ultraworkers-claw-code/rust/crates
YeonGyu-Kim 6ac7d8cd46 fix(api): omit tool_calls field from assistant messages when empty
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).
2026-04-09 22:06:25 +09:00
..
api fix(api): omit tool_calls field from assistant messages when empty 2026-04-09 22:06:25 +09:00
commands fix(cli): wire /tokens and /cache as aliases for /stats; implement /stats 2026-04-09 21:34:36 +09:00
compat-harness wip: plugins progress 2026-04-01 07:09:06 +00:00
mock-anthropic-service feat(harness+usage): add auto_compact and token_cost parity scenarios 2026-04-03 22:41:42 +09:00
plugins fix(plugins): chmod +x generated hook scripts + tolerate BrokenPipe in stdin write — closes ROADMAP #25 hotfix lane 2026-04-08 15:48:20 +09:00
runtime feat(cli): wire --reasoning-effort flag end-to-end — closes ROADMAP #34 2026-04-09 11:08:00 +09:00
rusty-claude-cli fix(cli): emit JSON for /config in --output-format json --resume mode 2026-04-09 22:03:11 +09:00
telemetry feat: anthropic SDK header matching + request profile 2026-04-01 05:55:25 +00:00
tools fix(tools): serialize web_search env-var tests with env_lock to prevent race 2026-04-08 18:34:06 +09:00