fix(llm): correct gpt-4o-mini context window 200000 -> 128000 - #7294
Conversation
gpt-4o-mini's official context window is 128,000 tokens (OpenAI announcement and API docs; litellm's model database agrees), but the shared LLM_CONTEXT_WINDOW_SIZES table and the OpenAI/Azure provider-local tables listed 200000 - apparently copied from the neighboring o3-mini / o4-mini entries. With CONTEXT_WINDOW_USAGE_RATIO = 0.85, crews resolved the usable window to 170000 instead of 108800, letting history grow past the model's real 128k limit and failing with API 400s on long runs. Fixes crewAIInc#7293
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change corrects the ChangesContext window correction
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This corrects the gpt-4o-mini context limit across shared, OpenAI, and Azure paths, preventing oversized histories from exceeding the model limit. The change is ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Vidit-Ostwal
left a comment
There was a problem hiding this comment.
Approved. Official OpenAI docs list gpt-4o-mini at 128,000 context tokens (and 16,384 max output). The previous 200000 matches Tier 1 TPM, not the context window. The three table updates (LiteLLM, native OpenAI, Azure) are the right places and leave other model lookups alone.
|
Thanks for things, cheers |
Related issue
Fixes #7293
Summary
gpt-4o-mini's official context window is 128,000 tokens (OpenAI announcement and API docs); litellm's own model database also reportsmax_input_tokens = 128000. The sharedLLM_CONTEXT_WINDOW_SIZEStable and the OpenAI/Azure provider-local tables list 200000 — apparently copied from the neighboringo3-mini/o4-minientries (both 200000). The same tables listgpt-4oas 128000, so the smallerminihaving a larger window is internally inconsistent.Because
get_context_window_size()appliesCONTEXT_WINDOW_USAGE_RATIO = 0.85, crews usinggpt-4o-miniresolved their usable window to170000instead of108800on all three provider paths (the litellm-path lookup inllm.pyiterates withoutbreak, sogpt-4o-miniresolves to its own entry), letting conversation history grow past the model's real 128k limit and failing with API 400s on long-running crews.This changes only the
gpt-4o-minivalue in three places — no key additions, removals, or reordering, so lookups for any other model are unaffected.Note for review: open PR #6603 (longest-prefix matching) adds a test asserting
gpt-4o-mini == 200000; if it merges first, its assertion needs the same correction.Verification
pytest lib/crewai/tests/test_llm.py -k context_window, 10 passed); happy to add a dedicatedgpt-4o-miniregression test if preferredLocal checks:
uv run ruff check <changed files>anduv run ruff format --check <changed files>: cleanpytest lib/crewai/tests/test_llm.py -q: 89 passed, 3 skipped (2 pre-existing environment errors on Windows, reproduced on unmodifiedmain)gpt-4o-miniwindow-size occurrencesAdditional context
llm-generatedlabel (contributors without triage permissions cannot add labels themselves).