Skip to content

[codex] Project Tool Search target calls in transcripts#80164

Merged
scoootscooob merged 1 commit into
mainfrom
codex/core-toolsearch-transcript-shape
May 10, 2026
Merged

[codex] Project Tool Search target calls in transcripts#80164
scoootscooob merged 1 commit into
mainfrom
codex/core-toolsearch-transcript-shape

Conversation

@scoootscooob

@scoootscooob scoootscooob commented May 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Project hidden Tool Search target executions into canonical messagesSnapshot output as target toolCall/toolResult pairs.
  • Keep provider-facing Tool Search controls compact, but expose logical target tools in trajectory context, with compact controls retained as providerVisibleTools.
  • Cover bridge parent-call propagation and transcript projection in Tool Search tests.

Why

Core Tool Search currently lets non-Codex models call wrapper tools such as tool_search_code or tool_call, then runs the selected target tool behind the bridge. The target lifecycle events use the right tool name, but verifier-facing transcript and trajectory surfaces can still show only the wrapper call. Benchmarks that score actual tool calls can then miss the logical target execution and return zeroes.

This is the core/native counterpart to #80155, which handles the Codex app-server dynamic tool transcript shape.

Real behavior proof

  • Behavior or issue addressed: Core/native PI Tool Search target calls were executed behind tool_search_code, but verifier-facing messagesSnapshot/trajectory output could show only the wrapper call instead of the logical target tool call/result.
  • Real environment tested: Local OpenClaw source worktree on Darwin 24.1.0 arm64 with Node v25.2.1.
  • Exact steps or command run after this patch: Ran node --import tsx --input-type=module with an inline script that registered a real Tool Search catalog, executed the tool_search_code bridge, captured the hidden target execution, and printed the projected transcript/trajectory shape.
  • Evidence after fix: terminal output excerpt:
{
  "visibleProviderTools": ["tool_search_code"],
  "hiddenCatalogToolCount": 1,
  "bridgeResultOk": true,
  "bridgeTelemetry": {
    "catalogSize": 1,
    "sources": { "openclaw": 1, "mcp": 0, "client": 0 },
    "searchCount": 0,
    "describeCount": 1,
    "callCount": 1
  },
  "capturedTargetExecutions": [
    {
      "parentToolCallId": "wrapper-call-proof",
      "toolCallId": "tool_search_code:wrapper-call-proof:proof_lookup_record:1",
      "toolName": "proof_lookup_record",
      "input": { "value": "invoice-42" }
    }
  ],
  "projectedMessagesSnapshot": [
    { "role": "assistant", "toolCall": "tool_search_code", "id": "wrapper-call-proof" },
    { "role": "toolResult", "toolName": "tool_search_code", "id": "wrapper-call-proof" },
    {
      "role": "assistant",
      "toolCall": "proof_lookup_record",
      "id": "tool_search_code:wrapper-call-proof:proof_lookup_record:1",
      "arguments": { "value": "invoice-42" }
    },
    {
      "role": "toolResult",
      "toolName": "proof_lookup_record",
      "id": "tool_search_code:wrapper-call-proof:proof_lookup_record:1",
      "text": "target-result invoice-42 via tool_search_code:wrapper-call-proof:proof_lookup_record:1"
    },
    { "role": "assistant", "text": "done" }
  ],
  "trajectoryCompiledShape": {
    "tools": ["proof_lookup_record"],
    "providerVisibleTools": ["tool_search_code"]
  }
}
  • Observed result after fix: The target execution keeps tool_search_code as the only provider-visible tool, records the parent wrapper id, and projects the logical proof_lookup_record toolCall/toolResult pair into messagesSnapshot; trajectory context exposes logical target tools while preserving compact providerVisibleTools.
  • What was not tested: Full external-model network run; the proof uses the local OpenClaw Tool Search bridge/runtime with an in-process catalog target so no provider credentials or network calls are required.

Validation

  • node scripts/test-projects.mjs src/agents/tool-search.test.ts
  • node scripts/test-projects.mjs src/agents/pi-embedded-runner/run/attempt.test.ts
  • pnpm check:changed

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels May 10, 2026
@scoootscooob
scoootscooob marked this pull request as ready for review May 10, 2026 07:41
@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR projects hidden Tool Search target executions into PI messagesSnapshot and trajectory output while adding tests for parent wrapper id propagation and projection ordering.

