[codex] Fix explicit custom web_search provider routing#77736
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 5:00 PM ET / 21:00 UTC. Summary PR surface: Source +44, Tests +153, Docs +3. Total +200 across 7 files. Reproducibility: yes. at source level: current main does not forward the configured provider as Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this only after maintainers confirm explicit provider config should be authoritative and fail closed, or revise the branch to preserve compatibility until the fallback-chain contract is settled. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main does not forward the configured provider as Is this the best way to solve the issue? Technically yes for the explicit custom-provider routing bug: the change is in the agent wrapper and web-search runtime where the wrong precedence occurs. The remaining question is not a narrow code defect but whether maintainers accept fail-closed explicit routing as the compatibility contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 010b61746379. Label changesLabel justifications:
Evidence reviewedPR surface: Source +44, Tests +153, Docs +3. Total +200 across 7 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Addressed the review follow-ups in commit Summary:
Real behavior proof, deterministic local terminal capture using production modules only; no host config writes, no gateway restart, no doctor/fix, no secrets: Validation run: Preferred Testbox gate was attempted first, but this machine is not authenticated with Blacksmith: No merge performed. Re-review progress:
|
738d986 to
27035fa
Compare
|
Closing as stale (May/June, no recent activity). Re-open if still relevant. |
|
Re-opening per clarification — did not intend to close. Will address issues/rebase instead. |
27035fa to
77e2115
Compare
77e2115 to
740459d
Compare
Summary
Fixes
web_searchrouting whentools.web.search.providerexplicitly names a custom or installed web-search provider.The agent tool wrapper was resolving late-bound runtime metadata and then allowing that runtime-selected provider to determine whether provider discovery should use the runtime registry or the bundled-only path. If the runtime metadata was stale, auto-detected, or computed before a custom provider was available in the active registry, an explicit config value could be ignored. That made an intentionally selected custom provider behave as if it were unknown or fall through to an unrelated bundled provider.
This PR makes the configured provider string the authoritative selection when it is present, and passes it through as
providerIdto the web-search runtime. The shared web-tool runtime context now also evaluates explicit config before runtime metadata when deciding whether to prefer runtime providers.Why This Is Needed
tools.web.search.provideris a user-facing explicit routing setting. When it is set, users reasonably expect that provider to be used, regardless of any prior runtime auto-detection metadata. The previous behavior inverted that precedence in the agent execution path:runWebSearchwould either throw an unknown-provider error for the configured provider or execute a different provider from the bundled set.That is both surprising and risky. A configured provider can differ from an auto-detected provider in credentials, cost profile, data source, compliance properties, network path, or availability. Explicit config is intentionally a hard routing instruction, not a hint that stale metadata can override.
What Changed
createWebSearchToolnow reads the configuredtools.web.search.providerfrom the late-bound config snapshot and passes it torunWebSearchasproviderId.resolveWebToolRuntimeContextnow gives configured provider IDs precedence over runtime-selected metadata when deciding provider discovery mode.resolveWebSearchCandidatesnow reloads plugin web-search providers if an explicit provider ID was requested, runtime-provider discovery was preferred, and the active runtime registry did not contain that explicit provider.docs/tools/web.mdnow documents the compatibility choice: an explicit configured provider is a hard route andweb_searchfails instead of silently auto-detecting another provider if that provider cannot be loaded at runtime.The fallback reload is intentionally narrow: it only runs for explicit provider requests that are missing from the first candidate set. Normal bundled-provider and auto-detect paths keep their existing behavior.
Impact
Users with a configured bundled provider should see no behavior change other than stronger explicit-provider precedence. Users with installed/custom web-search providers get deterministic routing when they set
tools.web.search.provider.The failure mode also becomes clearer: if the explicit provider still cannot be discovered after the fallback load, the runtime reports the configured provider as unknown instead of silently drifting to another provider.
Real behavior proof
web_searchshould honor an explicittools.web.search.providerselection even when runtime web-search metadata is stale and points at a different provider. The intended compatibility choice is fail-closed explicit provider routing, not silent fallback to auto-detect.pnpm exec tsx; no gateway restart, no host config writes, and no real credentials.staleandcustomweb-search providers, configuredtools.web.search.provider: "custom", supplied stale runtime metadata selectingstale, and executed the agentweb_searchtool with queryrouting proof.custom, proving the explicit configured provider won over stale runtime metadata selectingstale.Validation
pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/tools/web.md src/agents/tools/web-search.ts src/agents/tools/web-tool-runtime-context.ts src/agents/tools/web-tools.enabled-defaults.test.ts src/web-search/runtime.ts src/web-search/runtime.test.tspnpm test src/agents/tools/web-search.test.ts src/agents/tools/web-tools.enabled-defaults.test.ts src/web-search/runtime.test.tspnpm changed:lanes --jsonselectedcore,coreTests, anddocs.OPENCLAW_LOCAL_CHECK=1 OPENCLAW_LOCAL_CHECK_MODE=throttled pnpm check:changedwas attempted because Testbox is not authenticated here; it completed conflict-marker, changelog attribution, dependency/patch guards, core typecheck, core test typecheck, core lint, runtime sidecar loader, and runtime import-cycle checks, then left an idle node process with no active child work and was stopped to avoid leaving it behind.pnpm check:docsTestbox was attempted first but is unavailable in this environment:
Known unrelated broad-check note:
pnpm plugin-sdk:api:checkcurrently reportsdocs/.generated/plugin-sdk-api-baseline.sha256hash drift even though this branch has no generated file changes and does not touch Plugin SDK exports.