Skip to content

fix: hide web search when no provider is configured - #166199

Merged
roboclaw-bot merged 7 commits into
mainfrom
openclaw/gate-unconfigured-web-search
Oct 6, 2026
Merged

roboclaw-bot merged 7 commits into
mainfrom
openclaw/gate-unconfigured-web-search

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes agents repeatedly attempting web searches that cannot work because no search provider is configured.

User Impact

Unconfigured web_search is omitted from initial tools, Tool Search, and Code Mode. The agent instead receives a concise setup hint pointing to openclaw configure --section web or Settings → Ask OpenClaw.

Explicitly disabled or policy-denied search does not produce a misleading setup hint. Native hosted search and explicitly selected key-free providers retain their existing behavior. Configured-but-unavailable providers keep their actionable execution diagnostics; this is a configuration-presence check, not a network or credential health probe.

Why This Change Was Made

The shared tool assembly previously exposed search based on its enabled flag without checking provider setup. It now uses the search owner’s provider credential contracts and runtime metadata before catalog construction, and carries the resulting fact into initial and refreshed prompts. Existing execution-time credential/configuration late binding is unchanged.

Reported and requested by @jacobtomlinson.

Work sessions

Evidence

Landed candidate

Current head: 4a58efe88823aa3099e245f6a008548ae4a157b1, tree e27e87116d58350f236e14dc707939b41ef83836.

ClawSweeper revision 7 accepted the SDK correction below with no remaining actionable findings. The broader CI selection then exposed four model-provider collision assertions whose fixture did not configure managed search. These reproduced without ambient credentials. The fixture now supplies a synthetic managed-search credential with canonical scoped environment isolation, without forcing a provider or changing production behavior or assertions. All seven route cases pass (13.08s); the complete three-file CI selection passes 75/75 (20.69s). Consumer typecheck, lint/format and incremental P2 AutoReview pass. Final-head CI passed: 88 jobs terminal, zero failures. Required CI, dependency-review and security-sensitive-review statuses pass. ClawSweeper revision 8 reviewed this exact head with no actionable findings.

SDK correction

Prior head: 83d009c58140e4c29334a221bbb10393f2c0ad81, tree c75cbaa14813cf40979c8ad9e9eabdacc122783a.

The latest review found that the internal prompt callback leaked into both public SDK factory option types. Both public signatures now omit onWebSearchConfiguration; internal assembly retains it. The existing private-options regression covers both signatures. Canonical SDK typechecking failed at both assertions before the fix and passes afterward. SDK, search-assembly, and real prompt-callback suites pass 20/20 in 76.50s. The full changed-check plan for these two files passed in 577.8s, including production types, all 27 consumer test graphs, SDK boundaries, deadcode, lint and guards. Incremental staged AutoReview is scoped-clean through P2.

The prior head b49b3b88b1 completed CI successfully, with all 86 jobs terminal and no failures. This remains prior-head evidence; final-head CI and review are recorded above.

Prior runtime and CI repairs

Prior head: b49b3b88b1da68dc3181aad109e0c2bab77c6b2f, tree 5de768bf7ba9fbe3a97fbb899b03ad1aa9d206d3. The branch includes security-fixed main c39d9b0692 after the MCP prerequisite landed. Hosted ancestry and human credit are preserved.

The final CI repair does two distinct things:

  • Keeps callers’ already-prepared authentication-source facts during asynchronous tool construction. Undefined facts still trigger legitimate asynchronous discovery; source presence still requires a matching provider credential. Execution-time credential late binding is unchanged.
  • Places real database-consuming browser-delivery and skill-dispatch fixtures in the existing infra fork lane, with canonical provider-environment isolation. No production guard, assertion, timeout or retry was weakened, and no new test pool was introduced.

Verification

  • Both exact CI failures reproduced without ambient search credentials: browser delivery 1 failed / 12 passed, skill dispatch 3 failed / 7 passed. Adding environment isolation alone did not hide the failures; the production/prepared-fact and routing repairs were then applied.
  • Broader same-production-repair selection: 70/70 tests across eight files, 145.05s, covering configuration, assembly, late binding, media authentication, both failing fixtures, and MCP questions.
  • After strengthening the prepared-source matrix, final ordinary-wrapper verification: 34/34 across three files, no pool/worker override. Parent independently repeated it in 23.05s. This includes 23/23 formerly failing fixture cases and 11/11 assembly cases covering prepared false, true/unrelated, true/matching, and undefined discovery.
  • Affected agents-root and services consumer typechecks, focused lint/format, mock-export and SQLite-worker ratchets, and git diff --check passed.
  • Full final staged-candidate AutoReview against c39d9b0692: scoped-clean through P2, no findings.

