diff --git a/internal/multiagent/runner.go b/internal/multiagent/runner.go index 2f5cc10a..9c98f966 100644 --- a/internal/multiagent/runner.go +++ b/internal/multiagent/runner.go @@ -597,6 +597,13 @@ func chatToolCallsToSchema(tcs []agent.ToolCall) []schema.ToolCall { argsStr = string(b) } } + // Some OpenAI-compatible gateways require `function.arguments` to exist + // on every assistant tool_call message. When args are empty, omitempty may + // drop the field during serialization and cause "missing field arguments" + // on the next turn history replay. + if strings.TrimSpace(argsStr) == "" { + argsStr = "{}" + } typ := tc.Type if typ == "" { typ = "function"