Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Nov 25, 2025

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 reasoning was 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 AnthropicVertexHandler was not filtering out reasoning type messages before sending them to the Vertex AI API. This fix adds filtering similar to what GeminiHandler does, removing messages with type: "reasoning" which are not recognized by the Vertex AI API.

Changes

  • Added message filtering in AnthropicVertexHandler.createMessage() to remove reasoning type messages
  • Added a test case to verify that reasoning messages are properly filtered out

Testing

  • All existing tests pass
  • Added new test case specifically for reasoning message filtering
  • Ran: npx vitest run src/api/providers/__tests__/anthropic-vertex.spec.ts

Fixes #9583


Important

Filters out reasoning type messages in AnthropicVertexHandler to prevent Vertex AI API errors, with tests added to verify behavior.

  • Behavior:
    • Filters out reasoning type messages in AnthropicVertexHandler.createMessage() to prevent errors with Vertex AI API.
  • Testing:
    • Adds test case in anthropic-vertex.spec.ts to verify reasoning messages are filtered out.
    • Confirms all existing tests pass and new test case is executed successfully.

This description was created by Ellipsis for 30304e2. You can customize this summary. It will automatically update as commits are pushed.

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
@roomote
Copy link
Contributor Author

roomote bot commented Nov 25, 2025

Rooviewer Clock   See task on Roo Cloud

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.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 25, 2025
@daniel-lxs daniel-lxs closed this Nov 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 25, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Nov 25, 2025
@daniel-lxs daniel-lxs reopened this Nov 25, 2025
@github-project-automation github-project-automation bot moved this from Done to New in Roo Code Roadmap Nov 25, 2025
@github-project-automation github-project-automation bot moved this from Done to Triage in Roo Code Roadmap Nov 25, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Nov 25, 2025

Rooviewer Clock   See task on Roo Cloud

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.

hannesrudolph added a commit that referenced this pull request Nov 26, 2025
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
hannesrudolph added a commit that referenced this pull request Nov 26, 2025
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
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Nov 26, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Input tag 'reasoning' found using 'type' does not match any of the expected tags on Claude Sonnet 4.5

4 participants