mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
Upstream Chat/Responses turns sometimes end with finish_reason tool_calls while delivering no usable tool call (empty tool_calls array, or deltas without a name). The bridge forwarded that as stop_reason tool_use with zero tool_use content blocks. Strict clients then end the turn running nothing and reporting no error, which stalls agent loops mid-task with no visible failure. Guard both the streaming (Finish) and non-streaming (encodeBridgeResponse) paths: a tool stop with no assembled tool is demoted to a plain stop so the client treats it as text end-of-turn and continues.