Repository navigation
fix(agents): show CLI tool activity in session tail and trajectory exports - #188069
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 changesRecords observed CLI tool calls and results so session tail and trajectory exports retain tool activity. Example: Claude CLI reads proof.txt containing TASK_188069_ACTUAL_READ_RECEIPT, followed by another turn.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a current CLI trajectory gap through the existing recorder, and the earlier diagnostic-retention finding is resolved. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe CLI runner receives parsed native tool observations, correlates Gateway-owned outcomes, and forwards bounded events to the existing SQLite trajectory recorder consumed by session tail and export. flowchart LR
A[Native CLI output] --> B[Streaming parser]
B --> C[CLI event handlers]
D[Gateway tool outcomes] --> C
C --> E[Trajectory recorder]
E --> F[SQLite storage]
F --> G[Session tail and export]
Technical reviewBest possible solution: Forward observed CLI tool events through the existing bounded recorder while preserving authoritative outcomes and canonical transcript semantics. Do we have a high-confidence way to reproduce the issue? Supplied genuine-CLI before/after proof reproduces missing tool observations on pinned main, and current-main source retains the responsible omission; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete repair for forward-looking trajectory inspection: it connects existing observations to the existing recorder without introducing another history or storage owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 80b9e7b71fb2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +23, Tests 0, Docs +1. Total +24 across 3 files. Added test files: 0. View PR surface stats
Review metrics
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 30, 2026, 1:08 AM ET / 05:08 UTC (Revision 3). |
Genuine Claude CLI → built Gateway → tail/export proofHead: Actual native binary: official npm Claude Code 2.1.309, verified by its own The earlier #140273 settings-route blocker is avoided without changing its guards: a task-local HTTPS CONNECT proxy and trusted test CA serve the Anthropic Messages fixture. Normal TLS verification remains enabled; the certificate was verified for Claude initially exposes deferred tools. The fixture requests the real native Each capture ran two real Gateway turns: the first performs the tool work, the later turn explicitly uses no tools. Only then were the shipped consumers invoked: openclaw --profile p188069base agent --session-key <key> --message '<read the task marker file>' --timeout 90 --json
openclaw --profile p188069base agent --session-key <key> --message 'Reply briefly without using tools.' --timeout 90 --json
openclaw --profile p188069base sessions tail --session-key <key> --tail 200
openclaw --profile p188069base sessions export-trajectory --session-key <key> --workspace <task-workspace> --output <label> --jsonCandidate uses its own built binary/profile. Both exact binaries printed their task-owned config and agent-database paths before running.
The extra candidate pair is the genuine native ToolSearch, not duplicate read recording. Every case retains four session-start/end events, confirming that main's missing tools are not disabled capture or failed execution. Candidate tail, on both repetitions: The redacted export retains the actual read identity and outcome: {"type":"tool.call","data":{"toolCallId":"toolu_188069_tool-1","name":"read","args":{"path":"$WORKSPACE_DIR/proof.txt"}}}
{"type":"tool.result","data":{"toolCallId":"toolu_188069_tool-1","name":"read","status":"completed","success":true,"result":[{"type":"text","text":"TASK_188069_ACTUAL_READ_RECEIPT\n"}]}}Zero-growth regression and checksRemoved the added fixture extraction, duplicate trajectory fixture cases and the introduced 153-line allocation. The existing correlation scenario now checks recorded unknown outcomes (no fabricated success) and a later settled completion; existing MCP/server-native timeout cases additionally assert no unobserved
Scope: this qualifies the real native CLI, tool, Gateway and SQLite consumer path against a deterministic local model fixture. It is not a live Anthropic-service/authentication test. Historical CLI turns and |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Diagnostic contract retained on the repaired headHead: Addressed the P3 test-retention finding: the ambiguous identical-call scenario again captures trusted diagnostic events and asserts exactly six, including both The fixture cleanup inlines redundant single-identity emission wrappers and uses a standard recorder spy; the order and contents of the emitted CLI records and host outcomes are unchanged. This retains both independent output contracts without increasing test lines. The final capture suite passes 52/52, with targeted formatter/lint and whitespace checks passing. The other unchanged owner/consumer suites retain their earlier passing results (130 tests across the four suites in aggregate). Production code is unchanged from both the built contributor revision and the independently proved previous head. Therefore the genuine Claude Code 2.1.309 / built Gateway / tail-and-export proof applies to this SHA unchanged: two actual-read reproductions per ref after later turns, candidate-only persisted tool pairs, and no-tool controls on both refs. No permission, auth or SDK changes were made. Final surface: production +23; tests +30/-30 (net 0); docs +2/-1. No added test file or test-line allocation remains. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…ports (openclaw#188069) fix(agents): record CLI backend tool calls in the session trajectory Fixes openclaw#140273. For CLI-backed agent runs (for example Claude Code), OpenClaw already observed each tool call and result, but it never passed them to the session trajectory recorder. Session tail and export therefore showed no tool activity even when the CLI read files. Those existing observations now go to the bounded trajectory recorder, so tool calls and results show up like they do for other runtimes. Evidence: real Claude Code 2.1.309 driven through a built Gateway, routed to a local fixture over HTTPS CONNECT with a trusted test CA, with no login or paid key. After real file reads, session tail and export on main showed 0 tool calls or results (twice). With this change they showed both tool call and result pairs, ToolSearch and Read, with the actual file contents (twice). Runs without tool use recorded no tool rows on both refs. Details: openclaw#188069 (comment) and openclaw#188069 (comment). Thanks @wyf027. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #140273
What Problem This Solves
sessions tailand trajectory exports omit tool calls/results already observed during CLI-backed turns. The native CLI can perform the correct tool work while later inspection shows none of it.User Impact
Future CLI tool observations remain inspectable after later turns. Known failures remain failures; ambiguous host outcomes remain unknown; capture opt-outs retain their existing behavior. Historical turns and
chat.historyare not backfilled.Why This Change Was Made
Forward the existing CLI start/result observations to the existing bounded trajectory recorder before terminal correlation is retired. Reuse existing normalization, replay filtering, first-terminal handling and the host-owned outcome. No permission, auth, SDK, schema, setting or retention rule changes.
Reported by @d3vn0mi in #140273. Builds on the recorder from merged #178007 and the earlier investigation in closed, unmerged #140615. Contributor implementation and commit are retained.
Evidence
Genuine Claude CLI → built Gateway → tail/export before/after proof. Latest-head diagnostic retention and checks.
status:completed,success:true, the marker path and actual marker contents. Tail displaysreadandread ok.This proves the native CLI/tool/Gateway/SQLite consumer path against a deterministic local model endpoint, not live Anthropic authentication or model quality.
Merge Danger
Two-way runtime-code door; reverting does not delete observations already captured under existing retention. No storage migration, public API or execution-policy change. Blast radius is CLI tool trajectory inspection; canonical transcript/history semantics remain unchanged.