Skip to content

fix(core): rotate web search providers on quota and plan-limit failures - #60177

Open
Caffa wants to merge 1 commit into
anomalyco:devfrom
Caffa:websearch-rotation
Open

Caffa wants to merge 1 commit into
anomalyco:devfrom
Caffa:websearch-rotation

Conversation

@Caffa

@Caffa Caffa commented Oct 29, 2026 •

Copy link
Copy Markdown

Closes #60176

Related to #54311 and #58327; this change addresses only the built-in rotation trigger, not the plugin-side typed errors.

What changed

  • packages/core/src/websearch.ts: under provider: "random", HTTP 402 (Payment Required) and 432 (plan limit exceeded) now trigger a cooldown and provider rotation, alongside the existing 429. Fixed/explicit providers never fail over.
  • packages/core/src/tool/plugin/websearch.ts: added 402 and 432 entries to the status→message map so the tool surface reports a useful message instead of Web search request failed (HTTP 432).
  • services/www/src/docs/content/websearch.mdx: wording updated, since it previously described failover as HTTP-429-only.
  • packages/core/test/websearch.test.ts: added cases asserting rotation on 402/432. Existing assertions that 401/500/timeout do not rotate are unchanged (rename only where the test name implied 429-only).

The 432 status is non-standard and was reported by the provider plan-limit response; I could not find an in-repo or in-docs precedent for it.

Verify

  • cd packages/core && bun run test test/websearch.test.ts → 35 pass, 0 fail
  • cd packages/core && bun run test test/tool-websearch.test.ts test/config/websearch.test.ts test/plugin/websearch.test.ts → 23 pass, 0 fail
  • cd packages/core && bun run typecheck:tsc → clean (no output = no errors)
  • bunx oxlint on the two changed source files → 0 warnings, 0 errors

bun check could not be run locally (bun 1.4.2 vs the 1.4.4 pinned); typecheck via tsc was green.


Added by the opencode bot (AI-generated).

Related: #54311, #58327

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The change looks good to me. In random mode, 402 and 432 now go through the same cooldown-and-switch path as 429, while fixed or explicitly requested providers still fail without switching. I checked this with the unit tests: the new 402/432 tests fail on the base and pass with this change. The existing tests (including that 401, 500 and timeouts don't switch providers) pass too, and tsc is clean. I didn't run it against a real provider.

Public API: unchanged. No config, plugin API or schema changes; the only user-visible changes are the two new tool error messages and the docs wording.

One non-blocking note: a provider whose plan is used up gets the same 60-second cooldown as a rate-limited one, unless it sends Retry-After. After that, new sessions will try it again and spend one failed request before switching. That seems acceptable for this narrow fix; a longer cooldown could be a follow-up if it turns out to be noisy.

Related: #54311, #58327

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web search: rotate providers on quota and plan-limit failures, not only HTTP 429

1 participant