GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): forward retryAfterMs across provider session errors by rekram1-node · Pull Request #57589 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 21, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Problem

SessionError.Error defines retryAfterMs?: NonNegativeInt, and @opencode/ai already parses retryAfterMs on RateLimitError, QuotaExceededError, and ProviderInternalError. However, toSessionError only copied retryAfterMs inside the FreeUsageLimitError branch, dropping it on provider.rate-limit, provider.quota, and provider.internal errors and re-checking Number.isFinite / >= 0 / Math.ceil downstream instead of typing retryAfterMs as NonNegativeInt at the schema and parser boundary.

Change

  1. Type retryAfterMs as NonNegativeInt on HttpRateLimitDetails, RateLimitError, QuotaExceededError, and ProviderInternalError, and round up in RequestExecutor.retryAfterMs at the HTTP header parsing boundary.
  2. Forward retryAfterMs directly in providerError() so every provider error reason that carries retryAfterMs populates SessionError.Error.retryAfterMs.
 RequestExecutor.httpFailure
-  retryAfterMs(headers) -> number (may be float)
+  retryAfterMs(headers) -> NonNegativeInt (Math.ceil at header parse boundary)
   classifyProviderFailure
     RateLimitError | QuotaExceededError | ProviderInternalError
       toSessionError
-        QuotaExceeded (FreeUsageLimitError only) -> SessionError.retryAfterMs (re-validated + Math.ceil)
-        RateLimit / QuotaExceeded / ProviderInternal -> dropped retryAfterMs
+        providerError -> forwards reason.retryAfterMs on all provider errors

Added by the opencode bot (AI-generated).

Related: #33955

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): forward retryAfterMs across provider session errors
77edd55
opencode-agent[bot]
opencode-agent Bot reviewed Oct 21, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forwarding works. I ran RequestExecutor.httpFailure → toSessionError on both checkouts. On the base, retryAfterMs is dropped for rate-limit errors. With this PR, retry-after: 45 gives 45000 and retry-after-ms: 1500.5 gives 1501. core's session-error.test.ts and the full ai suite pass, and typecheck is clean in both packages.

One regression to fix before merging: the stricter schema type means a very large Retry-After value now throws inside httpFailure instead of producing a provider error (see inline).

Public API: SessionError.retryAfterMs was already NonNegativeInt, so the server, SDK and OpenAPI shapes don't change. Session errors now include retryAfterMs for provider.rate-limit, provider.quota and provider.internal too, which is additive. In @opencode/ai, retryAfterMs on RateLimitError, QuotaExceededError, ProviderInternalError and HttpRateLimitDetails narrows from any number to a non-negative safe integer. That is enforced when the error is built, so any caller passing a fraction or an unsafe integer will now get an exception.

Related: #33955

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/ai/src/route/executor.ts Outdated

const seconds = Number(value)
if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000)
if (Number.isFinite(seconds)) return Math.max(0, Math.ceil(seconds * 1000))

@opencode-agent opencode-agent Bot Oct 21, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NonNegativeInt is built on Schema.Int, which only accepts safe integers, and these error classes check their fields when constructed. So a large header value now makes httpFailure throw instead of returning a provider error. For example, retry-after: 1e13 (1e16 ms, above 2**53) or a huge retry-after-ms value causes new RateLimitError(...) to throw Schema validation failed. On the base this was a normal provider.rate-limit error. Could retryAfterMs cap the result here, e.g. Math.min(Number.MAX_SAFE_INTEGER, …) or a sane upper bound, so a buggy or hostile gateway header can't turn a 429 into an exception?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(ai): clamp retryAfterMs to MAX_SAFE_INTEGER
3cb0421
@rekram1-node
rekram1-node merged commit 80b8762 into dev Oct 21, 2026
17 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node
rekram1-node deleted the session-error-retry-after branch October 21, 2026 01:57
@kobzevvv kobzevvv mentioned this pull request Oct 21, 2026
chore(upstream): порт v2.1.2 — 20 в порт, 26 на решение gpt-mem/opencode-mem#189
Open
12 tasks
vleonbonnet added a commit to vleonbonnet/opencode that referenced this pull request Oct 21, 2026
@vleonbonnet
Merge upstream dev (v2.1.2 and 9 commits after it) into main
5cb8fb7
- Tool output: upstream's new `save` (bytes a tool cannot attach inline) sits beside the fork's `truncateError`. The fork's private text saver is now `saveText`: its error path must catch a failed save, which upstream's `save` turns into a defect.
- Model requests: the `model.request` hook still sees `dryRun`; `baseURL` is passed as is, since upstream typed it as a string.
- Tests: the skill-instructions expectation for a changed description is upstream's new delta text, with the fork's list-of-rulesets `load`; the MCP test keeps both sides' imports.
- The OpenAPI documents (protocol and www) are regenerated: upstream's commit for `retryAfterMs` on session errors (anomalyco#57589) left them without it.
@kobzevvv kobzevvv mentioned this pull request Oct 22, 2026
chore(upstream): порт v2.1.3 — 33 в порт, 122 на решение gpt-mem/opencode-mem#207
Open
5 tasks
@ivopogace ivopogace mentioned this pull request Oct 22, 2026
Show when a rate- or quota-limited child can resume (retryAfterMs) ivopogace/opencode-courier#353
Closed
@ivanfenenko ivanfenenko mentioned this pull request Oct 25, 2026
Session failures: retry-after countdown and usage-limit error types opencode-mobile/opencode-mobile#832
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.