Skip to content

fix(0.12.1): retry 429 / 5xx in OpenAI-compatible backend#19

Merged
tangletools merged 1 commit into
mainfrom
feat/backend-429-retry
May 20, 2026
Merged

fix(0.12.1): retry 429 / 5xx in OpenAI-compatible backend#19
tangletools merged 1 commit into
mainfrom
feat/backend-429-retry

Conversation

@tangletools
Copy link
Copy Markdown
Contributor

Summary

When tcloud router returned 429 mid-canonical-eval (legal-agent persona 3 of 36), the runtime stream threw `BackendTransportError` and the eval caught it but reported `chars=0` with `composite=0%` — looking like an agent-quality problem instead of a transient rate-limit cascade.

Adds `BackendRetryPolicy` to `createOpenAICompatibleBackend`:

  • 5 attempts default with exponential backoff (1s → 30s, ±25% jitter)
  • Retries 408 / 425 / 429 / 500 / 502 / 503 / 504
  • Hard failures (401, 403, 404) propagate immediately
  • Honors AbortSignal so callers can still cancel mid-retry
  • Drains failed response bodies to free connections
  • Set `retry: { maxAttempts: 1 }` to opt out

Test plan

  • `pnpm typecheck` clean
  • `pnpm test` — 144 tests pass
  • Re-run legal-agent canonical eval against 0.12.1 — expect retries on 429 instead of `chars=0` cascade

…ckend

When tcloud router returned 429 mid-canonical-eval (legal-agent persona 3
of 36), the runtime stream threw BackendTransportError and the eval
caught it but reported chars=0 with composite=0% — looking like an agent
quality problem instead of a transient rate-limit cascade.

Add `BackendRetryPolicy` to `createOpenAICompatibleBackend`:
- 5 attempts default with exponential backoff (1s → 30s, ±25% jitter)
- Retries 408 / 425 / 429 / 500 / 502 / 503 / 504
- Hard failures (401, 403, 404) propagate immediately
- Honors AbortSignal so callers can still cancel mid-retry
- Drains failed response bodies to free connections
- Set `retry: { maxAttempts: 1 }` to opt out

Closes the failure mode where legal-agent passed personas 1-2 with
real 4-6K-char responses, then every subsequent persona reported
chars=0 because the retry policy was missing.
@tangletools tangletools merged commit f05c7a0 into main May 20, 2026
1 check passed
@tangletools tangletools deleted the feat/backend-429-retry branch May 20, 2026 13:25
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.

2 participants