Skip to content

fix(agents): strengthen Claude stream retries - #641

Merged
jdchawla29 merged 1 commit into
mainfrom
codex/claude-stream-backoff
Sep 2, 2026
Merged

fix(agents): strengthen Claude stream retries#641
jdchawla29 merged 1 commit into
mainfrom
codex/claude-stream-backoff

Conversation

@jdchawla29

@jdchawla29 jdchawla29 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • allow three total attempts for transient Claude stream failures
  • use bounded full-jitter exponential backoff and honor numeric retry delay headers
  • preserve the existing post-stream and transient-error retry boundary

Validation

  • uv run --all-extras pytest -q: 1141 passed, 17 deselected
  • uv run --all-extras pytest -q hud/agents/tests/test_claude_agent.py: 17 passed
  • uv run --all-extras ruff format . --check
  • uv run --all-extras ruff check .
  • uv run --all-extras ty check
  • git diff --check

Note

Low Risk
Localized resilience change in Claude streaming retries with bounded delays; no auth or data-handling changes.

Overview
Claude message streaming now retries transient failures up to three attempts (was effectively two with a single retry), using smarter delays instead of a fixed 1s sleep.

_stream_response adds _stream_retry_delay: for inline APIStatusError responses it prefers Retry-After / Retry-After-Ms (clamped to 0–5s); otherwise it uses full-jitter exponential backoff (1s base, 5s cap). Retry logging reports delay and attempt n/3. Which errors qualify for retry is unchanged.

Tests were updated for two backoff sleeps before success, exhaustion after three failures, and header-based delay behavior (including capping long retry-after values).

Reviewed by Cursor Bugbot for commit ca11eb0. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T05:16:10.591991Z ca11eb0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jdchawla29
jdchawla29 merged commit 6712cb3 into main Sep 2, 2026
8 checks passed
@jdchawla29
jdchawla29 deleted the codex/claude-stream-backoff branch September 2, 2026 05:53
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