Skip to content

Resolve bounded o1/o3 mid-name segments to the 200K context window#60

Open
M3gA-Mind wants to merge 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:feat/oseries-segment-context
Open

Resolve bounded o1/o3 mid-name segments to the 200K context window#60
M3gA-Mind wants to merge 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:feat/oseries-segment-context

Conversation

@M3gA-Mind

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

Copy link
Copy Markdown
Contributor

Upstreams bounded o-series (o1/o3) mid-name segment matching for tinyhumansai/openhuman#4566 (Part 1 of 2; host cutover follows after release + pin bump).

Problem

context_window_for_model_id resolves canonical o1/o3 ids (o1, o1-mini, openai/o1-preview, …) but returned None for a bounded -o1-/-o3- token embedded mid-name (e.g. ollama/mistral-for-o1-benchmark). Segment-mode matching only inspected the leading token of the final /- or :-delimited component, so any o-series token that wasn't at the start of the model name was missed.

Change

Segment matching now scans the whole lowercased id and accepts any occurrence of the pattern that is delimited by a non-alphanumeric boundary (or the string start/end) on both sides. This mirrors the semantics of the host heuristic being retired (o1_o3_segment_context in openhuman's model_context.rs):

  • Mid-name o1/o3 tokens now resolve to the 200K reasoning-model window (ollama/mistral-for-o1-benchmark, vllm/qwen-o3-eval.bench).
  • Canonical ids continue to resolve (o1, o1-mini, o3-mini, openai/o1-preview).
  • The boundary guard keeps substrings from over-matching: solo1-7b, proto3-chat, octo3thing stay unmatched.

This is only the crate's own generic resolution; hosts keep their tier aliases / cost-catalog arms (out of scope here).

Tests

Extended o1_o3_context_patterns_require_segment_boundaries in src/harness/model/test.rs with the new positive mid-name cases and the negative boundary cases.

Commands run locally (all green)

  • cargo fmt --check
  • cargo clippy --lib --tests -- -D warnings
  • cargo test --lib — 1127 passed, 0 failed

Follow-up (Part 2, not in this PR)

The host cutover — deleting o1_o3_segment_context from openhuman's model_context.rs and bumping the tinyagents pin — is blocked until this change is merged, released, and the pin bumped. Tracked under tinyhumansai/openhuman#4566.

Summary by CodeRabbit

  • Bug Fixes
    • Improved model detection for context-window patterns embedded within model names.
    • Correctly recognizes valid o1/o3 patterns when surrounded by non-alphanumeric boundaries, including names with prefixes, suffixes, or provider paths.
    • Prevents false matches when o1/o3 appears within larger alphanumeric strings.

Segment-mode context matching only checked the first `/`- and `:`-delimited
component's leading token, so an o-series id embedded mid-name (e.g.
`ollama/mistral-for-o1-benchmark`) returned None. Scan the whole lowercased id
for the pattern and accept any occurrence bounded by non-alphanumeric edges, so
mid-name o1/o3 tokens resolve to 200K while substrings like `solo1-7b`,
`proto3-chat`, and `octo3thing` stay unmatched.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ef2ce8d1-8bbf-4296-a4cc-17a1f36ad505

📥 Commits

Reviewing files that changed from the base of the PR and between 674d89f and 82fbe8a.

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

📝 Walkthrough

Walkthrough

ContextPatternMatch::Segment now detects bounded pattern occurrences across the full model ID. Tests update o1/o3 expectations for delimited mid-name matches and reject unbounded substrings.

Changes

Model-ID context patterns

Layer / File(s) Summary
Bounded segment matching
src/harness/model/mod.rs
Segment matching scans the full lowercased model ID and accepts occurrences bounded by non-alphanumeric characters or string edges.
O-series boundary validation
src/harness/model/test.rs
Tests cover canonical IDs, delimited mid-name o1/o3 matches, and invalid embedded substrings.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: senamakel

Poem

I bounded the model names with care,
So o1 and o3 can bloom mid-pair.
Dashes and dots now mark the way,
While tangled substrings must stay away.
A rabbit-tested match, hooray!

🚥 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 accurately summarizes the main change: bounded mid-name o1/o3 matches now resolve to the 200K context window.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

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.

1 participant