Skip to content

feat(research): preserve native execution and selected search accounts - #177228

Merged
vincentkoc merged 10 commits into
mainfrom
openclaw/research-native-search-20261019
Nov 6, 2026
Merged

vincentkoc merged 10 commits into
mainfrom
openclaw/research-native-search-20261019

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Problem

Portable research must use the host-selected model and credential owner for model-backed search, retain source provenance, and replay prior receipts without new effects.

Changes

  • Carry host-owned model/profile selection through embedded tools, Gateway tools.invoke and MCP loopback without accepting model-authored authorization.
  • Preserve exact credential pins through search; unsupported required native models fail before thread creation rather than silently switching models or billing accounts.
  • Use the supported standalone native search path when structured source results are required.
  • Preserve fetched-document retrieval times and observed execution routes in memoized evidence; surface route changes without fabricating fresh retrievals.
  • Retain cancellation evidence while forbidding new calls during replay.

Stack and scope

Depends on the merged #173974. #177230 follows with authorized retained research views. The superseded #177229 remains closed; current native panel ownership is preserved. Source publication does not deploy a Gateway.

Evidence

  • Exact signed head: 03ce16a7f73ff2cdbba72d930d2c66663632291a; tree: 7e78f46c02d0a773090dbf6dc8095c3ff928c94d.
  • Native ancestry-preserving baseline onto bundled merge 3f8d6d6b6ad6bcbf67c995c22f6d6d02d885dc33; independent audit verified all 24 conflict resolutions. Retired extension-host test copies and duplicate project registration were removed; the landed native, Google, durable-job, and wake owners remain intact.
  • 235 focused tests across eight native Vitest shards passed. Real tools.invoke plus Codex 0.164.0 exercised selected model/account through a loopback Responses and native-search endpoint, rejected a foreign caller, and revoked persisted membership during native acquisition. The denied paths read no credentials, start no native client, and make no HTTP request. This is real native protocol/authority proof with synthetic local provider responses, not a paid search result.
  • Local P2 review found a real fallback bug: only the first candidate honored an explicit profile pin. The existing loop now stops after each matching pinned provider fails and retains its error. Three later-pinned scenarios failed before the fix; 74 affected tests passed afterward, followed by all eight final table cases. Unpinned automatic fallback remains supported.
  • Core and extension production/test types, affected core test leaves, typed lint, format, and outgoing-content scrub passed. Exact-base test-line budget: 6,540,627 / 6,540,632.
  • Fresh local autoreview and final committed-range autoreview against 3f8d6d6b are P0–P2 scoped-clean. The latter included frozen native/authority owner source. Local ClawSweeper is unavailable because no clean dependency-qualified built runner is present; the documented hosted-review fallback was requested at feat(research): preserve native execution and selected search accounts #177228 (comment).
  • CI on 23e424cd exposed an extension-test/core-type boundary violation in the new host test. The test now lives under test/plugins and enters through the approved lazy Codex test API, retaining the real binary and all authority assertions. The exact failed boundary gate, 52 affected tests, the native failed-CI replay, targeted types/lint, and fresh committed-range P2 review passed.
  • Full production build passed on 23e424cd in 3m23.7s. Production code is byte-identical in this test-boundary-only replacement. Exact replacement-head CI passed: https://github.com/openclaw/openclaw/actions/runs/42230184053 (attempt 1). The native completed-hosted-evidence gates are accepted.
  • Upstream authenticated native and Google acceptance, and bundled fresh-install/stable-upgrade acceptance, are complete in the merged dependency PRs. No production Gateway deployment or restart is part of this change.

@clawsweeper

clawsweeper Bot commented Oct 19, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: codex plugin: file-transfer size: M labels Oct 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR preserves selected model and account context in search and records the execution route used by portable research.

