crewAIInc / crewAIInc/crewAI

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

Open
#7,303 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
58.8k
Forks
8.5k
Avg merge
1d 15h
Merged PRs (30d)
109

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the context-window tables in lib/crewai/src/crewai/llm.py, lib/crewai/src/crewai/llms/providers/openai/completion.py, and lib/crewai/src/crewai/llms/providers/azure/completion.py. Run the cases in test_llm.py, test_openai.py, and test_azure.py, checking that o1, o1-pro, and o3 resolve to 200,000 while o1-preview and o1-mini remain at 128,000.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, python
Domain
ai, backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.