Skip to content

fix: recover early provider stream disconnects - #10

Merged
SmartAI merged 1 commit into
mainfrom
fix/provider-stream-disconnect-recovery
Sep 14, 2026
Merged

SmartAI merged 1 commit into
mainfrom
fix/provider-stream-disconnect-recovery

Conversation

@SmartAI

@SmartAI SmartAI commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Retry transient streaming transport failures up to three attempts, with 1s/2s backoff, only before an SSE event reaches the adapter.
  • Stop safely after event delivery; do not replay partial output or completed tools. Keep HTTP error responses out of retry recovery.
  • Add per-attempt diagnostics: request ID, HTTP status/version, elapsed time, bytes received, last SSE event type, and terminal-event status. Do not log request headers, URLs, or payloads.

Why

A prematurely closed chunked HTTP response raises RemoteProtocolError and previously ended the turn immediately. Reproduced the exact incomplete-chunked-read failure with a local HTTP server. This change recovers early failures and adds evidence for upstream investigation; it does not establish why the upstream connection closed.

Validation

  • pytest -q tests/test_transport.py tests/test_providers.py tests/test_codex.py tests/test_agent.py — 59 passed
  • ruff check src/ava/transport/http.py tests/test_transport.py — passed
  • mypy src/ava/transport/http.py — passed
  • git diff --check — passed

Socket-level tests cover recovery, retry exhaustion, no replay after metadata/terminal events, truncated HTTP error responses, cancellation during backoff, and diagnostic privacy.

Limitation

Once any SSE event has been delivered, interrupted streams still fail rather than automatically retry. Even metadata can mutate adapter state. An early retry can also repeat upstream generation and incur additional provider cost.

@SmartAI
SmartAI merged commit 3a4fda9 into main Sep 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant