crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

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

Open Rohitkanithi opened this issue 2 months ago • 2 comments

Description

OpenAI's flagship reasoning models (o1, o1-pro, o3) and Azure OpenAI deployments of o1, o1-mini, and o3-mini are missing from LLM_CONTEXT_WINDOW_SIZES and native provider context window tables.

Because prefix lookup fails ("o1".startswith("o1-preview") is false), querying with model="o1" or model="o3" falls back to DEFAULT_CONTEXT_WINDOW_SIZE (8,192 tokens, or 6,144 usable tokens with ratio) instead of their official 200,000 tokens. This can trigger false LLMContextLengthExceededError or premature prompt truncation.

Proposed Solution

Register official 200k context windows for o1, o1-pro, and o3 across llm.py, openai/completion.py, and azure/completion.py, while preserving the 128k windows for o1-preview and o1-mini.

Steps to Reproduce

  1. Initialize an LLM instance with an o-series model: llm = LLM(model="o1", is_litellm=True)
  2. Query its context window: size = llm.get_context_window_size()
  3. Check the returned size: Expected ~150,000 (200k * 0.75 ratio), but returns 6,144 (8k * 0.75 ratio).

Expected behavior

o1, o1-pro, and o3 should recognize the official 200,000 context window (150,000 usable after ratio), while o1-preview and o1-mini retain their 128,000 window.

Screenshots/Code snippets

from crewai.llm import LLM

llm = LLM(model="o1") print(llm.get_context_window_size())

Outputs: 6144 (Incorrect: default 8192 * 0.75)

Expected: 150000 (Official 200000 * 0.75)

Operating System

macOS Sonoma

Python Version

3.12

crewAI Version

1.15.20

crewAI Tools Version

1.15.20

Virtual Environment

Venv

Evidence

In lib/crewai/src/crewai/llm.py: LLM_CONTEXT_WINDOW_SIZES contains "o1-preview": 128000 and "o1-mini": 128000, but omits "o1", "o1-pro", and "o3".

In lib/crewai/src/crewai/llms/providers/openai/completion.py: context_windows omits "o1", "o1-pro", and "o3".

In lib/crewai/src/crewai/llms/providers/azure/completion.py: context_windows omits all o-series models.

Possible Solution

  1. Add "o1": 200000, "o1-pro": 200000, "o3": 200000 to LLM_CONTEXT_WINDOW_SIZES in lib/crewai/src/crewai/llm.py.
  2. Add "o1-pro", "o1", "o3" to context_windows in openai/completion.py with longest-prefix-first ordering.
  3. Add o-series models to azure/completion.py context_windows.

Additional context

I have already developed and tested a patch with unit tests in test_llm.py, test_openai.py, and test_azure.py, and will submit a PR linking to this issue immediately.

Rohitkanithi avatar Sep 07 '26 05:09 Rohitkanithi

Looks like #7796 (centralize and refresh context windows) resolved this: o1, o1-pro, and o3 are now registered at 200k in crewai/llms/context_window.py, with o1-preview and o1-mini at 128k. This can probably be closed.

SWAPI03 avatar Oct 01 '26 06:10 SWAPI03

Fixed by #7796, which centralizes context-window lookup and includes the o1, o1-pro, and o3 windows. Closing the open pull requests that targeted this issue as superseded.

Vidit-Ostwal avatar Oct 01 '26 11:10 Vidit-Ostwal