mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
Mid-stream api_error/overloaded_error SSE events (e.g. a local provider such as LM Studio rejecting a malformed tool_call) arrive inside the 200 SSE body, bypassing withRetry — which only guards stream creation — so they were surfaced as a terminal API error that ended the turn with no retry. Add withStreamRetry around queryModel: when an attempt produced zero output (no tool_use block completed, so query.ts never started a tool — safe w.r.t. the double-tool-execution hazard, inc-4258), re-establish the stream and retry up to CLAUDE_STREAM_TRANSIENT_RETRY_MAX times (default 2) before surfacing the error. Covers both the streaming and non-streaming query wrappers; adds unit tests for the retry loop and the transient-error classifier.