crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Gemini 2.0 Flash Thinking window is wrong (1M, not 32k) and Bedrock provider resolves Claude 2.1 to 100k

Open Theater-ahyeon opened this issue 2 months ago • 2 comments

Description

Two context-window values in the provider tables are wrong or unreachable:

  1. gemini-2.0-flash-thinking is a 1M-token model, not 32k. Both LLM_CONTEXT_WINDOW_SIZES ("gemini-2.0-flash-thinking-exp-01-21": 32768) and the Gemini native provider ("gemini-2.0-flash-thinking": 32768) carry the 32,768 figure, but that belonged to the December exp-1219 snapshot. The exp-01-21 refresh raised the window to 1,048,576 tokens (see Google's long-context documentation and coverage of the January upgrade). With LLM(model="gemini-2.0-flash-thinking-exp-01-21", is_litellm=True) the litellm path currently returns 32768 × ratio.
  2. The Gemini native provider's 32k entry is also unreachable. "gemini-2.0-flash-thinking": 32768 sits after "gemini-2.0-flash": 1048576 in a first-match startswith loop, so gemini-2.0-flash-thinking-exp-01-21 resolves through the plain gemini-2.0-flash prefix and returns 1M. The two paths disagree with each other.
  3. The Bedrock provider table has no anthropic.claude-v2:1 entry, so Claude 2.1 resolves through the anthropic.claude-v2 prefix (Claude 2.0) and returns 100k instead of the 200k window llm.py's shared table already assigns to the :1 model id.

Steps to Reproduce

from crewai import LLM

# litellm path: returns 32768 * 0.85, expected 1048576 * 0.85
LLM(model="gemini-2.0-flash-thinking-exp-01-21", is_litellm=True).get_context_window_size()

# native gemini path: returns 1048576 * 0.85 (accidentally correct, table entry dead)
LLM(model="google/gemini-2.0-flash-thinking-exp-01-21").get_context_window_size()

# native bedrock path: returns 100000 * 0.85, expected 200000 * 0.85
LLM(model="bedrock/anthropic.claude-v2:1").get_context_window_size()

Expected behavior

All three paths return the model's official window. Related to #7436 / #7437 (the lookup-order issue in the shared table); this issue is about the stale values and the missing Bedrock entry.

Theater-ahyeon avatar Sep 13 '26 20:09 Theater-ahyeon

Thanks for splitting this out of #7436 and for the three-path repro, @Theater-ahyeon. It made checking the Bedrock half quick, and I only looked at that half.

I can confirm the lookup on main (7a01af2): bedrock/anthropic.claude-v2:1 returns 85000 because the provider table only carries the anthropic.claude-v2 prefix (llms/providers/bedrock/completion.py:2139) and the loop at :2149 takes the first startswith hit. One thing worth weighing before adding a 200k row, though: in us-east-1 and us-west-2, Bedrock reports both Claude 2.x ids as end-of-life. GetFoundationModel answers "reached the end of its life" for each, and ListFoundationModels returns zero claude-v2 entries. Since Vidit-Ostwal asked in #7340 to drop retired models from these maps, removing the two anthropic.claude-v2* rows may be the tidier fix for this part, and #7340 still carries both with # TODO(verify). Happy to leave it with you either way.

Model id (native path) main 7a01af2 Bedrock GetFoundationModel (2026-09-17)
bedrock/anthropic.claude-v2:1 85000 (100000 × 0.85) EOL
bedrock/anthropic.claude-v2 85000 EOL
$ python repro.py
bedrock/anthropic.claude-v2:1 BedrockCompletion 85000 (ratio=0.85)
bedrock/anthropic.claude-v2 BedrockCompletion 85000 (ratio=0.85)

$ aws bedrock get-foundation-model --region us-east-1 --model-identifier anthropic.claude-v2:1
An error occurred (ResourceNotFoundException) when calling the GetFoundationModel operation:
This model version has reached the end of its life. Use an active model version instead.
Details: where the PRs touch this and how I checked
  • #7442 (yours) and #7446 both add "anthropic.claude-v2:1": 200000 to the same Bedrock table in llms/providers/bedrock/completion.py, and both edit llm.py and the Gemini table that #7340 moves into llms/context_window.py, so all three will conflict with whichever lands first.
  • #7340 as of today keeps "anthropic.claude-v2": 100000, # TODO(verify) and "anthropic.claude-v2:1": 200000, # TODO(verify) in the new BEDROCK_CONTEXT_WINDOWS map.
  • Same GetFoundationModel error for anthropic.claude-v2 in us-east-1 and us-west-2. In eu-west-1 both ids come back ValidationException: The provided model identifier is invalid.
  • aws bedrock list-foundation-models --region us-east-1 --by-provider Anthropic --query "length(modelSummaries[?contains(modelId,'claude-v2')])" prints 0.
  • Repro script:
from crewai import LLM
from crewai.llm import CONTEXT_WINDOW_USAGE_RATIO
for m in ["bedrock/anthropic.claude-v2:1", "bedrock/anthropic.claude-v2"]:
    llm = LLM(model=m)
    print(m, type(llm).__name__, llm.get_context_window_size(), f"(ratio={CONTEXT_WINDOW_USAGE_RATIO})")

kimnamu avatar Sep 17 '26 01:09 kimnamu

Gemini 2.0 model are retired.

Vidit-Ostwal avatar Sep 29 '26 05:09 Vidit-Ostwal