fix: cap long SDK retry-after waits#68474
Conversation
Greptile SummaryInjects Confidence Score: 5/5Safe to merge — only finding is a P2 model constant naming preference in the test fixture. The core logic is correct: 429 detection, numeric parse with NaN guard, threshold comparison, header injection, and response body stream transfer all work as intended. Four new tests cover the meaningful branches. The single comment is a P2 style preference (test model constant No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/provider-transport-fetch.test.ts
Line: 99-103
Comment:
**Prefer `sonnet-4.6` for Anthropic test model constants**
Per the repo testing guidelines, new tests should use `sonnet-4.6` (not `claude-opus-4-7`) as the canonical Anthropic model fixture. The model ID has no effect on the 429 logic being tested, so the swap is mechanical.
```suggestion
const anthropicModel = {
id: "sonnet-4.6",
provider: "anthropic",
api: "anthropic-messages",
baseUrl: "https://api.anthropic.com/v1",
} as unknown as Model<"anthropic-messages">;
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: skip SDK retry on 429 with retry-af..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99561b5bd7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
99561b5 to
f865ae5
Compare
f3b1673 to
a48822e
Compare
a48822e to
0d1afa7
Compare
0d1afa7 to
f5db146
Compare
f5db146 to
14e1550
Compare
|
Landed via rebase as b09aed8.\n\nValidation:\n- Verified OpenAI/Anthropic Stainless SDK retry behavior: both honor |
Summary
408,409,429, or5xx) includesretry-after-msorretry-afterabove 60 seconds, OpenClaw injectsx-should-retry: falseinto the response so Anthropic/OpenAI SDKs surface the error immediately.OPENCLAW_SDK_RETRY_MAX_WAIT_SECONDSto tune the cap; set it to0,false,off,none, ordisabledto leave long SDK sleeps intact.Why
Anthropic and OpenAI's Stainless-based TypeScript SDKs check
x-should-retrybefore their built-in retry status handling, and parseretry-after-ms/retry-afterinto retry sleep durations. Without this cap, a long provider retry window can make an interactive OpenClaw run silently wait inside the SDK instead of returning control to OpenClaw's auth/profile/model failover layer.Refs: cline/cline#10139
Test plan
x-should-retry, retryable statuses, andretry-after-ms/retry-afterparsing.pnpm test src/agents/provider-transport-fetch.test.tspnpm check:changedpnpm checkpnpm testran full suite; one unrelatedsrc/infra/gateway-lock.test.tsstale-lock timing case failed once, then passed on targeted rerun.pnpm test src/infra/gateway-lock.test.ts