fix(agent-core-v2): align rate-limit retries with v1#1598
Conversation
🦋 Changeset detectedLatest commit: 122e923 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 122e923adb
ℹ️ 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".
| if (error instanceof APIStatusError) { | ||
| return [408, 409, 429, 500, 502, 503, 504, 529].includes(error.statusCode); | ||
| } | ||
| return error instanceof ChatProviderError; |
There was a problem hiding this comment.
Exclude deterministic provider validation errors from retry
When the Anthropic adapter rejects a malformed/unsupported data-URL image before sending any request, it throws a base ChatProviderError from imageUrlPartToAnthropic; this new catch-all now marks that deterministic validation failure as retryable, so stepRetry sleeps and re-enqueues the same step until maxRetriesPerStep instead of surfacing the bad input immediately. This is especially noticeable with higher retry configs and also emits misleading retry events; add the same kind of narrow exclusion for known deterministic ChatProviderErrors rather than retrying every base provider error.
Useful? React with 👍 / 👎.
Related Issue
No linked issue. This is a focused fix for reproducible rate-limit handling drift between agent-core-v2 and the legacy engine.
Problem
agent-core-v2 retained the retry policy that predated the v1 fault-tolerance hardening: it used a shorter backoff, discarded provider
Retry-Aftermetadata, and classified fewer transient provider failures as retryable. A rate-limited child retry also emittedsubagent.spawnedagain, while the web projector allowed the child error frame to reach the main session. Together, a recoverable child-agent 429 could appear in the UI as a session error and produce duplicate lifecycle events.What changed
Retry-Afterthrough the OpenAI and Anthropic provider boundaries and classify embedded OpenAI Responsesstatus_code=429failures.subagent.spawnedwhen a child turn is retried.Validation
pnpm --filter @moonshot-ai/agent-core-v2 exec vitest run test/agent/stepRetry/stepRetry.test.ts test/app/llmProtocol/errors.test.ts test/app/llmProtocol/providers/provider-errors.test.ts test/session/swarm/sessionSwarm.test.ts --maxWorkers=4— 135 tests passed.pnpm --filter @moonshot-ai/kimi-web exec vitest run test/agent-event-projector.test.ts— 18 tests passed.pnpm --filter @moonshot-ai/agent-core-v2 typecheckpnpm --filter @moonshot-ai/kimi-web typecheckpnpm --filter @moonshot-ai/agent-core-v2 lint:domaingit diff --checkChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update. No user documentation update is needed for this recovery-path bug fix.