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 — websearch: custom providers cannot signal rate limits — excluded from provider failover · Issue #58327 · anomalyco/opencode

websearch: custom providers cannot signal rate limits — excluded from provider failover #58327

New issue
Copy link
New issue
Copy link
Open
Open
websearch: custom providers cannot signal rate limits — excluded from provider failover#58327
Copy link

Description

@nazerim
nazerim
opened on Oct 23, 2026
Issue body actions

Summary

Built-in websearch providers participate in the HTTP-429 → Retry-After cooldown → switch-to-another-available-provider path, but custom providers registered via ctx.websearch.transform have no way to signal a rate limit: any execute() failure surfaces as ServiceUnavailableError and hard-fails the search. A pinned plugin provider therefore loses the failover story built-ins get for free.

Environment

  • opencode version: 2.1.2
  • OS: Darwin 25.6.0 (darwin arm64)
  • Terminal: ghostty (TERM=xterm-ghostty)
  • Shell: /bin/zsh
  • Install/channel: release (Homebrew tap, channel=latest)
  • Active plugins: custom websearch provider via ctx.websearch.transform (plus two unrelated plugins)

Reproduction

  1. Register a websearch provider whose execute() throws an error carrying .status = 429:
export default {
  id: "failtest",
  async setup(ctx) {
    await ctx.websearch.transform((editor) => {
      editor.add({
        id: "fail429",
        name: "Fail 429",
        execute: async () => {
          const e = new Error("forced 429");
          e.status = 429;
          throw e;
        },
      });
    });
  },
};
  1. Pin it in config: "websearch": { "provider": "fail429" } (with TAVILY_API_KEY present so a healthy built-in provider is available).
  2. Trigger a search: opencode api post /api/websearch -d '{"query":"anything"}'.

Observed response:

{"_tag":"ServiceUnavailableError","message":"Web search request failed: fail429","service":"fail429"}

No retry occurs on the available tavily provider. A plain throw new Error(...) behaves identically.

Expected Behavior

A documented error contract that a custom provider can use to signal rate limiting — e.g. a typed WebSearch.RateLimited { retryAfter? } error (or honoring status/retryAfter on thrown errors) — which the provider selector treats with the same cooldown + switch-provider behavior it applies to built-ins.

Actual Behavior

Plugin errors are opaque: wrapped as ServiceUnavailableError, request fails. The 429 handling ("Web search rate limited (HTTP 429)" status map + Retry-After cooldown) exists only inside the built-in providers' own HTTP call path; the WebSearch.* error taxonomy exposes ProviderRequired/ProviderNotFound but no rate-limited kind.

Additional Context

  • "random" selection also appears to consider built-ins only: with a custom provider registered and a key present, random picked a built-in 4/4 times — custom providers currently participate only via explicit pinning.
  • Current workaround we ship: the plugin itself catches Brave failures and queries the Tavily REST API as a fallback. It works, but every provider-plugin author would re-implement core failover/cooldown logic with no shared state.
  • Docs nicety: state which selection/failover semantics apply to plugin-registered providers.

Activity

  1. opencode-agent commented on Oct 23, 2026

    @opencode-agent
    opencode-agentBot
    on Oct 23, 2026 – with OpenCode Agent
    Contributor
    More actions

    Thanks for the detailed write-up and the minimal repro plugin!

    In short, you're asking for a documented way for a custom web search provider (registered via ctx.websearch.transform) to report a rate limit, so it gets the same cooldown and provider switching as the built-in providers.

    Here's how the current code (packages/core/src/websearch.ts) behaves:

    • Cooldown and switching only run when websearch.provider is "random", and only when the failure is an HTTP client error with status 429 (Retry-After sets the cooldown). With a pinned provider, built-in or custom, any failure ends the search. So pinning fail429 would not fail over even with a proper 429.
    • In "random" mode, the selector does include plugin-registered providers. A provider is reused for the session until it is rate limited, so a few built-in picks in a row is probably chance plus that stickiness, not exclusion.
    • The gap you found is real: an error thrown from a plugin's execute() is never recognised as a rate limit, and the plugin API has no rate-limited error type or retryAfter field. Because the cooldown state lives inside core, a plugin can't fully fix this on its own. Your in-plugin fallback is the best workaround for now.

    A possible addition to the plugin API would be an exported RateLimited error with an optional retryAfter, or having the promise adapter honour status: 429 / retryAfter on thrown errors, which the selector would then handle like a built-in 429. Documenting that failover only applies to "random" would also help. Maintainers will consider this.

    Related:

    • websearch: V2 keyless search is undocumented and "random" can stick to a failing provider #54311: "random" can stick to a failing provider, and fallback is documented for HTTP 429 only
    • fix(core): make web search limits non-fatal and report real errors #50938: open PR reworking web search errors and limits
  2. nazerim commented on Oct 23, 2026

    @nazerim
    nazerim
    on Oct 23, 2026
    Author
    More actions

    Thanks for the careful triage — two corrections to my report, on your read of the code:

    1. My repro overstates the failover story. I pinned fail429 and read the hard-fail as "custom providers are excluded from failover", but a pinned provider never fails over whether built-in or custom — the switching is random-mode only. The title/summary should be read accordingly.
    2. random does include plugin-registered providers. My "built-ins picked 4/4" observation was the session stickiness (first pick reused until a rate limit), not exclusion — the same confound websearch: V2 keyless search is undocumented and "random" can stick to a failing provider #54311 describes.

    What remains, and what you confirmed is real: in random mode, a built-in's 429 cools down and switches, while a 429 from a plugin provider's execute() is opaque — wrapped as ServiceUnavailableError, search ends — and there is no typed signal or retryAfter a plugin can surface. An exported RateLimited { retryAfter? } (or the promise adapter honoring status: 429 / retryAfter on thrown errors) is exactly the shape I'd hope for, and documenting failover as random-only would help — I misread the semantics precisely because it isn't documented.

    Question: is that contract in scope for #50938 (the web search errors/limits rework)? If so I'm happy to test that branch against the fail429 repro. Context: #58334 re-lands Brave as a built-in, which would solve our specific deployment, but the plugin gap stands for any out-of-tree provider.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — 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.