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 — feat(websearch): let the model pick a provider per call by TOMUIV · Pull Request #64486 · anomalyco/opencode

Conversation

@TOMUIV

@TOMUIV TOMUIV commented Nov 17, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Issue for this PR

Closes #65252

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

websearch takes an optional providerID so the model can pick a provider for one call. The field already existed in the schema, the HTTP API and the plugin host; only the model-facing tool didn't declare it, so a name the model passed was silently dropped.

A pinned call uses that provider as-is: no failover, no rate-limit cooldown write, no change to the saved default. A provider the user saved still wins — a different id is refused — and a saved "disabled" still refuses, so an explicit id can't reopen search the user turned off. The accepted ids are published in the tool schema from the live provider registry, so plugin providers appear without a hardcoded list.

How did you verify your code works?

bun run --cwd packages/core typecheck is clean. bun test over tool-websearch, websearch, plugin/websearch, tool-model-policy, config/websearch, config/policy and plugin/provider-opencode: 157 pass. The schema cases cover "every id", "only the id the user saved", and ""random" keeps every id".

Known limitation: with full_codemode the tool can move into the Code Mode catalog, whose schema is cached from the registry, so the enum only reaches the model while the tool is direct. An unknown id still fails with the list of available ones.

Screenshots / recordings

No UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Public API: adds optional providerID to the model-facing websearch tool; POST /api/websearch with providerID now honours a disabled web search (otherwise backwards compatible)

Sorry, something went wrong.

Uh oh!

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

All reactions
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 17, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 17, 2026
View reviewed changes

@opencodejr opencodejr 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.

The feature works as described. Running OpenCode from source with the simulated model, the websearch tool now gets an optional providerID with an enum of the live provider IDs, and a model call that names exa goes through the usual consent form. On the base, a call with providerID isn't rejected as the description says: the field is quietly ignored. I couldn't run a real search through a pinned provider (no credentials). The websearch, tool-websearch and session-ui sources tests pass, and tsc -b in packages/core is clean.

Public API: the model-facing websearch tool gains an optional providerID input (backwards compatible). POST /api/websearch with providerID while web search is disabled now returns websearch_disabled (400) instead of searching, which is a behaviour change for HTTP callers. The SDK, client, schema and plugin API are unchanged.

Concerns:

  • Please rebase on dev. #64471 replaced the tool output with a plain array of results (the provider is kept only in metadata), which conflicts with the { provider, results } output and the new Provider: line here. #64475 made codemode follow the full_codemode flag instead of false. After rebasing, please check that the providerID enum, which is written by the session context hook, still reaches the model in Code Mode.
  • The model can override a provider the user explicitly chose (see inline). This needs a maintainer decision.
  • Tests: tool-websearch.test.ts gains about 680 lines for one optional field. Please cut it down to a few small cases: the enum appears, an unknown ID fails, disabled beats a pinned provider, and a pinned call doesn't change the saved preference.
  • Scope: about 330 lines of tool code is a lot for exposing one field. The name sanitising, enum size limits, re-mapping provider-not-found errors after the consent form, and the special 429 message could mostly go, which would make the change easier to review and maintain.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/tool/plugin/websearch.ts
yield* permission.assertNotDenied(approval)
return yield* new WebSearch.DisabledError()
}
needsConsent = saved.value === undefined

@opencodejr opencodejr Bot Nov 17, 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.

When the user has saved a specific provider ("Choose another provider" in the form, or a provider set in config), a pinned providerID still overrides it for that call. A user who picked a provider for cost, privacy or account reasons loses that control, and the model decides instead. Before this change, the tool always used the user's selection. Should a pinned provider only be honoured when the saved choice is random/unset, or should this be confirmed as the intended product behaviour first?

Sorry, something went wrong.

Uh oh!

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

All reactions

@TOMUIV TOMUIV Nov 17, 2026

Copy link
Copy Markdown
Author

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.

Taken — I adopted the conservative option.

With a specific saved provider, that choice wins: providerID must match it, and a different id is refused with Web search is pinned to "<saved>" by the user. Omit providerID or pass "<saved>". Only "random" (or no choice yet) lets the model pick. The refusal happens before the search and before any approval prompt, so it costs no provider call and leaves no saved permission.