Example: A session selects openai/gpt-5.4 with profile openai:research and invokes Codex search.

  • Before: Search uses the native default model and account.
  • After: Gateway invocation requires gpt-5.4 and openai:research; CLI MCP account propagation remains incomplete.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The updated authority evidence is meaningful, but an account-selection regression still blocks merge.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The maintainer's exact-head execution report and inspected production-boundary test establish selected-model/account HTTP effects through real Codex 0.164.0, foreign-caller rejection, and persisted-membership revocation before credential reads or native startup; provider responses are synthetic.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Partial
User problem: Research and model-backed search can use a different runtime, model, or billing account from the user's selection.
Reason: Preserving explicit account selection has clear value, and the maintainer-authored PR establishes direction; MCP loopback remains incomplete.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: the updated native authority evidence addresses the earlier concern, but MCP loopback can still replace a run-selected search account with the configured account.

Priority: P2
Reviewed head: 23e424cdb56559566e2452dba68823752f027c8b

Before merge

  • Carry the resolved CLI profile into MCP search context (P1) - For a CLI run selecting openai/gpt-5.4 with openai:personal while the agent default is openai/gpt-5.4@openai:configured, buildCliMcpGrantContext supplies only modelProvider/modelId. Neither webSearchModelSelection nor modelAuthProfileId is populated on that path, so this fallback inserts openai:configured and the Codex provider now explicitly uses that account. With personal first in auth.order, this also changes the previous search-account choice. Populate the new host-owned selection from the resolved CLI account during grant creation and carry it through tool resolution; the standalone tools.invoke test cannot catch this path.

Findings

  • [P1] Carry the resolved CLI profile into MCP search context — src/agents/openclaw-tools.model-context.ts:58-64

Tests

  • Low-value test src/web-search/runtime.test.ts: Remove the added modelSelection forwarding test at line 574: it asserts a mocked execute call shape and adds no final-effect coverage beyond the native account test, leaving the earlier test-value advice unresolved.
  • Missing end-to-end proof: The native authority scenario covers standalone Gateway invocation, but does not exercise a CLI MCP grant with a run-selected account different from the configured account.
Agent review details

How this fits together

Agent and Gateway tool assembly supply host-selected model context to the shared search runtime, which dispatches to provider plugins; portable research retains returned execution facts with its evidence.

flowchart LR
  A[Agent run] --> C[Tool assembly]
  B[Gateway invocation] --> C
  C --> D[Search runtime]
  D --> E[Codex native worker]
  E --> F[Provider transport]
  F --> G[Research evidence]
Loading

Technical review

Best possible solution:

Carry the resolved CLI account through the existing MCP grant producer so every search entry path preserves the same host-selected model and profile.

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

Source establishes the MCP mismatch: its grant carries only provider/model, while the new resolver fills the absent account from agent configuration; no reproduction was run during this read-only review.

Is this the best way to solve the issue?

The existing search and native execution owners are appropriate, but the cutover needs the CLI grant producer to preserve its resolved account rather than reconstructing it from defaults.

Full review comments:

  • [P1] Carry the resolved CLI profile into MCP search context — src/agents/openclaw-tools.model-context.ts:58-64
    For a CLI run selecting openai/gpt-5.4 with openai:personal while the agent default is openai/gpt-5.4@openai:configured, buildCliMcpGrantContext supplies only modelProvider/modelId. Neither webSearchModelSelection nor modelAuthProfileId is populated on that path, so this fallback inserts openai:configured and the Codex provider now explicitly uses that account. With personal first in auth.order, this also changes the previous search-account choice. Populate the new host-owned selection from the resolved CLI account during grant creation and carry it through tool resolution; the standalone tools.invoke test cannot catch this path.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/cli-runner/mcp-grant-context.test.ts src/agents/openclaw-tools.web-search.test.ts
  • pnpm test src/gateway/tools-invoke-web-search.native.test.ts
  • git diff --check