Reproducibility: yes. source inspection gives a high-confidence path: current main executes target tools through runToolLifecycle but returns the unprojected active-session messagesSnapshot. I did not run a live Tool Search turn in this read-only review.

Real behavior proof
Sufficient (terminal): The PR body now includes after-fix terminal output from a local Tool Search bridge/runtime run showing the projected target transcript and trajectory shape.

Next step before merge
Human handling is still needed for protected-label review and the exact-head checks-fast-protocol failure; there is no narrow code repair to queue from this review.

Security
Cleared: The diff is limited to internal Tool Search transcript/trajectory projection and tests, with no dependency, workflow, secret, permission, or supply-chain changes.

Review details

Best possible solution:

Land a maintainer-approved projection that records logical target tool calls/results in verifier-facing transcripts while preserving compact provider-visible Tool Search controls.

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

Yes, source inspection gives a high-confidence path: current main executes target tools through runToolLifecycle but returns the unprojected active-session messagesSnapshot. I did not run a live Tool Search turn in this read-only review.

Is this the best way to solve the issue?

Likely yes: carrying the wrapper parent id and projecting logical target call/result pairs after the wrapper result is a narrow fix that preserves provider-visible compaction. Maintainer review should still clear the trajectory contract split and the failing protocol check before merge.

What I checked:

  • Protected label: Live PR metadata shows labels agents, maintainer, and size: M; repository policy keeps protected-label PRs open for explicit maintainer handling. (39329c981089)
  • Current-main source path: Current main routes hidden Tool Search target execution through runToolLifecycle, then assigns messagesSnapshot from the selected active-session snapshot without target-call projection, matching the PR's stated bug boundary. (src/agents/pi-embedded-runner/run/attempt.ts:2665, 09132effa82a)
  • Tool Search contract: The Tool Search docs say final real tool calls cross back into OpenClaw and should be observable through normal logging/telemetry, supporting the requested transcript projection. Public docs: docs/tools/tool-search.md. (docs/tools/tool-search.md:49, 09132effa82a)
  • PR diff reviewed: The PR adds target transcript projection helpers, forwards parent wrapper call ids into catalog execution, applies the projection to messagesSnapshot, and records logical tools plus providerVisibleTools for compacted trajectory context. (src/agents/tool-search.ts:536, 39329c981089)
  • Regression coverage: The PR adds a focused Tool Search test proving projected target call/result messages are inserted after the wrapper result and that code/structured bridge calls propagate parent ids. (src/agents/tool-search.test.ts:506, 39329c981089)
  • Real behavior proof: The updated PR body includes after-fix terminal output from a local OpenClaw Tool Search bridge/runtime run showing provider-visible tool_search_code, a captured hidden proof_lookup_record execution, projected messagesSnapshot target call/result records, and trajectory tools/providerVisibleTools split. (39329c981089)

Likely related people:

  • @steipete: Introduced the PI Tool Search runtime, wired it through the embedded runner, and added adjacent Tool Search coverage in the current-main history for this surface. (role: feature introducer and recent area contributor; confidence: high; commits: 93acb3815958, 7a1a3ae2fe6d, c6ef46d70359; files: src/agents/tool-search.ts, src/agents/pi-embedded-runner/run/attempt.ts, src/agents/tool-search.test.ts)

Remaining risk / open question:

  • Exact-head CI currently includes a checks-fast-protocol failure whose visible annotation does not identify a narrow repair from this read-only review.
  • The PR changes trajectory context.compiled.tools semantics for compacted Tool Search runs; maintainer review should confirm downstream trajectory/export consumers expect the tools versus providerVisibleTools split.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 09132effa82a.

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 10, 2026
@scoootscooob
scoootscooob force-pushed the codex/core-toolsearch-transcript-shape branch from 39329c9 to c8e6d29 Compare May 10, 2026 08:18
@scoootscooob
scoootscooob merged commit 769b117 into main May 10, 2026
111 checks passed
@scoootscooob
scoootscooob deleted the codex/core-toolsearch-transcript-shape branch May 10, 2026 08:24
longstoryscott pushed a commit to longstoryscott/openclaw that referenced this pull request May 13, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR proof: sufficient ClawSweeper judged the real behavior proof convincing. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant