From 9478f425e28eaf9ebe704843e7ea2ca850466d1e Mon Sep 17 00:00:00 2001 From: Shxiao101 Date: Sun, 6 Sep 2026 14:53:32 +0900 Subject: [PATCH] fix(llm): correct gpt-4o-mini context window 200000 -> 128000 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 #7293 --- lib/crewai/src/crewai/llm.py | 2 +- lib/crewai/src/crewai/llms/providers/azure/completion.py | 2 +- lib/crewai/src/crewai/llms/providers/openai/completion.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/crewai/src/crewai/llm.py b/lib/crewai/src/crewai/llm.py index c2924e5427..e6604805d4 100644 --- a/lib/crewai/src/crewai/llm.py +++ b/lib/crewai/src/crewai/llm.py @@ -170,7 +170,7 @@ def _ensure_litellm() -> bool: LLM_CONTEXT_WINDOW_SIZES: Final[dict[str, int]] = { "gpt-4": 8192, "gpt-4o": 128000, - "gpt-4o-mini": 200000, + "gpt-4o-mini": 128000, "gpt-5.4-mini": 200000, "gpt-5.6": 1050000, # sol, terra, luna, and the gpt-5.6 alias "gpt-4-turbo": 128000, diff --git a/lib/crewai/src/crewai/llms/providers/azure/completion.py b/lib/crewai/src/crewai/llms/providers/azure/completion.py index 8cdb49cca7..eecc1a0592 100644 --- a/lib/crewai/src/crewai/llms/providers/azure/completion.py +++ b/lib/crewai/src/crewai/llms/providers/azure/completion.py @@ -1320,7 +1320,7 @@ def get_context_window_size(self) -> int: "gpt-3.5-turbo": 16385, "gpt-5.4-mini": 200000, "gpt-35-turbo": 16385, - "gpt-4o-mini": 200000, + "gpt-4o-mini": 128000, "gpt-4-turbo": 128000, "gpt-5.6": 1050000, "gpt-4o": 128000, diff --git a/lib/crewai/src/crewai/llms/providers/openai/completion.py b/lib/crewai/src/crewai/llms/providers/openai/completion.py index 20234e5019..280c314eac 100644 --- a/lib/crewai/src/crewai/llms/providers/openai/completion.py +++ b/lib/crewai/src/crewai/llms/providers/openai/completion.py @@ -2682,7 +2682,7 @@ def get_context_window_size(self) -> int: "gpt-4.1-nano-2025-04-14": 1047576, "gpt-5.4-mini": 200000, "gpt-4-turbo": 128000, - "gpt-4o-mini": 200000, + "gpt-4o-mini": 128000, "gpt-5-mini": 1047576, "gpt-5-nano": 1047576, "o1-preview": 128000,