Earlier scoped proof remains identified separately: security-baseline head 658e7ed4817c passed 93 tests across seven files in 149.78s, all seven canonical prompt snapshots, and the production npm bulk audit with no matching high-or-higher advisories. Dependencies and generated snapshot baselines were not changed by the final repair. Npm bulk results are not comprehensive vulnerability clearance.

Review history and limitations

The original retry-dispatch auth mock and happy-path search fixture findings are resolved. The MCP question-authority fixture also uses its existing database-worker pool; credential-free proof passed 12/12 without a pool override. Subsequent wider CI exposed the two additional real database consumers repaired above, rather than only cancellation collateral.

The previous auto-merge request was retired through native recovery before edits. Final-head CI and review are complete as recorded above. The native guarded workflow merged this head as eea001248e7fad3698293b36fa9f761904de59c1; landed tree 5277f0c8076d90d7de79445fd30b38bf5e08702d matches the verified composition with main. Live-provider execution was not exercised.

Omit unconfigured managed search from initial and deferred tool catalogs and provide truthful setup guidance without changing native search or configured-provider diagnostics.

Co-authored-by: jacobtomlinson <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L labels Oct 6, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 6, 2026 16:29
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 6:54 PM ET / 22:54 UTC (Revision 8).

ClawSweeper review

What this changes

The branch hides unconfigured managed web search from agent tool catalogs, provides setup guidance, and updates regression fixtures and test routing.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still advertises unconfigured managed search. The prior SDK blocker is resolved, and the latest fixture correction introduces no actionable finding.

Priority: P2
Reviewed head: 4a58efe88823aa3099e245f6a008548ae4a157b1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful regression coverage and resolved prior blockers; no new actionable defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: This bot-authored PR is exempt from ordinary contributor proof. Its assembly, routing, and prompt regressions are supplemental evidence; no live-provider result is claimed, and no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This bot-authored PR is exempt from ordinary contributor proof. Its assembly, routing, and prompt regressions are supplemental evidence; no live-provider result is claimed, and no stored-data contract changes.
Evidence reviewed 8 items Current-main necessity: Fetched main still constructs web_search without the branch's configuration-presence gate; the central improvement is not already implemented.
Latest release comparison: The v2026.9.8 source also constructs web_search without this configuration gate.
Configuration owner and compatibility: The presence check preserves explicit provider selection, prepared runtime selections, unresolved SecretRefs, and degraded-provider diagnostics. Assembly consumes the prepared result while retaining execution-time configuration and credential binding; no persisted format changes are introduced.
Findings None None.
Security None None.

How this fits together

OpenClaw assembles agent tools from provider configuration, credentials, model capabilities, and tool policy. The resulting catalog feeds initial tools, deferred discovery, Code Mode, and system-prompt guidance.

flowchart TD
  A[Search configuration and credentials] --> B[Configuration presence check]
  C[Model capabilities and tool policy] --> D[Agent tool assembly]
  B --> D
  D --> E[Initial and deferred tool catalogs]
  D --> F[Setup guidance in agent prompt]
  E --> G[Search execution with current credentials]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +184, Tests +456, Docs +9. Total +649 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 9 207 23 +184
Tests 12 461 5 +456
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 677 28 +649

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +184 lines; tests and test support net +456 lines Production growth implements provider-presence preparation and prompt propagation, with most growth devoted to regression coverage.

Technical review

Best possible solution:

Use the search owner's configuration facts consistently across catalogs and prompts while preserving configured-provider diagnostics and current credential binding.

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

Yes, source establishes the mechanism: current main constructs enabled managed search without checking provider setup. Repeated model attempts were not executed during this read-only review.

Is this the best way to solve the issue?

Yes, the branch places configuration detection in the search owner and carries one prepared fact into assembly and prompt guidance without changing execution health checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f215c401e69a.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This addresses avoidable failed search attempts with a bounded tool-availability improvement.
  • 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 bot-authored PR is exempt from ordinary contributor proof. Its assembly, routing, and prompt regressions are supplemental evidence; no live-provider result is claimed, and no stored-data contract changes.

Evidence

