fix(providers): surface OpenCode Zen short-window rate limits - #1330
Conversation
Document the observed ~15-20 RPM burst ceiling on opencode-zen (and cross-link it on opencode-free), and enrich opaque Zen 429s with guidance plus a parseable Retry-After so Codex clients can back off.
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughOpenCode Zen and OpenCode Free now document shared endpoints, quotas, and 429 behavior. Zen 429 responses receive provider-specific guidance and synthetic retry timing when upstream retry headers are absent. The response pipeline passes authentication and transport metadata to this logic. ChangesOpenCode Zen rate-limit handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant OpenCodeZen
participant handleResponses
participant enrichOpenCodeZenRateLimitMessage
participant RetryCalculator
OpenCodeZen-->>handleResponses: Return upstream 429 response
handleResponses->>enrichOpenCodeZenRateLimitMessage: Pass provider, auth, transport, and Retry-After metadata
enrichOpenCodeZenRateLimitMessage-->>handleResponses: Return enriched message and retry guidance
handleResponses->>RetryCalculator: Calculate client retry delay
RetryCalculator-->>handleResponses: Return retry timing
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Tracking: Fixes #1145 (OCX-56). Auto-close keyword is in the PR body; Development sidebar may lag on fork heads. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs-site/src/content/docs/guides/providers.md`:
- Around line 279-287: Clarify the OpenCode Zen rate-limit documentation and
registry notes to say Zen may return generic 429 responses without rate-limit
headers, rather than never returning them; document that opencodex adds the
synthetic 15-second Retry-After only when upstream omits Retry-After, while
preserving upstream-header precedence. Apply the equivalent “headers can be
absent” wording in docs-site/src/content/docs/guides/providers.md (279-287),
src/providers/registry.ts (2040 and 2060),
docs-site/src/content/docs/ja/guides/providers.md (206-207),
docs-site/src/content/docs/ko/guides/providers.md (206-207),
docs-site/src/content/docs/ru/guides/providers.md (217-223), and
docs-site/src/content/docs/zh-cn/guides/providers.md (194-195).
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 10a5f899-5a8c-4b65-9f82-d0c785aa0bba
📒 Files selected for processing (9)
docs-site/src/content/docs/guides/providers.mddocs-site/src/content/docs/ja/guides/providers.mddocs-site/src/content/docs/ko/guides/providers.mddocs-site/src/content/docs/ru/guides/providers.mddocs-site/src/content/docs/zh-cn/guides/providers.mdsrc/providers/opencode-zen-rate-limit.tssrc/providers/registry.tssrc/server/responses/core.tstests/opencode-zen-rate-limit.test.ts
CodeRabbit: Zen may omit Retry-After / X-RateLimit headers on generic 429s; synthetic backoff is only added when upstream omits Retry-After.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/providers/opencode-zen-rate-limit.ts (1)
63-65: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftDo not add the 15-second hint when upstream
Retry-Afterexists.The guard checks only the message text. If the upstream response contains
Retry-After: 120but the body has noTry again in Ntext, this function still appendsTry again in 15s.The response pipeline may preserve the upstream header, but the client error then contains conflicting retry guidance and can cause premature retries.Pass the resolved upstream retry value into this function, or perform enrichment only after checking the upstream header. Add a regression test that verifies an upstream value does not produce the synthetic 15-second hint.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/opencode-zen-rate-limit.ts` around lines 63 - 65, Update the retry-hint enrichment logic in the rate-limit handling function to skip the synthetic 15-second message whenever a resolved upstream Retry-After value exists, regardless of message text. Pass that value into the function or move enrichment after the header check, and add a regression test confirming upstream retry values do not append the synthetic hint.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/providers/opencode-zen-rate-limit.ts`:
- Line 71: Update the rate-limit guidance helper in opencode-zen-rate-limit.ts
to accept authentication and transport context, and append the retryOn429
message only for key-authenticated HTTP routes. Exclude keyless opencode-free
routes and custom runTurn transports while preserving the existing guidance for
supported paths.
---
Outside diff comments:
In `@src/providers/opencode-zen-rate-limit.ts`:
- Around line 63-65: Update the retry-hint enrichment logic in the rate-limit
handling function to skip the synthetic 15-second message whenever a resolved
upstream Retry-After value exists, regardless of message text. Pass that value
into the function or move enrichment after the header check, and add a
regression test confirming upstream retry values do not append the synthetic
hint.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d96ad8fc-2e54-4fc5-8146-5215b58c84d5
📒 Files selected for processing (8)
docs-site/src/content/docs/guides/providers.mddocs-site/src/content/docs/ja/guides/providers.mddocs-site/src/content/docs/ko/guides/providers.mddocs-site/src/content/docs/ru/guides/providers.mddocs-site/src/content/docs/zh-cn/guides/providers.mdsrc/providers/opencode-zen-rate-limit.tssrc/providers/registry.tstests/opencode-zen-rate-limit.test.ts
Skip the synthetic 15s message when Zen already sent Retry-After, and only suggest retryOn429 on key-authenticated HTTP routes.
Summary
opencode-zenprovider note (and cross-link it fromopencode-free), since OpenCode does not publish RPM or rate-limit headers.Try again in 15shint soRetry-Afteris useful for Codex-shaped clients.Validation
bun test tests/opencode-zen-rate-limit.test.ts tests/opencode-free-provider.test.ts tests/retry-after-429.test.ts— passbun run typecheck— passupstream/dev→HEAD) — decisionreadyafter lens/surface evidenceReview notes
Retry-After: 15only applies when Zen omits a header and the body looks like a generic rate-limit 429; a real upstreamRetry-Afterstill wins.X-RateLimit-*remaining counts (would be dishonest without a probe).Limitations
Fixes #1145
Summary by CodeRabbit
New Features
retryOn429.Documentation