Repository navigation
refactor: reuse web search request preparation - #148949
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 6:06 AM ET / 10:06 UTC (Revision 2). ClawSweeper reviewWhat this changesWeb search reuses its prepared request configuration during provider selection, avoiding redundant work without changing intended search behavior. Merge readiness✅ Ready for maintainer review Keep open as a useful, focused refactor: current main still repeats request preparation, and no actionable correctness defect was found. The earlier proof warning does not establish a blocker under the applicable maintainer exemption. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw's web search runtime receives queries, configuration, and cancellation signals from agent tools and CLI commands. It selects eligible plugin providers and returns search results or errors, allowing fallback only for automatic selection. flowchart TD
A[Agent tool or CLI query] --> B[Prepare request context]
C[Configuration and runtime metadata] --> B
B --> D[Select eligible providers]
D --> E[Execute selected provider]
E --> F{Automatic fallback allowed?}
F -->|Failure and eligible backup| E
E --> G[Search result or error]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -6. Total -6 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep request preparation local to each search and reuse its context while preserving existing provider selection, credential refresh, and execution boundaries. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: source confirms redundant preparation, and the body reports a bounded synthetic measurement rather than a user-facing failure. Is this the best way to solve the issue? Yes. Passing the existing request-local context removes repeated work without adding a cache, changing public APIs, or bypassing later provider checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 00a455554d9f. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* commit '1226eecf4ff909de172a6837422cfa64723fade8': (39 commits) test: align model auth and setup fixtures with current behavior (#149023) refactor: reuse web search request context (#148949) fix(ci): remove duplicate Copilot auth metadata (#149016) test(agents): align auth fixtures with runtime store reads (#149004) improve: reduce data fetched during reminder maintenance (#148996) fix(cron): skip availability checks when session pruning is idle (#148920) fix(auth): guard GitHub Copilot device flow authority (#148999) fix(agents): prevent early recovery aborts of foreground exec (#148959) fix(github-copilot): remove retired Raptor mini (#116505) improve(feishu): reduce preparation work for documents with tables (#148997) improve: reduce database work when recording participants (#148841) test: accept Bun error labels in plugin assertions (#148955) fix(models): clarify saved account health and catalog status (#148987) test(plugins): align Copilot auth-choice registry expectations (#148981) fix(channels): reject blank integer channel add options (#145534) fix(ui): preserve archive undo after chat navigation (#148831) feat: show cited source previews in macOS and iOS chat (#148906) fix: avoid redundant tab updates while chats stream (#148865) test(qa): run Discord through Crabline (#116446) perf(crabbox): prepare project runtimes during worker download (#148952) ...
* commit '84114b5a2711764e2ca333e327e808fd88316063': (40 commits) improve(sessions): reuse compiled transcript metadata queries (#148773) fix(ci): repair Copilot contracts and config failure diagnostics (#149001) test: align model auth and setup fixtures with current behavior (#149023) refactor: reuse web search request context (#148949) fix(ci): remove duplicate Copilot auth metadata (#149016) test(agents): align auth fixtures with runtime store reads (#149004) improve: reduce data fetched during reminder maintenance (#148996) fix(cron): skip availability checks when session pruning is idle (#148920) fix(auth): guard GitHub Copilot device flow authority (#148999) fix(agents): prevent early recovery aborts of foreground exec (#148959) fix(github-copilot): remove retired Raptor mini (#116505) improve(feishu): reduce preparation work for documents with tables (#148997) improve: reduce database work when recording participants (#148841) test: accept Bun error labels in plugin assertions (#148955) fix(models): clarify saved account health and catalog status (#148987) test(plugins): align Copilot auth-choice registry expectations (#148981) fix(channels): reject blank integer channel add options (#145534) fix(ui): preserve archive undo after chat navigation (#148831) feat: show cited source previews in macOS and iOS chat (#148906) fix: avoid redundant tab updates while chats stream (#148865) ...
* refactor(agents): centralize tool description exclusions * Merge main into refactor/tool-description-exclusions-20260915 * commit '84114b5a2711764e2ca333e327e808fd88316063': (40 commits) improve(sessions): reuse compiled transcript metadata queries (#148773) fix(ci): repair Copilot contracts and config failure diagnostics (#149001) test: align model auth and setup fixtures with current behavior (#149023) refactor: reuse web search request context (#148949) fix(ci): remove duplicate Copilot auth metadata (#149016) test(agents): align auth fixtures with runtime store reads (#149004) improve: reduce data fetched during reminder maintenance (#148996) fix(cron): skip availability checks when session pruning is idle (#148920) fix(auth): guard GitHub Copilot device flow authority (#148999) fix(agents): prevent early recovery aborts of foreground exec (#148959) fix(github-copilot): remove retired Raptor mini (#116505) improve(feishu): reduce preparation work for documents with tables (#148997) improve: reduce database work when recording participants (#148841) test: accept Bun error labels in plugin assertions (#148955) fix(models): clarify saved account health and catalog status (#148987) test(plugins): align Copilot auth-choice registry expectations (#148981) fix(channels): reject blank integer channel add options (#145534) fix(ui): preserve archive undo after chat navigation (#148831) feat: show cited source previews in macOS and iOS chat (#148906) fix: avoid redundant tab updates while chats stream (#148865) ... * refactor(agents): consolidate tool description exclusions * chore: merge main for tool summary validation * commit '926bb1e1d75c6b102bcbf93114c690312c23cf18': (1903 commits) refactor(matrix): reuse startup verification account key (#157310) perf(config): avoid repeated environment scans during publication (#156457) chore(i18n): refresh native locales (#157495) fix(update): show quiet step progress and date recorded outcomes (#153407) feat(gateway): preserve browser sign-in requirements before connecting (#157454) test(scripts): await CLI admission fixture lifetimes (#157424) fix(ci): preserve consumer selection across core type stripes (#157373) fix(wizard): preserve typed plugin enum values (#127577) (#138090) fix(qa): title mock Code Mode fixture calls refactor: simplify SQLite worker lifecycle and test fixtures (#157458) test: prebuild run-node signal fixture (#157478) refactor(exec): reuse approval policy rule keys (#157198) fix(ci): reuse prepared runtime for changed-target E2E shards (#157365) fix(config): apply Gateway writes without waiting for file events (#157372) fix: count recorded nested tool operations once (#157438) fix(telegram): stop leaking raw file:// markdown links in messages (#137810) refactor(claws): share resource capability changes (#154680) improve(channels): reduce redundant preparation for button messages (#157050) fix(build): package preparation fails on unrelated test types (#157318) refactor(claws): share bounded document reading (#157436) ... Co-authored-by: Vincent Koc <[email protected]>
…8966) * refactor(agents): centralize tool description exclusions * Merge main into refactor/tool-description-exclusions-20260915 * commit '4a994031abb1b54d51b76755a55ac8f6e918162d': (40 commits) improve(sessions): reuse compiled transcript metadata queries (openclaw#148773) fix(ci): repair Copilot contracts and config failure diagnostics (openclaw#149001) test: align model auth and setup fixtures with current behavior (openclaw#149023) refactor: reuse web search request context (openclaw#148949) fix(ci): remove duplicate Copilot auth metadata (openclaw#149016) test(agents): align auth fixtures with runtime store reads (openclaw#149004) improve: reduce data fetched during reminder maintenance (openclaw#148996) fix(cron): skip availability checks when session pruning is idle (openclaw#148920) fix(auth): guard GitHub Copilot device flow authority (openclaw#148999) fix(agents): prevent early recovery aborts of foreground exec (openclaw#148959) fix(github-copilot): remove retired Raptor mini (openclaw#116505) improve(feishu): reduce preparation work for documents with tables (openclaw#148997) improve: reduce database work when recording participants (openclaw#148841) test: accept Bun error labels in plugin assertions (openclaw#148955) fix(models): clarify saved account health and catalog status (openclaw#148987) test(plugins): align Copilot auth-choice registry expectations (openclaw#148981) fix(channels): reject blank integer channel add options (openclaw#145534) fix(ui): preserve archive undo after chat navigation (openclaw#148831) feat: show cited source previews in macOS and iOS chat (openclaw#148906) fix: avoid redundant tab updates while chats stream (openclaw#148865) ... * refactor(agents): consolidate tool description exclusions * chore: merge main for tool summary validation * commit 'e0f58a77476acbe382bff5e55cd520e9d228d478': (1903 commits) refactor(matrix): reuse startup verification account key (openclaw#157310) perf(config): avoid repeated environment scans during publication (openclaw#156457) chore(i18n): refresh native locales (openclaw#157495) fix(update): show quiet step progress and date recorded outcomes (openclaw#153407) feat(gateway): preserve browser sign-in requirements before connecting (openclaw#157454) test(scripts): await CLI admission fixture lifetimes (openclaw#157424) fix(ci): preserve consumer selection across core type stripes (openclaw#157373) fix(wizard): preserve typed plugin enum values (openclaw#127577) (openclaw#138090) fix(qa): title mock Code Mode fixture calls refactor: simplify SQLite worker lifecycle and test fixtures (openclaw#157458) test: prebuild run-node signal fixture (openclaw#157478) refactor(exec): reuse approval policy rule keys (openclaw#157198) fix(ci): reuse prepared runtime for changed-target E2E shards (openclaw#157365) fix(config): apply Gateway writes without waiting for file events (openclaw#157372) fix: count recorded nested tool operations once (openclaw#157438) fix(telegram): stop leaking raw file:// markdown links in messages (openclaw#137810) refactor(claws): share resource capability changes (openclaw#154680) improve(channels): reduce redundant preparation for button messages (openclaw#157050) fix(build): package preparation fails on unrelated test types (openclaw#157318) refactor(claws): share bounded document reading (openclaw#157436) ... Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Web search resolves its request configuration twice before provider discovery, which can repeat complete config serialization for scoped requests.
User Impact
No user-visible behavior change is intended. Provider selection, configured-versus-automatic fallback, errors, cancellation, and returned results remain unchanged. There are no configuration, dependency, schema, or permission changes.
Why This Change Was Made
Pass the existing request-local context from
runWebSearchinto candidate preparation instead of resolving it again immediately. The change removes six net lines and preserves the later config reads, credential callbacks, and both explicit-selection checks. Context is prepared afresh for every request; nothing is cached across calls.The avoided work depends on the input. A scoped config that differs from the active source after provenance checking can avoid two full config serializations. Identity and other cheap paths already avoid that work. These counts come from source inspection. In the small synthetic scoped-mismatch case, the actual
runWebSearchentry point used 16.06–16.78% less median wall time in the two pair orders, saving 6.38–7.08 microseconds per call. Cheap-path results were mixed, and forcing the input config was slightly slower. No general or network-search speedup is claimed.Evidence
The maintained test runner executed all three requested files:
src/web-search/runtime.test.ts(33 cases),src/web-search/runtime-execution.test.ts(9), andsrc/agents/tools/web-search.signal.test.ts(8). All 50 passed with no skipped, missing, or unexpected files. The native process and descendants closed successfully.Codex review through P2 found no actionable defects in the complete changed owner and supplied caller context. Unchanged protected dependencies remained outside that review; the final reviewer found the supplied context sufficient for this narrow change. Earlier blocked or incomplete review attempts remain preserved in the local evidence.
Untimed before/after
runWebSearchproof passed 32 calls, including 16 config-case observations and eight control records covering callback reentry, fallback, structured errors, and cancellation. Complete decoded outputs matched; native children closed, candidate source was restored, and generated caches were retired.The frozen install passed without source or lockfile changes. Independent audit verified all 144 complete decoded timed-phase outputs (112 measured calls and 32 warmups), the retained preflight controls, exact source bindings, worker closure, and generated-cache retirement. No timed sample was rerun or discarded. Hosted exact-head CI remains required; local type-aware lint and broad type checks are not claimed. No live provider/network performance claim or broad release validation is included.
Paired request-preparation measurements and limitations
Darwin arm64, Node 26.8.2. Fixed B1 → C1 → C2 → B2 order, four small config cases per process, two warmups and seven measured calls per case. Each observation is one actual
runWebSearchcall using synthetic providers. Config publication, assertions, output serialization, and report writes are outside the wall/CPU timer.These small samples are descriptive, not statistical significance or throughput proof. Post-call worker RSS was 1.01–1.13% higher in every pair; it is sampled after assertions and serialization and does not measure per-call allocations. Whole-child peak RSS was also higher (kernel: +2.95% / +1.00%; sampled process tree: +2.54% / +1.01%), so no memory improvement is claimed. Whole-child measures include startup and proof overhead.
All cooperating local product, staging, and review jobs were paused for the timed family; no whole-machine-idle claim is made. One remote correctness command remained active; subsequent source-order and timestamp checks confirmed its final artifact export occurred after the timing window. The local archive was created more than 21 minutes after the window closed. The untimed preflight used the same corpus and inputs; a subsequent source-guard-only change batched reference inspection before the timed run, with the original guard and preflight retained.