fix(llm): register official 200k context window for o1 and o3 (#7303) - #7354
fix(llm): register official 200k context window for o1 and o3 (#7303)#7354Rohitkanithi wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughChangesThe change adds 128,000- and 200,000-token context window mappings for OpenAI and Azure o-series reasoning models. Shared and provider-specific tests verify the resolved values after applying Reasoning model context windows
Suggested reviewers: Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to OpenAI and Azure o-series models now use their registered context windows rather than the default fallback, preventing premature truncation and false context-length failures. The covered mappings are ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Fixes #7303
Summary
As noted in the issue description, I already had this patch and test suite completed and submitted. Opening this PR with complete coverage across
test_llm,test_openai, andtest_azure.Problem
The official context window for OpenAI's flagship reasoning models (
o1,o1-pro, ando3) and Azure OpenAI deployments ofo1,o1-mini, ando3-miniis 200,000 tokens. Previously, they were missing fromLLM_CONTEXT_WINDOW_SIZESand native providercontext_windowstables.Because prefix matching fails (
"o1".startswith("o1-preview")is false), queries usingmodel="o1"ormodel="o3"fell back toDEFAULT_CONTEXT_WINDOW_SIZE(8,192 tokens, resolving to 6,963 usable tokens with ratio 0.85). This triggered falseLLMContextLengthExceededErroror premature prompt truncation on reasoning models.Changes
"o1": 200000,"o1-pro": 200000, and"o3": 200000toLLM_CONTEXT_WINDOW_SIZESinlib/crewai/src/crewai/llm.py, preserving128000foro1-previewando1-mini."o1-pro": 200000,"o1": 200000, and"o3": 200000tocontext_windowsinlib/crewai/src/crewai/llms/providers/openai/completion.pywith longest-prefix-first ordering.o1-preview,o1-mini,o1-pro,o1,o3-mini,o3, ando4-minitolib/crewai/src/crewai/llms/providers/azure/completion.py.lib/crewai/tests/test_llm.pylib/crewai/tests/llms/openai/test_openai.pylib/crewai/tests/llms/azure/test_azure.pyVerification
o1,o1-pro,o3,o1-mini, ando1-previewacross LiteLLM, OpenAI, and Azure paths.