What I checked:

  • Introduced scope and current main: The pinned introduced range adds selection propagation, per-candidate pin handling, research route reporting, and native transport coverage; fetched main still has the earlier default-selection behavior. (src/agents/openclaw-tools.model-context.ts:32, 23e424cdb565)
  • Missing MCP selection producer: The CLI grant producer records modelProvider and modelId but never supplies webSearchModelSelection or the selected profile; the new resolver consequently substitutes the configured profile when the model matches. (src/agents/cli-runner/mcp-grant-context.ts:219, 23e424cdb565)
  • Native authority evidence: The maintainer reports executing the real Codex process through invokeGatewayTool against local Responses and search endpoints; the committed scenario verifies the selected account/model, rejects a foreign caller, and rejects membership revoked during acquisition before credential reads, native startup, or HTTP effects. (src/gateway/tools-invoke-web-search.native.test.ts:315, 23e424cdb565)
  • Personally inspected determining native contract: The new proof executes the pinned Codex dependency, making its transport contract applicable; the inspected native search owner obtains provider auth and places the current model into SearchRequest. (codex-rs/ext/web-search/src/tool.rs:108, 6aaac6948030)
  • Accepted routing direction: The maintainer-authored body explicitly chooses exact model/profile preservation and refusal instead of silent substitution; the existing bounded native owner retains its authority callback and rejects unavailable required models. (extensions/codex/src/web-search-provider.runtime.ts:35, 23e424cdb565)
  • Persistence compatibility: The latest stable tree contains no deep-research plugin; this change retains existing route literals, adds an optional owner, and leaves version-one job namespaces and receipt storage unchanged, establishing a no-migration case. (extensions/deep-research/src/job-state.ts:8, 23e424cdb565)

Likely related people:

  • Peter Steinberger: Raw commit c916135 adds src/web-search/runtime.ts:575 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c91613518f80; files: src/web-search/runtime.ts)
  • Jason (Json): Raw commit 1e0062b adds extensions/codex/src/web-search-provider.runtime.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1e0062b44a51; files: extensions/codex/src/web-search-provider.runtime.ts)

PR surface

Source +107, Tests +714, Docs +7, Other +3. Total +831 across 28 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 15 127 20 +107
Tests 10 729 15 +714
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 2 3 0 +3
Total 28 866 35 +831

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish. Replaced prior rating: 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review merge-risk labels are merge-risk: 🚨 auth-provider, merge-risk: 🚨 compatibility.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: This is a useful research-routing improvement with a concrete account-selection defect in a limited entry path.
  • merge-risk: 🚨 auth-provider: The new configured-profile fallback can select a different search account from the originating CLI run.
  • merge-risk: 🚨 compatibility: The public search execution context gains modelSelection and portable research changes its default execution route; the maintainer-authored direction accepts these contract changes.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish. Replaced prior rating: 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-19T10:25:02.562Z sha 0609209 :: needs real behavior proof before merge. :: none

Reviewed November 6, 2026, 8:45 AM ET / 13:45 UTC (Revision 2).

@vincentkoc
vincentkoc force-pushed the openclaw/research-native-codex-20261019 branch from 9910412 to 585ac36 Compare November 6, 2026 04:12
@vincentkoc
vincentkoc force-pushed the openclaw/research-native-search-20261019 branch from 0609209 to c9490fc Compare November 6, 2026 04:16
@vincentkoc
vincentkoc changed the base branch from openclaw/research-native-codex-20261019 to openclaw/deep-research-bundled-20261016 November 6, 2026 04:16
@vincentkoc vincentkoc self-assigned this Nov 6, 2026
Base automatically changed from openclaw/deep-research-bundled-20261016 to main November 6, 2026 13:02
@vincentkoc
vincentkoc marked this pull request as ready for review November 6, 2026 13:37
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The branch and PR body now contain the exact-head validation and production-boundary proof. Please review the current committed range; the selected-account authority and per-candidate profile-pin findings are resolved.

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 6, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) November 6, 2026 13:41
@vincentkoc
vincentkoc disabled auto-merge November 6, 2026 13:46
@vincentkoc
vincentkoc merged commit a30ec5d into main Nov 6, 2026
166 checks passed
@vincentkoc
vincentkoc deleted the openclaw/research-native-search-20261019 branch November 6, 2026 14:21
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 7, 2026
openclaw#177228)

