Bug: Tool calls with nil arguments fail when using Anthropic models via GitHub Copilot
Describe the bug
When using Anthropic models via GitHub Copilot (e.g., github-copilot/claude-opus-4-5 or github-copilot/claude-sonnet-4-5), tool calls with no arguments (nil/empty) cause an API error and block further conversation.
The error from opus:
LLM response status: 400 body: {"error":{"message":"messages.3.content.0.tool_use.input: Input should be a valid dictionary","code":"invalid_request_body"}}
The error from sonnet:
LLM response status: 400 body: Bad Request
The issue is that GitHub Copilot's backend appears to proxy Anthropic model requests using Anthropic's native API format, which expects tool_use.input to be a dictionary, not a JSON string. However, ECA formats tool calls for the openai-chat API where function.arguments is a JSON string.
When (:arguments content) is nil, (json/generate-string nil) produces "null". When the Copilot proxy translates this to Anthropic format, null is not a valid dictionary, causing the API rejection.
To Reproduce
- Login to GitHub Copilot
- Select an Anthropic model like
github-copilot/claude-opus-4-5 - Run any tool that takes no arguments (e.g.,
editor_diagnostics) - The tool executes successfully
- On the next API call (sending the conversation history back), the API returns a 400 error
- The conversation is now stuck - any attempt to continue immediately fails with the same error
Expected behavior Tool calls with no arguments should work correctly with Anthropic models accessed via GitHub Copilot.
Note
Clearing the chat (/clear) and starting over doesn't help.
Analysis
The bug is in src/eca/llm_providers/openai_chat.clj in the transform-message function:
:function {:name (:full-name content)
:arguments (json/generate-string (:arguments content))}
When :arguments is nil, this produces "null" which GitHub Copilot's Anthropic proxy rejects.
Suggested fix
:arguments (json/generate-string (or (:arguments content) {}))
This ensures nil arguments become "{}" (empty object) rather than "null".
Additional context
- This only affects Anthropic models accessed via GitHub Copilot
- OpenAI models via Copilot (e.g.,
gpt-5) work fine with no-argument tools - Direct Anthropic provider usage is handled by
anthropic.cljwhich correctly uses(or (:arguments content) {})on line 125
Thank you for the report and finding the issue @itkonen this is something some people complained but I could not repro, now I can! I will fix it!
Fixed on 0.109.3!
Thank you very much for your amazing work! It's working perfectly now!