-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: resolve 400 error with native tools on OpenRouter #9238
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Contributor
Review completed successfully. No issues found. The PR correctly addresses the 400 error by ensuring Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
mrubens
approved these changes
Nov 13, 2025
mini2s
added a commit
to zgsm-ai/costrict
that referenced
this pull request
Nov 17, 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'snativeArgswas stored asFileEntry[]instead of{files: FileEntry[]}, causingtool_use.inputto be an array instead of an object in the API conversation history.Changes:
NativeToolArgs.read_fileto{files: FileEntry[]}matching API schemaAll tools now store
nativeArgsin their exact API-compatible format, eliminating special-case handling.Important
Fixes 400 error by updating
read_filetool'snativeArgsto match API schema, ensuring correct handling across the codebase.NativeToolArgs.read_fileto{files: FileEntry[]}intools.ts.tool_use.inputis an object, not an array, inTask.tsandNativeToolCallParser.ts.ReadFileToolmethods to handle{files: FileEntry[]}format.presentAssistantMessage()inpresentAssistantMessage.tsto use updatednativeArgs.This description was created by
for b09338c. You can customize this summary. It will automatically update as commits are pushed.