* fix(research): keep evidence types in their leaf contract

* test(codex): account for native research boundary coverage

* feat(google): add authority-bound managed research adapter

* feat(research): retain conversation-bound jobs and evidence

* feat(research): recover durable jobs through current source authority

* feat(research): activate lazy bundled research by default

* feat(research): bind native search to selected model and evidence

* fix(research): retain search authority and profile pins

* test(research): keep native search proof host-owned
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Sandboxed web search dropped its session sandbox flag before resolving a provider, allowing configured untrusted workspace or external providers to execute. Carry that flag through both resolver routes into the existing shared manifest trust filter used by web fetch. Bundled, verified official, and nonsandboxed behavior stay intact.

Give sandboxed callers an actionable availability hint without loading rejected provider code for diagnostics. Remove obsolete type exclusions, redundant request forwarding, and a duplicate inherited authStore field; production LOC is net +1.

The 100-line regression allocation protects the real plugin-loader boundary. On main, two sandboxed rejection cases execute the workspace plugin unexpectedly; the fix passes both and all six controls, with no import, registration, tool creation, or execution trace for rejected code. All 115 focused tests and touched-file format/lint pass on Blacksmith Testbox. The final working tree received P0-P2 autoreview; its only index-only fixture finding was resolved by staging the reviewed replacement.

Final CI passes tests, types, lint, builds and security. Its only failure is the existing shared test-line ceiling, six lines over budget, independently reproduced on clean main 31ad71a. Own 100-line regression growth is exactly funded. Landing uses the native inherited-failure evidence route without relabeling failed CI.

Supersedes #144520, thanks @Finn763. Related: #144164.

Co-authored-by: finn763 <[email protected]>
(cherry picked from commit 3e3935a)

Release adaptation (OpenClaw 2026.11.6):
- Cherry-picked onto parent candidate 82f1197 after the scoped #189423 backport. No production or regression-test adaptation required; preserved release's existing tool-result-error import.
- Existing manifest trust filtering and explicit empty scopes remain the sole selection authority; sandboxed is now carried through context and both existing selection routes. No new trust owner, configuration, or permissions.
- Companion audit pinned at bd692e9: e333f7e (#197657) removes the allocation after main's ratchet reset, not applicable here; retain source's 100-line allocation. a30ec5d (#177228) changes native-research/account-pinning execution, not a prerequisite for sandbox selection and excluded. No later PR mentions. Existing shared trust filter/empty-scope refusal is present-equivalent. Other heuristic runtime-name references do not consume the changed contract.

Release validation (local isolated worktree):
- Before this pick, source's real-plugin-loader regression: 2 failed / 6 passed. Both sandboxed workspace cases executed rejected code through runtime preference true and false.
- After this pick: 95 passed across 7 runtime/owner suites, including all 8 regression cases and shared empty-scope cases. Additional tool, provider-error, fetch-provider and setup consumers pass (counts recorded in lane report).
- Changed-TypeScript type-aware lint: 4 files clean using supported core config. Changed-file formatting and git diff --check clean. Manual self-review/pr-simplify: direct propagation into existing owner, no duplicate policy; 3 production files, net +1 line.
- No real model/Gateway end-to-end run or broad gates in this lane; parent owns final release qualification. Upstream claims above describe source validation, not release qualification. One attempted suite was absent on this release and was corrected before running; not a product failure.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 3be9be1ddaa4a19d3672994f03bf580fcf20b6c3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:feature Preliminary submission classification; full source review pending. docs Improvements or additions to documentation extensions: codex extensions: deep-research gateway Gateway runtime merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant