Repository navigation
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
There was a problem hiding this comment.
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.
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: underprovider: "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 ofWeb 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 failcd packages/core && bun run test test/tool-websearch.test.ts test/config/websearch.test.ts test/plugin/websearch.test.ts→ 23 pass, 0 failcd packages/core && bun run typecheck:tsc→ clean (no output = no errors)bunx oxlinton the two changed source files → 0 warnings, 0 errorsbun checkcould not be run locally (bun 1.4.2 vs the 1.4.4 pinned); typecheck viatscwas green.Added by the opencode bot (AI-generated).
Related: #54311, #58327