Skip to content

feat: env-tunable 529 retry budget for headless runs - #352

Merged
dahai80 merged 1 commit into
mainfrom
fix-529-retry-budget
Nov 26, 2026
Merged

dahai80 merged 1 commit into
mainfrom
fix-529-retry-budget

Conversation

@dahai80

@dahai80 dahai80 commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Fixes #349 (option 1 — minimal surgical fix).

Problem

Headless -p dispatches hard-fail after 3 consecutive 529s (MAX_529_RETRIES) while claude code rides the same transient capacity cascade out with ~10 attempts and exponential backoff. A console worker fleet sees a failed task for what is a blip; claude workers on the same gateway at the same time all completed.

Change

  • FUSION_CODE_MAX_529_RETRIES env override of the 529 strike budget for foreground/headless sources, clamped to DEFAULT_MAX_RETRIES (10) so a stuck gateway still terminates the turn.
  • Default unchanged (3) for interactive REPL use.
  • Background sources keep bailing immediately — the anti-amplification rationale for non-foreground queries is untouched.
  • Option 2 of the issue (exposing the ant-only persistent retry gate outside internal builds) is a larger behavioral change and is deliberately not included; the env-tunable budget covers the observed failure mode.

Tests

New withRetry529.test.ts (backoff sleep stubbed): default 3-strike hard fail preserved; budget=10 rides out 5 strikes and returns ok; budget=999 clamps to 10. Full suite 1849 pass / 0 fail, tsc clean.

🤖 Generated with Claude Code

Headless -p dispatches hard-fail after 3 consecutive 529s
(MAX_529_RETRIES) while claude code rides the same transient capacity
cascade out with ~10 attempts — console worker fleets see a failed task
for what is a blip. Add FUSION_CODE_MAX_529_RETRIES: operators raise
the budget for foreground/headless sources (capped at DEFAULT_MAX_
RETRIES=10 so a stuck gateway still terminates the turn). Default
stays 3 for interactive REPL use; background sources keep bailing
immediately (anti-amplification rationale unchanged).

Tests: default 3-strike fail preserved; budget=10 rides out 5 strikes;
budget clamped to 10. Full suite 1849 pass / 0 fail.

Co-Authored-By: Claude Code <[email protected]>
@dahai80
dahai80 force-pushed the fix-529-retry-budget branch from 84f54cf to 431fe1c Compare November 26, 2026 11:07
@dahai80

dahai80 commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main after #350 (which shipped the first iteration of this fix in v0.8.32). Conflict resolved in favor of this branch's semantics: budget capped at DEFAULT_MAX_RETRIES=10 so a stuck gateway still terminates the turn, values below 1 fall back to the default, helper exported for unit tests. Added a cap/fallback adjustment to the withRetry.test.ts expectations; both test files pass (8 cases), typecheck + lint + 1309-test suite green.

@dahai80
dahai80 merged commit 2dc4623 into main Nov 26, 2026
1 check passed
@dahai80
dahai80 deleted the fix-529-retry-budget branch November 26, 2026 11:08
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.

Headless runs give up on 529 after 3 retries while claude code retries ~10 — workers die in transient capacity cascades

1 participant