Skip to content

harness(openai): populate profile context window from the hint table#36

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/openai-profile-context-window
Jul 8, 2026
Merged

harness(openai): populate profile context window from the hint table#36
senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/openai-profile-context-window

Conversation

@M3gA-Mind

@M3gA-Mind M3gA-Mind commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

derive_profile never populated max_input_tokens, so every OpenAiModel / OpenAI-compatible preset advertised max_input_tokens: None. SummarizationPolicy::from_profile reads the window from that field, so context-window-aware compaction fell back to a fixed generic threshold instead of the model's real window — trimming on the wrong boundary or overflowing.

Change

Populate max_input_tokens in derive_profile from the existing provider-neutral context_window_for_model_id(model) hint table (stays None for unrecognized ids, so nothing is guessed). No other profile fields change.

Tests

derive_profile_populates_known_context_windows (known ids resolve their window; unknown stays None). cargo fmt --check, cargo clippy --lib --tests -- -D warnings, and cargo test --lib all pass.

Closes tinyhumansai/openhuman#4634

Summary by CodeRabbit

  • Bug Fixes
    • Improved automatic handling of recognized OpenAI model IDs so the app now sets the correct input context size for supported models.
    • Unrecognized model IDs continue to be treated safely, avoiding incorrect profile assumptions.
    • Added coverage to prevent regressions in model profile detection and context window selection.

derive_profile left max_input_tokens None, so SummarizationPolicy::from_profile
saw no window and context-window-aware compaction fell back to a fixed generic
threshold. Source it from context_window_for_model_id (stays None for
unrecognized ids, so nothing is guessed).
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b45b408d-5b80-412e-9040-04ee23044701

📥 Commits

Reviewing files that changed from the base of the PR and between b6ae2b6 and abf1640.

📒 Files selected for processing (2)
  • src/harness/model/mod.rs
  • src/harness/stream/mod.rs
📝 Walkthrough

Walkthrough

The derive_profile function in the OpenAI transport module now populates max_input_tokens on the resulting ModelProfile by calling context_window_for_model_id, with updated documentation reflecting this behavior. A new unit test validates known and unrecognized model IDs.

Changes

Context Window Population in derive_profile

Layer / File(s) Summary
Populate max_input_tokens from lookup table
src/harness/providers/openai/transport.rs
derive_profile doc comment and implementation updated to set max_input_tokens via context_window_for_model_id(model) instead of relying on the default profile value.
Test coverage for known/unknown model IDs
src/harness/providers/openai/test.rs
New test derive_profile_populates_known_context_windows asserts correct max_input_tokens for gpt-4o-mini and gpt-4.1, and None for an unrecognized model ID.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

Possibly related PRs

Poem

A rabbit hopped through tokens wide,
Found windows where the model's ID guides. 🐰
No more guessing, no more None,
gpt-4o-mini's context is done!
Hop, test, and check it twice —
Compaction now trims just right. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: populating OpenAI profile context windows from the hint table.
Linked Issues check ✅ Passed The PR sets max_input_tokens from context_window_for_model_id and preserves None for unknown models, matching #4634.
Out of Scope Changes check ✅ Passed The changes stay focused on the OpenAI profile fix and its test coverage, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands.

collapsible_if in StreamAccumulator::push_tool_chunk and a duplicated
#[cfg(test)] on the stream test module both fail CI's
cargo clippy --all-targets -- -D warnings under rust 1.96. Behavior-neutral.
@M3gA-Mind

Copy link
Copy Markdown
Contributor Author

CI guardian: the Rust SDK check was red on a pre-existing main clippy failure under stable rust 1.96 (a collapsible_if in StreamAccumulator::push_tool_chunk and a duplicated #[cfg(test)] on the stream test module), inherited by this branch. Pushed a behavior-neutral lint fix so CI can go green; no change to this PR's own logic.

@senamakel
senamakel merged commit de6c440 into tinyhumansai:main Jul 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TinyAgents][T1] Default OpenAI(-compatible) profiles omit context windows — window-aware compaction no-ops

3 participants