Description
I am encountering an issue in OpenCode v2 (version 2.0.18) where tool calls trigger a validation error from the provider.
This behavior is not present in OpenCode v1 with the same provider.
Plugins
none
OpenCode version
2.0.18
Steps to reproduce
- Use a custom provider
- Trigger any tool call
For example, I use the following prompt to reproduce: use the shell tool to call 'echo dummystring'
- The request sent to the provider contains "content": null for the assistant message that initiates the tool call
Actual behavior:
The provider returns a ValidationError because it expects a string or an array for the content field, but receives null.
Failing request
{
"model": "gemma-4-31b-it",
"messages": [
{ "role": "assistant", "content": null, "tool_calls": [...] }
]
}
Error response
{
"errors": [{
"errorMessage": "Request doesn't match the schema",
"message": "Invalid input: expected string, received null"
}]
}
Expected behavior:
The content field should be an empty string "" instead of null when a tool call is made without accompanying text.
Workaround / Proof of concept:
I created a small plugin that intercepts the request and replaces "content": null with "content": "".
With this change, the tool calls work perfectly.
Fixed request which is working
{
"model": "gemma-4-31b-it",
"messages": [
{ "role": "assistant", "content": "", "tool_calls": [...] }
]
}
Screenshot and/or share link
No response
Operating System
macOS
Terminal
Kitty, VSCode terminal, MacOS Terminal
Description
I am encountering an issue in OpenCode v2 (version 2.0.18) where tool calls trigger a validation error from the provider.
This behavior is not present in OpenCode v1 with the same provider.
Plugins
none
OpenCode version
2.0.18
Steps to reproduce
For example, I use the following prompt to reproduce:
use the shell tool to call 'echo dummystring'Actual behavior:
The provider returns a ValidationError because it expects a string or an array for the content field, but receives null.
Failing request
{ "model": "gemma-4-31b-it", "messages": [ { "role": "assistant", "content": null, "tool_calls": [...] } ] }Error response
{ "errors": [{ "errorMessage": "Request doesn't match the schema", "message": "Invalid input: expected string, received null" }] }Expected behavior:
The content field should be an empty string "" instead of null when a tool call is made without accompanying text.
Workaround / Proof of concept:
I created a small plugin that intercepts the request and replaces "content": null with "content": "".
With this change, the tool calls work perfectly.
Fixed request which is working
{ "model": "gemma-4-31b-it", "messages": [ { "role": "assistant", "content": "", "tool_calls": [...] } ] }Screenshot and/or share link
No response
Operating System
macOS
Terminal
Kitty, VSCode terminal, MacOS Terminal