What I checked:

  • Current-main necessity: Fetched main still constructs web_search without the branch's configuration-presence gate; the central improvement is not already implemented. (src/agents/openclaw-tools.ts, f215c401e69a)
  • Latest release comparison: The v2026.9.8 source also constructs web_search without this configuration gate. (src/agents/openclaw-tools.ts:231, fc23bc864e45)
  • Configuration owner and compatibility: The presence check preserves explicit provider selection, prepared runtime selections, unresolved SecretRefs, and degraded-provider diagnostics. Assembly consumes the prepared result while retaining execution-time configuration and credential binding; no persisted format changes are introduced. (src/web-search/runtime.ts:424, 4a58efe88823)
  • Review continuity: Both public coding-tool factory signatures omit onWebSearchConfiguration, resolving the historical SDK finding. Comparing the previous reviewed head with the current head shows only the route fixture's environment isolation and synthetic managed-search credential. (src/agents/agent-tools.ts:668, 4a58efe88823)
  • Latest fixture correction: The latest change supplies BRAVE_API_KEY under canonical environment isolation without changing route assertions or production code. The captured discussion reports four failures before the correction, seven passing route cases afterward, and 75 passing tests in the broader selection; these are contributor-reported supplemental results, not reviewer execution. (src/agents/agent-tools.model-provider-collision.test.ts:17, 4a58efe88823)
  • Feature-history routing: Main history identifies steipete's authentication-source preparation work and holny's OAuth-aware search auto-detection repair. GitHub commit metadata verified both handles and relevant patches. Some deeper local blame and pickaxe reads failed because older blobs could not be retrieved; no feature-introduction claim relies on those failed reads. (src/web-search/runtime.ts, 90c4d9a6edeb)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-06T16:45:43.271Z sha 6aa88bc :: needs changes before merge. :: [P2] Complete the auth-source mock used by retry-dispatch tests | [P2] Align the happy-path snapshot fixture with search availability
  • reviewed 2026-10-06T17:19:04.936Z sha ed21e84 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T17:37:26.327Z sha ed21e84 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T21:05:31.458Z sha d2a7c66 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T21:28:14.243Z sha 658e7ed :: blocked before merge. :: [P1] [P1] Keep the prompt callback out of public SDK options
  • reviewed 2026-10-06T22:14:17.838Z sha b49b3b8 :: blocked before merge. :: [P1] [P1] Keep the prompt callback out of public SDK options
  • reviewed 2026-10-06T22:39:22.438Z sha 83d009c :: needs maintainer review before merge. :: none

Complete the retry-dispatch auth-source mock and explicitly select key-free search in the happy-path prompt catalog. Addresses both review findings without changing production behavior or generated snapshots.

Co-authored-by: jacobtomlinson <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Addressed both P2 findings in ed21e84: completed the synchronous auth-source mock and made the happy-path search provider explicit. No production behavior or snapshot baselines changed in this follow-up.

Validation: 81 focused tests passed (including 18 retry-dispatch and 17 snapshot tests), targeted lint/format passed, and the canonical clean-environment pnpm prompt:snapshots:check passed for all seven files (Testbox run). Fresh independent AutoReview is scoped-clean through P2. The PR body retains the remaining broad build/typecheck gaps.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 6, 2026
The web-search configuration probe reaches the host-owned shared-state broker when no provider key is present. Route the existing real HTTP fixture through the established fork-backed database-worker lane, preserving all assertions and production admission guards.

Co-authored-by: jacobtomlinson <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Landing checks found three actual HTTP500 failures inside cancelled job 112401215225. They were caused by this PR’s new configuration probe reaching the shared-state host broker from the fixture’s thread-backed pool; they are not attributed to the MCP advisory or merely to fail-fast cancellation.

Fixed in d2a7c66 by assigning the fixture to the existing database-worker pool. Credential-free ordinary-wrapper proof now passes all 12 cases without a pool override, in 66.58s. Lint/format/diff and independent P2 review pass. Product behavior and all assertions are unchanged. The body contains the exact reproduction, repair and remaining security prerequisite (#166217).

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Integrate main c39d9b0 to pick up the landed MCP security prerequisite. The PR remains the same 16-file web-search change relative to main. Refreshed focused tests, canonical prompt snapshots, production dependency audit, and independent P2 review pass.

Co-authored-by: jacobtomlinson <[email protected]>
@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) October 6, 2026 21:20
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Oct 6, 2026
@roboclaw-bot
roboclaw-bot disabled auto-merge October 6, 2026 21:31
Carry the existing auth-source fact through async search configuration preparation instead of rediscovering it. Route genuine database-consuming integration fixtures through the existing infra fork lane and isolate provider credentials for deterministic coverage.

