Skip to content

perf(web-search): defer bundled provider runtime imports - #135073

Merged
steipete merged 1 commit into
mainfrom
codex/perf-web-search-selection
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-web-search-selection

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Managed web-search discovery loads every eligible bundled provider runtime before it knows whether any provider can serve the request. A fresh built process with no configured provider imports 15 runtime plugins just to return the existing unavailable-provider error.

Why This Change Was Made

Use the existing shared resolver's runtime-artifact hook to enumerate enabled bundled search descriptors from their light public artifacts. Each descriptor creates its tool through the canonical resolver scoped to that descriptor's owner. This preserves setup-only public factories, active-registry compatibility checks, plugin activation, and external-plugin fallback behavior. Search now shares the enabled-artifact selection owner already used by web fetch.

The provider-scope helpers are folded into their one caller, deleting repeated forwarding and selection branches. Production +78/-87 (net -9); tests +62/-1 (net +61). There are no new configuration options, caches, dependencies, or persistence changes.

User Impact

Bundled provider inventory and unavailable-provider paths avoid loading unrelated executable plugins. A selected provider still executes through its runtime registration. Explicit selection, auto-detection order, credentials and SecretRefs, provider fallback, cancellation, disabled plugin entries, and mixed external installations retain their existing contracts.

Evidence

  • A three-sample, fresh-process comparison used the same built bundle, restoring the previous eager resolver in the baseline process only. The unavailable-provider result was identical. Runtime imports fell from 15 to 0, median post-GC heap growth from 166,442,496 to 18,785,216 bytes, RSS growth from 675,217,408 to 19,398,656 bytes, and discovery time from 3,460.83 to 168.04 ms. These are cold discovery measurements, not whole-Gateway or model-latency guarantees.
  • A source probe enumerated providers without imports, then created a Brave tool and imported Brave alone. Explicit plugin disablement and the existing bundled global-enable compatibility behavior were preserved. Separate built entrypoint memory profiles completed for Brave and XAI.
  • All 86 tests in the runtime, shared resolver, public artifact, explicit-fast-path and fallback suites pass. The new lazy-loading regression failed against the old code. Existing cases cover active registries, credentials and SecretRefs, auto-detection, explicit and unknown selections, fallback, cancellation, alias ownership and external artifact resolution.
  • The rebuilt isolated Gateway used a real OpenAI API key and configured DuckDuckGo for managed search. A CodeMode turn executed web_search and web_fetch, returned the correct Node Buffer documentation answer, and recorded three tool calls with zero failures in 4.464 s.
  • Full build and the complete required changed-check plan passed, including core/test typechecks, lint, dead-export checks and runtime guards. Fresh Codex autoreview is scoped-clean at the required priority; manual owner and sibling review preserved the shared resolver's activation and registry checks.

Discover bundled search providers from enabled public descriptors and load only the selected runtime when creating its tool. Preserve activation and provider selection while removing duplicate scope forwarding.
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete
steipete marked this pull request as ready for review September 1, 2026 09:57
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 6:04 AM ET / 10:04 UTC.

ClawSweeper review

What this changes

This PR lists enabled bundled web-search provider descriptors from lightweight public artifacts and loads only the selected provider runtime when its search tool is created.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. This is a focused maintainer-authored performance refactor; current main still eagerly resolves bundled web-search runtimes, while the branch defers runtime loading through the existing plugin resolver without a supported correctness regression.

Priority: P2
Reviewed head: 6d20962911550b0eb47e94ee7df324045e043a34

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative production refactor with targeted lazy-loading coverage and no supported correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless reports an isolated Gateway run exercising web_search and web_fetch after the change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless reports an isolated Gateway run exercising web_search and web_fetch after the change.
Evidence reviewed 6 items Lazy runtime owner: The new runtime-artifact path returns public provider descriptors, then resolves the canonical plugin runtime scoped to the descriptor’s plugin only when createTool is called.
Shared resolver boundary: The shared resolver first reuses a compatible active registry, then invokes the runtime-artifact hook only when a registry load is needed; this preserves the established registry/activation owner boundary.
Caller and execution path: The web-search runtime scopes explicit selection through the manifest owner, and execution invokes the selected descriptor’s createTool before running it.
Findings None None.
Security None None.

How this fits together

Web-search requests choose configured or credential-detected provider descriptors before executing a tool. Plugin metadata supplies lightweight discovery information, while the selected provider’s runtime supplies the executable search tool.

flowchart LR
  A[Web search request] --> B[Provider selection]
  B --> C[Public provider descriptors]
  C --> D[Selected provider]
  D --> E[Scoped plugin runtime]
  E --> F[Search tool execution]
Loading

Before merge

  • Complete next step (P2) - No repair lane is warranted: there is no discrete actionable defect, and this protected maintainer PR should proceed through normal exact-head CI and maintainer handling.
Agent review details

Security

None.

PR surface

Source -9, Tests +61. Total +52 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 78 87 -9
Tests 1 62 1 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 140 88 +52

Review metrics

Metric Value Why it matters
Production versus test delta production +78/-87 (net -9); tests +62/-1 The performance boundary is added without net production growth, while focused coverage protects deferred loading and disabled-provider behavior.

Technical review

Best possible solution:

Keep the descriptor-to-scoped-runtime flow: it preserves manifest-first discovery and loads executable provider code only at the actual tool-creation boundary.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR optimizes plugin-runtime import fanout rather than repairing a separately reported user failure. The supplied source and focused test identify the changed resolution path.

Is this the best way to solve the issue?

Yes. Reusing the shared resolver’s runtime-artifact hook keeps discovery on the lightweight manifest/artifact path and retains canonical activation and runtime registration for the selected provider.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b6eee723bb1d.

Labels

Label changes:

  • add P2: This is a bounded improvement to web-search startup and unavailable-provider work, with no established urgent regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless reports an isolated Gateway run exercising web_search and web_fetch after the change.

Label justifications:

  • P2: This is a bounded improvement to web-search startup and unavailable-provider work, with no established urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is outside the external-contributor proof gate; its body nevertheless reports an isolated Gateway run exercising web_search and web_fetch after the change.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed the completed ClawSweeper result and its remaining maintainer-handling step. Retain the descriptor-to-scoped-runtime design: it preserves canonical activation and active-registry checks, removes eager unrelated imports, and is net-negative in production code. The 86 focused tests, complete changed checks, full build, and real API-key managed search/fetch turn pass. There are no actionable review findings to repair; landing will use the native workflow after exact-head CI is green.

@steipete
steipete merged commit f05fed0 into main Sep 1, 2026
342 of 343 checks passed
@steipete
steipete deleted the codex/perf-web-search-selection branch September 1, 2026 10:28
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…5073)

Discover bundled search providers from enabled public descriptors and load only the selected runtime when creating its tool. Preserve activation and provider selection while removing duplicate scope forwarding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant