mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-04-11 02:20:18 +08:00
When serializing a multi-turn conversation for the OpenAI-compatible path, assistant messages with no tool calls were always emitting 'tool_calls: []'. Some providers reject requests where a prior assistant turn carries an explicit empty tool_calls array (400 on subsequent turns after a plain text assistant response). Fix: only include 'tool_calls' in the serialized assistant message when the vec is non-empty. Empty case omits the field entirely. This is a companion fix to fd7aade (null tool_calls in stream delta). The two bugs are symmetric: fd7aade handled inbound null -> empty vec; this handles outbound empty vec -> field omitted. Two regression tests added: - assistant_message_without_tool_calls_omits_tool_calls_field - assistant_message_with_tool_calls_includes_tool_calls_field 115 api tests pass. Fmt clean. Source: gaebal-gajae repro 2026-04-09 (400 on multi-turn, companion to null tool_calls stream-delta fix).