Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Nov 13, 2025

Fixes 400 error "messages.3.content.0.tool_use.input: Input should be a valid dictionary" when using native tools with OpenRouter routing to Anthropic.

Root Cause:
read_file's nativeArgs was stored as FileEntry[] instead of {files: FileEntry[]}, causing tool_use.input to be an array instead of an object in the API conversation history.

Changes:

  • Updated NativeToolArgs.read_file to {files: FileEntry[]} matching API schema
  • Updated parser, tool implementation, and call sites accordingly
  • Added debug logging to OpenRouter provider

All tools now store nativeArgs in their exact API-compatible format, eliminating special-case handling.


Important

Fixes 400 error by updating read_file tool's nativeArgs to match API schema, ensuring correct handling across the codebase.

  • Behavior:
    • Fixes 400 error by updating NativeToolArgs.read_file to {files: FileEntry[]} in tools.ts.
    • Ensures tool_use.input is an object, not an array, in Task.ts and NativeToolCallParser.ts.
  • Implementation:
    • Updates ReadFileTool methods to handle {files: FileEntry[]} format.
    • Adjusts presentAssistantMessage() in presentAssistantMessage.ts to use updated nativeArgs.
  • Misc:
    • Adds debug logging to OpenRouter provider for better error tracking.

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

Fixes #issue where OpenRouter throws a 400 error after 2 tool uses when routing to Anthropic.

Root cause: read_file's nativeArgs was stored as FileEntry[] instead of {files: FileEntry[]} like other tools, causing tool_use.input to be an array instead of an object when added to API conversation history.

Changes:
- Updated NativeToolArgs.read_file to store {files: FileEntry[]} matching API schema
- Updated NativeToolCallParser to wrap files array in object
- Updated ReadFileTool to accept/return object format
- Added debug logging to OpenRouter provider for troubleshooting

All tools now store nativeArgs in their exact API-compatible format, eliminating special-case handling.
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 13, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 13, 2025
@dosubot dosubot bot added the bug Something isn't working label Nov 13, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 13, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed successfully.

No issues found. The PR correctly addresses the 400 error by ensuring read_file's nativeArgs matches the API schema format {files: FileEntry[]} instead of a bare array. All changes are internally consistent and properly typed.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 13, 2025
@mrubens mrubens merged commit 237c324 into main Nov 13, 2025
24 checks passed
@mrubens mrubens deleted the fix/native-tools-400-error branch November 13, 2025 20:10
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 13, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 13, 2025
mini2s added a commit to zgsm-ai/costrict that referenced this pull request Nov 17, 2025