mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-09-20 00:48:00 +00:00
An agent client (pi) serialises an assistant turn whose content is only [thinking, toolCall] as content:[] with tool_calls. The multimodal-strip pass treated an empty content array as 'nothing left, drop the whole message' and discarded the tool_calls with it. The next message is that call's tool result, so it arrived orphaned: the model saw a result for a call it had never made and re-issued the same call on every turn — an endless repeated-tool-call loop. Reproduced against a capture sink: content:[] lost tool_calls, while content:"" and content:null kept them. Only messages with neither usable content NOR a tool call now get dropped. Content that collapses to empty but still has tool_calls or a tool_call_id is emitted as "" instead. Test: TestOpenCodeKeepsToolCallWithEmptyContent (plus a negative control that an image-only message without tool calls is still dropped).