WebSearch.selection() is now exposed on the service so the tool can read the saved choice without guessing from default() (which cannot tell "random" from a specific id). Test: saved exa + request parallel fails with the message and runs zero queries; saved random + request parallel still searches with parallel. Docs updated on websearch.mdx. See 6083d36.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/tool/plugin/websearch.ts Outdated
.join("\n\n")
: NO_RESULTS
const content = [
`Provider: ${displayText(output.provider)}`,

@opencodejr opencodejr Bot Nov 17, 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.

#64471 just removed provider from the tool output (it is now an array of results, with the provider only in metadata). This extra Provider: line in the content also needs sources.ts to know to skip it. Please rebase and check that it fits the new output shape, or drop it: the provider is already recorded in metadata.

Sorry, something went wrong.

Uh oh!

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

All reactions

@TOMUIV TOMUIV Nov 17, 2026

Copy link
Copy Markdown
Author

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.

Done in the rebase — the Provider: line is gone entirely. content is now byte-identical to dev (flat result array, provider only in metadata), so sources.ts needs no special case.

Sorry, something went wrong.

Uh oh!

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

All reactions

@opencodejr opencodejr Bot Nov 17, 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.

Confirmed at 6083d36: the Provider: line is gone, the output and content follow #64471's flat result array with the provider only in metadata, and sources.ts is no longer touched. This thread is resolved. The only open point is the enum one from my latest review: when a specific provider is saved, the enum still lists every id.

Sorry, something went wrong.

Uh oh!

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

All reactions
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

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

@TOMUIV
TOMUIV force-pushed the feat/websearch-tool-provider-id branch from f4cc7b9 to 7f70a46 Compare November 17, 2026 18:24
@TOMUIV

TOMUIV commented Nov 17, 2026

Copy link
Copy Markdown
Author

Rebased onto dev (0e447fc) and cut the change down per the review. Thanks for the detailed pass.

Rebase

  • refactor(core): simplify websearch tool results #64471: output is now the flat result array and the provider stays in metadata. I dropped the Provider: content line entirely, so content is byte-identical to dev.
  • feat(core): enable websearch in full Code Mode #64475: codemode now follows full_codemode and I kept that. One consequence worth stating: when full_codemode is on, this tool is advertised from the Code Mode catalog, whose schema is rendered and cached from the registry, so the enum only applies on the direct-tool path. Unknown ids still fail with the full list, and the default (full_codemode off) keeps the enum.

Size

  • Tool code: ~330 → 65 lines. Removed the name sanitising, the enum size limits, the post-consent ProviderNotFound remapping (and the Effect.result/suspend structure it needed), the special 429 message, and the withProviderEnum helper (inlined into the hook).
  • Tests: ~680 → 102 lines, five cases: the enum appears in the model-visible schema, a pinned call doesn't change the saved choice, an unknown id fails before searching, consent still runs before the first pinned search, and disabled beats a pinned provider at the service layer.
  • Total now +186/−8 across 6 files.

On the override question

Happy to defer to you here. The intent was that providerID only routes this call: it never writes websearch:provider, never enters the 429 cooldown, and doesn't fail over. A saved disabled now also wins inside WebSearch.query, so an explicit id can't reopen search the user turned off, and the first use still goes through the consent form. So it can't move the user's preference, only pick among providers the user has already consented to.

If you'd rather user choice be absolute, I can either drop the request path or gate it behind a flag — say which you prefer and I'll adjust.

Also noted: on dev a providerID is silently dropped rather than rejected; the description now says that.

All reactions

Sorry, something went wrong.

Uh oh!

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

@TOMUIV
TOMUIV force-pushed the feat/websearch-tool-provider-id branch from 7f70a46 to 6083d36 Compare November 17, 2026 18:58
opencodejr[bot]
opencodejr Bot reviewed Nov 17, 2026
View reviewed changes

@opencodejr opencodejr 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.

Re-reviewed at 6083d36. All my earlier points are resolved: a provider the user saved (in the consent form or in config) now wins, and a different providerID is refused before the approval prompt, with policy deny rules still checked first. The PR is rebased onto #64471 and #64475, so the output follows the new array format, the Provider: line is gone, and sources.ts is no longer touched. The Code Mode limitation is documented, and the change and its tests are much smaller. The websearch tests (62 pass) and tsc -b in packages/core pass.

Public API: the model-facing websearch tool gains an optional providerID (backwards compatible). POST /api/websearch with providerID while web search is disabled now returns websearch_disabled instead of searching, which is a behaviour change for HTTP callers. WebSearch.Service.selection() is new but internal to core and not exposed to plugins. The SDK, client, schema and plugin API are unchanged.

One remaining point, not blocking: when a specific provider is saved, the enum still lists every provider (inline).

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/tool/plugin/websearch.ts Outdated
...properties,
providerID: {
type: "string",
enum: Array.from(new Set(providers.map((provider) => provider.id))).toSorted(),

@opencodejr opencodejr Bot Nov 17, 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.

When the user has saved a specific provider, the tool refuses every other id, but this enum still lists all providers. The model is invited to make calls that will always fail. Could the hook publish only the saved id in that case (or drop providerID from the schema), and keep the full list for random or no choice yet? It would only need the same websearch.selection() read the tool already does.

Sorry, something went wrong.

Uh oh!

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

All reactions
@TOMUIV
feat(websearch): let the model pick a provider per call
0fd89e5
`WebSearch.Input.providerID` already exists in the schema, the HTTP API and the
plugin host, but the model-facing tool only declares `query`, so a model that
names a provider has it silently dropped. Wire the field through.

- The input gains an optional `providerID`, and the session context hook rewrites
  it into a JSON-Schema enum built from the live provider registry, so providers
  registered by plugins appear automatically. Ids are de-duplicated and sorted,
  so the emitted schema is byte-identical while the set is unchanged.
- A pinned provider is used as-is for that one call: no failover, no cooldown
  write, and no change to the saved preference — only the user's answers to the
  consent form write `websearch:provider`.
- A provider the user saved outranks the request: with a specific saved choice,
  `providerID` must match it, so a search can never leave the provider the user
  chose. With `"random"` (or before consent) the model is free to pick.
- An unknown id fails with the available ids instead of falling back, and
  `WebSearch.query` now also honours a saved "disabled" for explicit-provider
  callers.
@TOMUIV
TOMUIV force-pushed the feat/websearch-tool-provider-id branch from 6083d36 to 0fd89e5 Compare November 20, 2026 15:43
@TOMUIV

TOMUIV commented Nov 20, 2026

Copy link
Copy Markdown
Author

Rebased onto dev (55c68275) and reworked the hook for #64515, which removed this plugin's tool-visibility hook.

What changed

  • The context hook now only publishes the enum. Tool visibility (disabled, or no providers left) belongs to modelTools through WebSearch.available(), so the old delete event.tools[name] branch is gone rather than duplicated.
  • The last review point is handled: when the user saved a provider, the enum lists only that id, so the model isn't invited to name one that would be refused. "random", or no choice yet, still lists every id.

Tests

  • tool-websearch.test.ts keeps the schema cases (all ids, saved id only, random keeps all) and drops "offers the tool to the model only while a provider remains", which is now tool-model-policy.test.ts's subject through WebSearch.available().
  • bun run --cwd packages/core typecheck is clean.
  • bun test over tool-websearch, websearch, plugin/websearch, tool-model-policy, config/websearch, config/policy and plugin/provider-opencode: 157 pass. The four config/reload skill cases fail on this machine because ~/.agents/skills exists here; they don't involve this change.
  • bun run lint:changed reports nothing. The repo-wide bun run check still trips script/check-greys.ts on services/site CSS that this PR doesn't touch.
  • CI is queued awaiting approval again.

Unchanged limitation: with full_codemode enabled the tool can move into the Code Mode catalog, whose schema is rendered and cached from the registry, so the enum reaches the model only while the tool is direct. An unknown id still fails with the list of available ones.

All reactions

Sorry, something went wrong.

Uh oh!

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

opencodejr[bot]
opencodejr Bot reviewed Nov 20, 2026
View reviewed changes

@opencodejr opencodejr 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.

Re-reviewed at 0fd89e5. All earlier points are addressed: a saved provider wins over the model's choice, the Provider: line is gone and the output follows #64471's array format, and the enum now advertises only the saved provider when there is one (all providers for random or no choice yet). The rebase onto #64515 is clean, and the hook now only writes the enum. The websearch tests (63 pass) and tsc -b in packages/core pass. The public API impact is unchanged from my last review.

One small, non-blocking edge case is noted inline: a saved provider that is no longer registered.

  • packages/core/src/tool/plugin/websearch.ts:251: selection() falls back to the stored KV value even when that provider is no longer registered (for example, its key was removed or a plugin unloaded). In that case the enum offers only an ID that execute will reject as unknown. You could use the saved ID only when it is in providers, and otherwise fall back to the full list. Non-blocking.

Sorry, something went wrong.

Uh oh!

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

All reactions
@TOMUIV TOMUIV mentioned this pull request Nov 20, 2026
[FEATURE]: let the model pick a web search provider for a single call #65252
Open
1 task done

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

Reviewers

@opencodejr opencodejr[bot] opencodejr[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.

[FEATURE]: let the model pick a web search provider for a single call

Uh oh!

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

1 participant

@TOMUIV
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 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.