Retry incomplete Anthropic streams instead of ending as an empty reply

Merged
AN
14h ago
+881-104

Retry incomplete Anthropic streams instead of ending as an empty reply. Worker delivery rebased onto main; see the commit messages.


Summary by cubic

Fixes Anthropic streams that disconnect before completion so Pi and OpenCode retry instead of ending the turn with an empty reply.

Previously a stream that closed before the message_stop event was delivered as an empty successful response. Now the stream fails with a retryable ECONNRESET error, and content-free diagnostics — validated response headers, byte and event counts, and qualified timing — are logged as warnings and recorded in dump artifacts. Partial message identity and usage are preserved in dumps.

  • Streams must end with message_stop to count as complete; empty, partial, and unterminated 200 responses now surface as ECONNRESET, while explicit terminal error events keep their original failure. Response content type can no longer override the request's stream mode during thread recovery.
  • Diagnostics are scrubbed to fixed header names and numeric counters, so no response content or credentials leak into logs.