Co-authored-by: jacobtomlinson <[email protected]>
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Repaired the remaining exact-head CI failures in b49b3b8. The browser-delivery and skill-dispatch fixtures now use the existing database-worker lane with canonical credential isolation. Async search preparation also preserves callers’ existing auth-source facts instead of rediscovering them; undefined-source discovery and execution-time late binding remain unchanged.

The failures reproduced first. Broader repair verification passed 70 tests; final ordinary-wrapper verification passed 34/34 (parent repeated in 23.05s), including the four prepared-source cases. Consumer typechecks, lint/format/ratchets and final staged P2 AutoReview pass. The PR body records exact scope and remaining CI gates. The old auto-merge request was retired natively before the repair.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Resolved the SDK contract finding in 83d009c: onWebSearchConfiguration is omitted from both public coding-tool factory signatures while remaining available internally. The existing private-options regression now covers both factories. Canonical SDK typechecking reproduced both failures before the fix and passes afterward.

20/20 SDK, assembly and actual callback tests pass (76.50s). The complete changed-check plan for the two changed files passes, including production types, 27 consumer test graphs, SDK boundaries, deadcode and guards (577.8s). Fresh scoped P2 AutoReview is clean. Prior b49 CI passed; final-head CI is running separately.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 6, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

ClawSweeper revision 7 cleared the SDK blocker. Wider CI selected the model-provider collision fixture and exposed four expectations relying on unconfigured managed search. Fixed in 4a58efe using canonical credential isolation and a synthetic managed-search key, without forcing provider selection, changing production behavior or weakening assertions. Red proof: 4 failed/3 passed; green: 7/7 in 13.08s and the full three-file CI group 75/75 in 20.69s. Typecheck, lint/format and incremental P2 AutoReview pass.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot
roboclaw-bot merged commit eea0012 into main Oct 6, 2026
158 of 160 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/gate-unconfigured-web-search branch October 6, 2026 23:03
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
* fix: hide web search when no provider is configured

Omit unconfigured managed search from initial and deferred tool catalogs and provide truthful setup guidance without changing native search or configured-provider diagnostics.

Co-authored-by: jacobtomlinson <[email protected]>

* test: configure web search fixtures for availability gating

Complete the retry-dispatch auth-source mock and explicitly select key-free search in the happy-path prompt catalog. Addresses both review findings without changing production behavior or generated snapshots.

Co-authored-by: jacobtomlinson <[email protected]>

* test: run MCP question authority with database workers

The web-search configuration probe reaches the host-owned shared-state broker when no provider key is present. Route the existing real HTTP fixture through the established fork-backed database-worker lane, preserving all assertions and production admission guards.

Co-authored-by: jacobtomlinson <[email protected]>

* fix: preserve prepared web search authentication sources

Carry the existing auth-source fact through async search configuration preparation instead of rediscovering it. Route genuine database-consuming integration fixtures through the existing infra fork lane and isolate provider credentials for deterministic coverage.

Co-authored-by: jacobtomlinson <[email protected]>

* fix(plugin-sdk): keep search prompt callback internal

Co-authored-by: jacobtomlinson <[email protected]>

* test(agents): configure managed search in route fixture

Co-authored-by: jacobtomlinson <[email protected]>

---------

Co-authored-by: jacobtomlinson <[email protected]>
steipete added a commit that referenced this pull request Oct 7, 2026
…66365)

## What Problem This Solves

`chat.send` could wait behind unrelated transcript-history reads while authorizing a request, admitting its run, or preparing durable input. An ordered metadata read could hold the database writer FIFO while waiting on the single history worker.

## User Impact

Hot-session input can be persisted and acknowledged while history dispatch is blocked. Exact session rows, target discovery, transcript identity selection, and bounded cold-archive metadata use the existing projection worker. Writer FIFO ordering, current permissions, source replacement checks, and durable input custody remain intact. There are no schema, configuration, retention, or update changes.

## Why This Change Was Made

Metadata discovery and payload reads selected different workers. Use the metadata worker consistently, remove the unused inventory lane parameter, and remove the discovery-only lane fallback. Transcript corpus/archive payloads and maintenance retain their existing owners.

Production LOC delta: **+14**. The generic reader also serves transcript payloads, so the metadata operations must select the existing projection lane explicitly; transcript target selection also retains its lazy worker/incognito boundary. Most added lines are argument/import formatting. No new pool, cache, wrapper, or configuration option is introduced.

## Evidence

