Repository navigation
fix: avoid duplicate deferred tool results - #169537
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. What this changesThis PR removes nested structured details from model-facing deferred tool results while retaining the complete result for runtime consumers. Example: An agent discovers sessions_list and invokes dispatch_action with limit=1.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current deferred-result duplication bug with a focused projection change; no actionable correctness or security findings remain. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherOpenClaw Tool Search dispatches authorized catalog tools and projects their returned content into provider-bound text and images while retaining structured details for runtime consumers. flowchart LR
A[Model tool request] --> B[Tool Search dispatcher]
B --> C[Catalog execution owner]
C --> D[Target tool result]
D --> E[Model content projection]
D --> F[Complete runtime details]
E --> G[Provider request]
Technical reviewBest possible solution: Land the focused projection repair while preserving complete runtime details, existing image handling, and error semantics. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the duplicate serialization path, and the supplied CLI capture demonstrates it before the fix; this review ran no target code. Is this the best way to solve the issue? Removing details at the existing model-projection boundary restores direct-call parity without a new setting, competing owner, or change to execution and runtime consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2c130c7039f2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -3, Tests +1, Docs +2. Total 0 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 13, 2026, 11:18 PM ET / October 14, 2026, 03:18 UTC (Revision 3). |
# Conflicts: # docs/tools/tool-search.md
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
fix(tool-search): send deferred tool results to the model once When the model called a deferred tool through Tool Search, the tool's structured result was serialized twice into the model context. This wasted tokens and the truncation budget. Deferred results now include the payload once, like direct tool calls. Proof: built CLI with a recording provider. The deferred call's result payload appeared twice on main and once with this change; the direct-call control is once on both. A live openai/gpt-5.4-mini turn searched for and called sessions_list successfully. Fixes openclaw#169492. Thanks @TUARAN. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes #169492. Deferred tool execution used to serialize a target's structured payload twice: once in its text content and again in
result.details. Keep the model-facing result's content and status fields, but retain the complete result only in the control tool's structured details for runtime/UI consumers. Images and termination/error handling remain intact.Original fix by @TUARAN; reported in #169492.
Evidence
Built CLI, isolated state, recording OpenAI-compatible scripted provider. The scripted turn searches for
sessions_list, dispatches it, then records the next provider request. State was created through the shipped agent command, not database writes.Captured, redacted output:
The direct-call control retains the same result fields (
count,sessions,hasMore,limitApplied). Session identifiers and timestamps naturally differ between isolated runs. Current main renamed the deferred dispatcher fromtool_calltodispatch_action; the integrated candidate uses that shipped name.Exact-head checks: 60 Tool Search tests passed; changed-file formatting and lint passed. Simplification retained the existing result-projection owner and extended the existing regression rather than adding scaffolding. Production delta: +4/-7; tests: +2/-1.
Live gate on
openai/gpt-5.4-mini, explicitly using the OpenClaw runtime:The persisted live transcript confirms both tool execution and the final reply.
No overlap with Pash/Sarah changes.
Risk
Two-way door: reverting restores the previous context projection without changing persisted state or configuration. Blast radius is model context for deferred Tool Search calls; direct tool calls are unchanged. Runtime/UI consumers still receive the complete structured result.