Skip to content

fix: add Anthropic error pattern for context window detection (#4381)#4382

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770322173-fix-anthropic-context-window-detection
Open

fix: add Anthropic error pattern for context window detection (#4381)#4382
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770322173-fix-anthropic-context-window-detection

Conversation

@devin-ai-integration
Copy link
Contributor

Summary

Adds "prompt is too long" to the CONTEXT_LIMIT_ERRORS pattern list so that Anthropic's context window error ("prompt is too long: 210094 tokens > 200000 maximum") is properly detected. Without this, respect_context_window=True silently fails for Anthropic/Claude models because the error message doesn't match any existing pattern, preventing automatic summarization.

Production change: one string added to lib/crewai/src/crewai/utilities/exceptions/context_window_exceeding_exception.py

Closes #4381

Review & Testing Checklist for Human

  • Verify "prompt is too long" won't false-positive on non-context-window errors from any supported provider (the substring match is case-insensitive)
  • Consider whether other Anthropic error message variants exist beyond the one reported in the issue that should also be covered

Notes

Requested by: João
Link to Devin run

Adds 'prompt is too long' to CONTEXT_LIMIT_ERRORS so that Anthropic's
context window errors are properly recognized when respect_context_window=True.

Closes #4381

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anthropic error pattern not recognized for context window detection

0 participants