Skip to content

fix(llm): register official 200k context windows for o1, o1-pro and o3 - #7411

Open
Lubaoshuai wants to merge 1 commit into
crewAIInc:mainfrom
Lubaoshuai:fix/o-series-context-windows
Open

fix(llm): register official 200k context windows for o1, o1-pro and o3#7411
Lubaoshuai wants to merge 1 commit into
crewAIInc:mainfrom
Lubaoshuai:fix/o-series-context-windows

Conversation

@Lubaoshuai

Copy link
Copy Markdown

Fixes #7303

o1, o1-pro and o3 were missing from the context window tables, so lookups fell through to the 8k default (LLMContextLengthExceededError false positives, premature truncation).

Registers 200k for the three models in LLM_CONTEXT_WINDOW_SIZES (llm.py) and in the native OpenAI and Azure provider tables, while keeping the 128k windows for o1-preview and o1-mini. Prefix ordering follows each lookup's own semantics: llm.py iterates the whole table with last-match-wins, so the shorter o1 entry goes before the longer prefixes; the provider tables return on the first startswith match, so the new entries go after them.

Tests: parametrized regression cases for o1 / o1-pro / o3 / dated snapshots (200k) and o1-preview / o1-mini (still 128k) at all three layers (tests/test_llm.py, tests/llms/openai/test_openai.py, tests/llms/azure/test_azure.py).

o1, o1-pro and o3 were missing from the context window tables, so
lookups fell through to the 8k default and triggered false
LLMContextLengthExceededError or premature truncation (crewAIInc#7303).

Register 200k for the three models in the shared LLM_CONTEXT_WINDOW_SIZES
table and in the native OpenAI and Azure provider tables, keeping the
128k windows for o1-preview and o1-mini. Prefix ordering follows each
lookup's own semantics (last-match-wins in llm.py, first-match-wins in
the provider tables) so the longer 128k prefixes keep precedence.
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5746e462-bee6-4801-8864-3785fc24b0e0

📥 Commits

Reviewing files that changed from the base of the PR and between 894898f and 982b9f0.

📒 Files selected for processing (6)
  • lib/crewai/src/crewai/llm.py
  • lib/crewai/src/crewai/llms/providers/azure/completion.py
  • lib/crewai/src/crewai/llms/providers/openai/completion.py
  • lib/crewai/tests/llms/azure/test_azure.py
  • lib/crewai/tests/llms/openai/test_openai.py
  • lib/crewai/tests/test_llm.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change registers 200000-token context windows for o1, o1-pro, and o3 across shared, OpenAI, and Azure lookups. It preserves 128000-token windows for o1-preview and o1-mini. Tests cover provider and shared lookup behavior.

Changes

O-series context windows

Layer / File(s) Summary
Context window mappings
lib/crewai/src/crewai/llm.py, lib/crewai/src/crewai/llms/providers/openai/completion.py, lib/crewai/src/crewai/llms/providers/azure/completion.py
The shared, OpenAI, and Azure context-window lookups map supported O-series models to 200000 tokens. Longer prefixes remain ordered before shared prefixes.
Context window validation
lib/crewai/tests/test_llm.py, lib/crewai/tests/llms/openai/test_openai.py, lib/crewai/tests/llms/azure/test_azure.py
Parameterized tests verify 200000-token windows for O-series models and 128000-token windows for o1-preview and o1-mini.

Suggested reviewers: lorenzejay

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 982b9

The requested context-window mappings are implemented consistently across providers, with tests covering the important model variants and no unresolved merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: registering 200k context windows for the o1, o1-pro, and o3 models.
Description check ✅ Passed The description links issue #7303, explains the problem and solution, identifies prefix-ordering behavior, and describes regression tests across all affected layers. It does not use every template hea…
Linked Issues check ✅ Passed Issue #7303 coding requirements are implemented. llm.py registers o1, o1-pro, and o3 at 200000 tokens while preserving o1-preview and o1-mini at 128000. The OpenAI and Azure provider table…
Out of Scope Changes check ✅ Passed The changes stay within the context-window registration objective in issue #7303. The Azure o4-mini entry is an adjacent o-series registration in the same provider table and is covered by the same r…
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 6 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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.

[BUG] o1, o1-pro, and o3 reasoning models fallback to 8k default context window

1 participant