Benchmarks and runtime tests ran with provider `blacksmith-testbox`, profile `openclaw-check`, on Linux x86_64 / Node 24.19.0. Paired measurements and the first full staged gate used lease **`tbx_01m499e9p8c3pwdkxrq7kqyt11`** on base `cc7e664dfe34`. The full staged gate also passed after rebase to `8f5c33c30d71` on the Linux rig fallback (`node scripts/check-changed.mjs --staged`, exit 0, approximately 50 minutes). Fresh-lease integration proof passed on **`tbx_01m49cshscnkd5rn7tva92rwrp`**: core production types and 63 tests covering exact reads, worktree-owner projection, managed owner policy, and durable ACK; total command 2m23s.

On **`tbx_01m49wfjav8vbwxmsdrw22nrad`**, base `0288eb1f3692`, core production types and 218 tests across 16 focused files passed in 6m51s. The three corrected race fixtures passed all 58 tests in 2m24s. Their staged gate and a full 227-case registry lifecycle replay passed in 6m14s. The final branch is rebased onto `98567acd6060`; SHA-256 verification confirms all 17 reviewed files are byte-for-byte unchanged. The earlier results are prior-base evidence; hosted CI checks the final integration. All four leases are stopped/expired.

The RPC router/handler and SQLite rig ran 64 sends at concurrency eight, alongside four continuous synthetic history readers and post-ACK preparation. Provider execution was mocked after ACK. Same baseline revision, synthetic data, and lease:

| Request latency | Before | After | Reduction |
|---|---:|---:|---:|
| p50 | 6,451 ms | 979 ms | 84.8% |
| p95 | 17,257 ms | 3,339 ms | 80.7% |
| p99 / max | 18,234 ms | 3,470 ms | 81.0% |
| mean | 7,548 ms | 1,273 ms | 83.1% |

Afterward, all 1,500 history-worker requests were background page reads; foreground metadata used the projection worker. Harness RSS after the run was 2.995 GB before and 3.193 GB after; these are whole test-process measurements, including worker heaps and retained synthetic turns.

A second paired run waited for warm startup, then measured 32 requests with one send outstanding and the same four background history readers:

| Warm request latency | Before | After |
|---|---:|---:|
| p50 | 2,250 ms | 188 ms |
| p95 | 3,036 ms | 323 ms |
| p99 / max | 16,280 ms | 2,246 ms |
| mean | 2,710 ms | 264 ms |

**Both workloads still exceed the 150 ms p50 / 500 ms p99 targets.** The warm median is below 300 ms. The remaining 2,245 ms warm tail records 2,094 ms in authority, 9 ms in admission, 77 ms in persistence, and 65 ms in run admission. Repeated authority preparation and production latency still need finer attribution; this change removes the proven history-queue dependency without relaxing authority or durability.

- The full router → durable transcript → ACK regression passes with history dispatch held. The original revision times out waiting for ACK under the same gate (the existing 120-second Vitest deadline), confirming the regression catches the old dependency.
- Broader owner/sibling coverage: 167 tests passed across 12 files. After the transcript-target and cold-metadata cutover, 71 relevant tests passed, including cold restore authority, physical replacement, first registration, run admission, and ACK-before-skill-preparation behavior.
- `pnpm test src/gateway/server-methods/chat-send-preparation-ack.test.ts --maxWorkers=1`: 5 passed; 38.85 s runner wall time including worker compilation; 10.93 s test time. The new case took 3.67 s. Real router authorization and SQLite custody are required to prove a durable ACK; helper-only tests would miss the persistence dependencies. Added Linux test execution cost: approximately 3.7 seconds per run, measured on Testbox; hosted per-case timing was not collected.
- `node scripts/check-changed.mjs --staged`: passed on the paired measurement base in 27m53s, including all 27 core test type graphs, lint, dead-export, cycle, and storage guards. Every reviewed file matched its recorded SHA-256.
- Independent Codex reviews of the production scope and final three test corrections: scoped-clean, no actionable P0/P1 findings.
- Three additional test fixtures now inject metadata races/errors through the projection worker: native model ownership, diff-baseline generation, and SDK transcript-target locking. All 58 tests in those files passed on the fresh lease in 2m24s; their assertions are unchanged. The scoped staged gate selected and passed the `agents-other`, `other`, and `plugin-sdk` type graphs, lint, and dead-export checks.

<details>
<summary>24-hour slow-send attribution</summary>

The journal query covered 2026-10-05 19:00:50Z through 2026-10-06 19:00:50Z and yielded 77 request and 99 startup records. These are **conditional slow-stage distributions**: the logger excludes stages below 1,000 ms. Timers include awaited/scheduling time and can overlap; they are not exclusive CPU measurements. Missing fields are absent samples. Nearest-rank p99 equals max for these sample counts.

