-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: filter out reasoning type messages in AnthropicVertexHandler #9584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The AnthropicVertexHandler was not filtering out reasoning type messages before sending them to the Vertex AI API, causing an error when the context filled up. This fix adds filtering similar to what GeminiHandler does, removing messages with type: "reasoning" which are not recognized by the Vertex AI API. Fixes #9583
Review complete. No issues found. The implementation correctly filters out reasoning-type messages before sending to the Vertex AI API, matching the proven pattern used in GeminiHandler. The test coverage is comprehensive and all changes follow existing code patterns. Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Review complete. No issues found. The implementation correctly filters out reasoning-type messages before sending to the Vertex AI API, matching the proven pattern used in GeminiHandler. The test coverage is comprehensive and all changes follow existing code patterns. Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Fixes context condensation error when using reasoning with Anthropic models on Vertex: 'Input tag reasoning found using type does not match any of the expected tags' The issue occurs because: 1. Roo Code stores reasoning content internally with type: 'reasoning' 2. Gemini stores thought signatures with type: 'thoughtSignature' 3. When messages are replayed to Anthropic/Vertex APIs, these non-standard types cause 400 errors Solution: - Added filterNonAnthropicBlocks() to anthropic-vertex.ts and anthropic.ts - Filters out 'reasoning' (internal Roo format) and 'thoughtSignature' (Gemini format) - Removes empty messages after filtering This follows the same pattern used by: - Gemini handler (filters 'reasoning' messages) - gemini-format.ts (skips unsupported block types) - Claude Code handler (filterMessagesForClaudeCode for images) Fixes #9583 Related to #9584
Fixes context condensation error when using reasoning with Anthropic models on Vertex: 'Input tag reasoning found using type does not match any of the expected tags' The issue occurs because: 1. Roo Code stores reasoning content internally with type: 'reasoning' 2. Gemini stores thought signatures with type: 'thoughtSignature' 3. When messages are replayed to Anthropic/Vertex APIs, these non-standard types cause 400 errors Solution: - Added filterNonAnthropicBlocks() to anthropic-vertex.ts and anthropic.ts - Filters out 'reasoning' (internal Roo format) and 'thoughtSignature' (Gemini format) - Removes empty messages after filtering This follows the same pattern used by: - Gemini handler (filters 'reasoning' messages) - gemini-format.ts (skips unsupported block types) - Claude Code handler (filterMessagesForClaudeCode for images) Fixes #9583 Related to #9584
This PR attempts to address Issue #9583. Feedback and guidance are welcome.
Problem
Users were experiencing an error with Google Vertex AI when using Claude Sonnet models. The error message indicated that an input tag
reasoningwas being sent but is not recognized by the Vertex AI API. The valid tags are:document,image,redacted_thinking,search_result,text,thinking,tool_result,tool_use.Solution
The
AnthropicVertexHandlerwas not filtering outreasoningtype messages before sending them to the Vertex AI API. This fix adds filtering similar to whatGeminiHandlerdoes, removing messages withtype: "reasoning"which are not recognized by the Vertex AI API.Changes
AnthropicVertexHandler.createMessage()to removereasoningtype messagesTesting
npx vitest run src/api/providers/__tests__/anthropic-vertex.spec.tsFixes #9583
Important
Filters out
reasoningtype messages inAnthropicVertexHandlerto prevent Vertex AI API errors, with tests added to verify behavior.reasoningtype messages inAnthropicVertexHandler.createMessage()to prevent errors with Vertex AI API.anthropic-vertex.spec.tsto verifyreasoningmessages are filtered out.This description was created by
for 30304e2. You can customize this summary. It will automatically update as commits are pushed.