mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 11:43:57 +08:00
9db9c56fda
When a third-party gateway returns tool calls without a function name, the Chat -> Responses transform silently discarded them and still marked the turn as `completed`. Codex then saw a successful turn with nothing left to do and ended its agent loop without any error, turning a diagnosable upstream failure into a silent stall. - Emit `response.failed` (streaming) or a transform error (non-streaming) when every tool call in a turn was dropped and none remains usable. Gated on `status == "completed"` so that `finish_reason: length` truncation keeps its own `incomplete` semantics, matching the existing Anthropic streaming path. - Log all three drop sites with structured, content-free fields (call_id presence, argument byte counts, finish reason) so the upstream defect can finally be diagnosed from real traffic. - Treat whitespace-only function names as missing, and resolve tool keys conservatively when upstream omits the required `index` field. Turns that still contain a valid tool call, text-only turns and truncated turns are unaffected. Adds 13 tests. Refs #4341