| Stage / phase | Samples | p50 ms | p95 ms | p99 / max ms |
|---|---:|---:|---:|---:|
| Request total | 77 | 3,418 | 5,611 | 6,951 |
| Authority | 77 | 1,429 | 2,267 | 2,748 |
| Admission | 77 | 273 | 469 | 685 |
| Attachments | 77 | 0 | 11 | 285 |
| Persistence | 77 | 566 | 1,234 | 2,815 |
| Preparation | 77 | 0 | 1 | 8 |
| Reply context | 77 | 0 | 83 | 116 |
| Run admission | 77 | 1,135 | 2,314 | 2,402 |
| Effects | 77 | 0 | 0 | 0 |
| Response | 77 | 1 | 1 | 2 |
| Startup total | 99 | 5,674 | 102,321 | 3,288,574 |
| Startup ACK (repeated request duration) | 99 | 3,158 | 4,851 | 6,951 |
| Startup authoring | 95 | 1 | 6 | 9 |
| Startup preparation | 95 | 3,532 | 5,951 | 3,046,035 |
| Startup reply initialization | 95 | 1,612 | 80,753 | 356,488 |
| Startup reply context | 99 | 0 | 0 | 129 |
| Startup worktree | 13 | 3,575 | 5,131 | 5,131 |
| Startup dispatch | 99 | 15 | 544 | 8,757 |

The 54.8-minute startup record had already ACKed in 250 ms and began after that process started. It does not establish pre-ACK blocking or unfinished work from the earlier restart. Source tracing and the blocked-history regression establish the metadata-worker dependency fixed here; they do not attribute every production tail.

</details>

Related: #165608.

<details>
<summary>Hosted CI investigation and remaining upstream failures</summary>

Final-head [CI run 37556779529](https://github.com/openclaw/openclaw/actions/runs/37556779529), head `3292922b0e82`, completed with 79 successful jobs, 24 skipped jobs, two failed test jobs, and the failed aggregate gate. The stale metadata-race fixtures are corrected. No CI rerun was requested.

- **MCP fixture routing:** all ten `mcp-http.session-controls.test.ts` cases fail during tool/auth preparation before the session action. On unchanged base `0288eb1f3692`, `pnpm exec vitest run --config test/vitest/vitest.gateway-core.config.ts src/gateway/mcp-http.session-controls.test.ts --maxWorkers=1 -t 'MCP dispatch preserves archive final-effect authority: allowed'` fails with the identical `Shared-state admission requires the host broker`; adding `--pool=forks` passes. Upstream #166199 moved the sibling question-authority fixture into the fork-backed database-worker lane but omitted this fixture. This branch does not change its routing.
- **History expectation after the new base:** `chat.history advances past a replay boundary that cannot fit all projected siblings` still expects only sequence 2 on page one. Upstream #166263 now compresses an oversized source group into a fetchable placeholder before capping, allowing the older sequence-1 message to fit on the same page. The fixture and paging owner are byte-identical between base `98567acd6060` and this branch. The exact filtered case also fails on unchanged base `98567acd6060` on `blacksmith-testbox` lease `tbx_01m49zrpad1bfnzpwb9wp7t3tz`: a diagnostic print before the unchanged assertion captured `sequences: [1, 2]` and `hasMore: false`. The test exited 1 as expected; the probe command completed in 1m35s, restored the test, removed its temporary worktree, and the lease is stopped. No history behavior is changed here.

The initial CI run also reported one remaining fake timer in `subagent-registry-lifecycle.test.ts`, case `preserves cleanup exhaustion when another run settles (related=true)`. The complete 227-case file passed separately on unchanged base and candidate, and the corrected head's CI no longer reports it. The original failure remains unexplained; passing replays are not claimed as a fix, and no assertion was weakened.

</details>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…enclaw#166365)

## What Problem This Solves

`chat.send` could wait behind unrelated transcript-history reads while authorizing a request, admitting its run, or preparing durable input. An ordered metadata read could hold the database writer FIFO while waiting on the single history worker.

## User Impact

Hot-session input can be persisted and acknowledged while history dispatch is blocked. Exact session rows, target discovery, transcript identity selection, and bounded cold-archive metadata use the existing projection worker. Writer FIFO ordering, current permissions, source replacement checks, and durable input custody remain intact. There are no schema, configuration, retention, or update changes.

## Why This Change Was Made

Metadata discovery and payload reads selected different workers. Use the metadata worker consistently, remove the unused inventory lane parameter, and remove the discovery-only lane fallback. Transcript corpus/archive payloads and maintenance retain their existing owners.

Production LOC delta: **+14**. The generic reader also serves transcript payloads, so the metadata operations must select the existing projection lane explicitly; transcript target selection also retains its lazy worker/incognito boundary. Most added lines are argument/import formatting. No new pool, cache, wrapper, or configuration option is introduced.

## Evidence

Benchmarks and runtime tests ran with provider `blacksmith-testbox`, profile `openclaw-check`, on Linux x86_64 / Node 24.19.0. Paired measurements and the first full staged gate used lease **`tbx_01m499e9p8c3pwdkxrq7kqyt11`** on base `4a96fff224ff`. The full staged gate also passed after rebase to `66cf8a4c0732` on the Linux rig fallback (`node scripts/check-changed.mjs --staged`, exit 0, approximately 50 minutes). Fresh-lease integration proof passed on **`tbx_01m49cshscnkd5rn7tva92rwrp`**: core production types and 63 tests covering exact reads, worktree-owner projection, managed owner policy, and durable ACK; total command 2m23s.

On **`tbx_01m49wfjav8vbwxmsdrw22nrad`**, base `fd7d42fa5176`, core production types and 218 tests across 16 focused files passed in 6m51s. The three corrected race fixtures passed all 58 tests in 2m24s. Their staged gate and a full 227-case registry lifecycle replay passed in 6m14s. The final branch is rebased onto `772d281b298f`; SHA-256 verification confirms all 17 reviewed files are byte-for-byte unchanged. The earlier results are prior-base evidence; hosted CI checks the final integration. All four leases are stopped/expired.

The RPC router/handler and SQLite rig ran 64 sends at concurrency eight, alongside four continuous synthetic history readers and post-ACK preparation. Provider execution was mocked after ACK. Same baseline revision, synthetic data, and lease:

| Request latency | Before | After | Reduction |
|---|---:|---:|---:|
| p50 | 6,451 ms | 979 ms | 84.8% |
| p95 | 17,257 ms | 3,339 ms | 80.7% |
| p99 / max | 18,234 ms | 3,470 ms | 81.0% |
| mean | 7,548 ms | 1,273 ms | 83.1% |

Afterward, all 1,500 history-worker requests were background page reads; foreground metadata used the projection worker. Harness RSS after the run was 2.995 GB before and 3.193 GB after; these are whole test-process measurements, including worker heaps and retained synthetic turns.

A second paired run waited for warm startup, then measured 32 requests with one send outstanding and the same four background history readers:

| Warm request latency | Before | After |
|---|---:|---:|
| p50 | 2,250 ms | 188 ms |
| p95 | 3,036 ms | 323 ms |
| p99 / max | 16,280 ms | 2,246 ms |
| mean | 2,710 ms | 264 ms |

**Both workloads still exceed the 150 ms p50 / 500 ms p99 targets.** The warm median is below 300 ms. The remaining 2,245 ms warm tail records 2,094 ms in authority, 9 ms in admission, 77 ms in persistence, and 65 ms in run admission. Repeated authority preparation and production latency still need finer attribution; this change removes the proven history-queue dependency without relaxing authority or durability.

- The full router → durable transcript → ACK regression passes with history dispatch held. The original revision times out waiting for ACK under the same gate (the existing 120-second Vitest deadline), confirming the regression catches the old dependency.
- Broader owner/sibling coverage: 167 tests passed across 12 files. After the transcript-target and cold-metadata cutover, 71 relevant tests passed, including cold restore authority, physical replacement, first registration, run admission, and ACK-before-skill-preparation behavior.
- `pnpm test src/gateway/server-methods/chat-send-preparation-ack.test.ts --maxWorkers=1`: 5 passed; 38.85 s runner wall time including worker compilation; 10.93 s test time. The new case took 3.67 s. Real router authorization and SQLite custody are required to prove a durable ACK; helper-only tests would miss the persistence dependencies. Added Linux test execution cost: approximately 3.7 seconds per run, measured on Testbox; hosted per-case timing was not collected.
- `node scripts/check-changed.mjs --staged`: passed on the paired measurement base in 27m53s, including all 27 core test type graphs, lint, dead-export, cycle, and storage guards. Every reviewed file matched its recorded SHA-256.
- Independent Codex reviews of the production scope and final three test corrections: scoped-clean, no actionable P0/P1 findings.
- Three additional test fixtures now inject metadata races/errors through the projection worker: native model ownership, diff-baseline generation, and SDK transcript-target locking. All 58 tests in those files passed on the fresh lease in 2m24s; their assertions are unchanged. The scoped staged gate selected and passed the `agents-other`, `other`, and `plugin-sdk` type graphs, lint, and dead-export checks.

<details>
<summary>24-hour slow-send attribution</summary>

The journal query covered 2026-10-05 19:00:50Z through 2026-10-06 19:00:50Z and yielded 77 request and 99 startup records. These are **conditional slow-stage distributions**: the logger excludes stages below 1,000 ms. Timers include awaited/scheduling time and can overlap; they are not exclusive CPU measurements. Missing fields are absent samples. Nearest-rank p99 equals max for these sample counts.

| Stage / phase | Samples | p50 ms | p95 ms | p99 / max ms |
|---|---:|---:|---:|---:|
| Request total | 77 | 3,418 | 5,611 | 6,951 |
| Authority | 77 | 1,429 | 2,267 | 2,748 |
| Admission | 77 | 273 | 469 | 685 |
| Attachments | 77 | 0 | 11 | 285 |
| Persistence | 77 | 566 | 1,234 | 2,815 |
| Preparation | 77 | 0 | 1 | 8 |
| Reply context | 77 | 0 | 83 | 116 |
| Run admission | 77 | 1,135 | 2,314 | 2,402 |
| Effects | 77 | 0 | 0 | 0 |
| Response | 77 | 1 | 1 | 2 |
| Startup total | 99 | 5,674 | 102,321 | 3,288,574 |
| Startup ACK (repeated request duration) | 99 | 3,158 | 4,851 | 6,951 |
| Startup authoring | 95 | 1 | 6 | 9 |
| Startup preparation | 95 | 3,532 | 5,951 | 3,046,035 |
| Startup reply initialization | 95 | 1,612 | 80,753 | 356,488 |
| Startup reply context | 99 | 0 | 0 | 129 |
| Startup worktree | 13 | 3,575 | 5,131 | 5,131 |
| Startup dispatch | 99 | 15 | 544 | 8,757 |

The 54.8-minute startup record had already ACKed in 250 ms and began after that process started. It does not establish pre-ACK blocking or unfinished work from the earlier restart. Source tracing and the blocked-history regression establish the metadata-worker dependency fixed here; they do not attribute every production tail.

</details>

Related: openclaw#165608.

<details>
<summary>Hosted CI investigation and remaining upstream failures</summary>

Final-head [CI run 37556779529](https://github.com/openclaw/openclaw/actions/runs/37556779529), head `3292922b0e82`, completed with 79 successful jobs, 24 skipped jobs, two failed test jobs, and the failed aggregate gate. The stale metadata-race fixtures are corrected. No CI rerun was requested.

- **MCP fixture routing:** all ten `mcp-http.session-controls.test.ts` cases fail during tool/auth preparation before the session action. On unchanged base `fd7d42fa5176`, `pnpm exec vitest run --config test/vitest/vitest.gateway-core.config.ts src/gateway/mcp-http.session-controls.test.ts --maxWorkers=1 -t 'MCP dispatch preserves archive final-effect authority: allowed'` fails with the identical `Shared-state admission requires the host broker`; adding `--pool=forks` passes. Upstream openclaw#166199 moved the sibling question-authority fixture into the fork-backed database-worker lane but omitted this fixture. This branch does not change its routing.
- **History expectation after the new base:** `chat.history advances past a replay boundary that cannot fit all projected siblings` still expects only sequence 2 on page one. Upstream openclaw#166263 now compresses an oversized source group into a fetchable placeholder before capping, allowing the older sequence-1 message to fit on the same page. The fixture and paging owner are byte-identical between base `772d281b298f` and this branch. The exact filtered case also fails on unchanged base `772d281b298f` on `blacksmith-testbox` lease `tbx_01m49zrpad1bfnzpwb9wp7t3tz`: a diagnostic print before the unchanged assertion captured `sequences: [1, 2]` and `hasMore: false`. The test exited 1 as expected; the probe command completed in 1m35s, restored the test, removed its temporary worktree, and the lease is stopped. No history behavior is changed here.

The initial CI run also reported one remaining fake timer in `subagent-registry-lifecycle.test.ts`, case `preserves cleanup exhaustion when another run settles (related=true)`. The complete 227-case file passed separately on unchanged base and candidate, and the corrected head's CI no longer reports it. The original failure remains unexplained; passing replays are not claimed as a fix, and no assertion was weakened.

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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