Repository navigation
fix(agents): preserve complete ACP subagent answers - #165800
Conversation
ACP-backed subagents (sessions_spawn runtime="acp") delivered only the 4096-character terminal reply head to the parent, prefixed with [truncated-by-retention: complete child answer unavailable]. The shared text-turn transcript writer used by ACP turns never attached __openclaw.runId to the assistant row, so the completion reader's visible-final lookup by run id could not find the child's answer. Carry the run id through persistTextTurnTranscript into persistSessionTranscriptTurn, which already stamps run-owned assistant rows, and pass it from the ACP execution path and the CLI post-run transcript mirror. This is the ACP sibling of the claude-cli fix in openclaw#162843.
|
🦞👀 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. Reviewed October 8, 2026, 3:25 AM ET / 07:25 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch records the owning run ID on ACP and CLI fallback transcript answers so parents can recover the complete answer from the correct child run. Example: A parent requests a 400-line answer from an ACP child
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains necessary and has no identified merge blocker. Current main still contains the answer-recovery defect, the prior timing requirement is resolved, and the recorded production-boundary observations support the repair. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherOpenClaw stores child-agent answers in session transcripts. When a child finishes, its parent retrieves the answer belonging to that exact run, using a bounded snapshot when the complete answer cannot be found. flowchart TD
A[ACP or CLI child run] --> B[Complete answer and run identity]
B --> C[Shared transcript writer]
C --> D[Session transcript]
D --> E[Exact-run answer lookup]
E --> F[Complete answer to parent]
E --> G[Bounded fallback when unavailable]
Technical reviewBest possible solution: Supply the owning run ID through the existing transcript writer while preserving exact-run selection, visibility, and retention behavior. Do we have a high-confidence way to reproduce the issue? Yes: current-main source proves the missing run stamp conflicts with exact-run selection, and the supplied negative control and Gateway comparison corroborate it. This read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes: repairing the producer uses the existing storage contract and avoids broadening matching rules or adding a second recovery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 017842386a7f. Provenance checked
TestingProof path: shipped entry point. Added test files: 1. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -1, Tests +55, Docs +2. Total +56 across 5 files. View PR surface stats
LabelsLabel changes: No label 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 History |
Preserve the original run-owned ACP and CLI transcript fix, exercise recovery after a later turn, and simplify the shared writer without changing usage semantics. Co-authored-by: yetval <[email protected]>
|
Merged via squash.
|
* fix(agents): preserve complete ACP subagent answers ACP-backed subagents (sessions_spawn runtime="acp") delivered only the 4096-character terminal reply head to the parent, prefixed with [truncated-by-retention: complete child answer unavailable]. The shared text-turn transcript writer used by ACP turns never attached __openclaw.runId to the assistant row, so the completion reader's visible-final lookup by run id could not find the child's answer. Carry the run id through persistTextTurnTranscript into persistSessionTranscriptTurn, which already stamps run-owned assistant rows, and pass it from the ACP execution path and the CLI post-run transcript mirror. This is the ACP sibling of the claude-cli fix in openclaw#162843. * fix(agents): harden complete ACP answer recovery proof Preserve the original run-owned ACP and CLI transcript fix, exercise recovery after a later turn, and simplify the shared writer without changing usage semantics. Co-authored-by: yetval <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: yetval <[email protected]>
* fix(agents): preserve complete ACP subagent answers ACP-backed subagents (sessions_spawn runtime="acp") delivered only the 4096-character terminal reply head to the parent, prefixed with [truncated-by-retention: complete child answer unavailable]. The shared text-turn transcript writer used by ACP turns never attached __openclaw.runId to the assistant row, so the completion reader's visible-final lookup by run id could not find the child's answer. Carry the run id through persistTextTurnTranscript into persistSessionTranscriptTurn, which already stamps run-owned assistant rows, and pass it from the ACP execution path and the CLI post-run transcript mirror. This is the ACP sibling of the claude-cli fix in #162843. * fix(agents): harden complete ACP answer recovery proof Preserve the original run-owned ACP and CLI transcript fix, exercise recovery after a later turn, and simplify the shared writer without changing usage semantics. Co-authored-by: yetval <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: yetval <[email protected]> (cherry picked from commit a9ff654)
* fix(agents): preserve complete ACP subagent answers ACP-backed subagents (sessions_spawn runtime="acp") delivered only the 4096-character terminal reply head to the parent, prefixed with [truncated-by-retention: complete child answer unavailable]. The shared text-turn transcript writer used by ACP turns never attached __openclaw.runId to the assistant row, so the completion reader's visible-final lookup by run id could not find the child's answer. Carry the run id through persistTextTurnTranscript into persistSessionTranscriptTurn, which already stamps run-owned assistant rows, and pass it from the ACP execution path and the CLI post-run transcript mirror. This is the ACP sibling of the claude-cli fix in * fix(agents): harden complete ACP answer recovery proof Preserve the original run-owned ACP and CLI transcript fix, exercise recovery after a later turn, and simplify the shared writer without changing usage semantics. Co-authored-by: yetval <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: yetval <[email protected]> (cherry picked from commit a9ff654) (cherry picked from commit c0c7b56) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes: successful ACP subagents deliver a truncation notice and only the first 4,096 characters to their parent because their complete transcript answer cannot be found by run ID. The shared CLI fallback writer has the same missing ownership metadata.
Fixes #162777 (the remaining shared CLI fallback writer path). Related: #155119 (answer loss only; duplicate settlement and pending delivery are outside this change). No separate ACP issue was found in the issue search.
User Impact
Parents recover the complete visible answer for the completed ACP or CLI fallback run, including answers longer than 4 KiB and answers followed by another turn in the same child session. No configuration, protocol, schema, or historical-transcript migration changes are required.
Why This Change Was Made
Pass the existing owning run ID from ACP execution and CLI post-run handling through the shared text-turn writer to the canonical transcript persistence owner. The existing exact-run reader then finds the full assistant row; its bounded lifecycle fallback and run-isolation checks remain intact.
Original fix by @yetval; maintainer cleanup simplifies the same writer's usage handling and removes single-use metadata locals. The regression now writes a later answer before recovering the original long answer, so it also protects against delivering another run's result. Documentation names the ACP/CLI guarantee.
Evidence
Maintainer head:
965a7240734a0bfe3374f22291063ef6bcd3a1f7.Unit, types, static checks, independent review, and exact-head CI passed. Fresh live proof is partial: the real Gateway delivered the full answer to the parent, but the initial fixture compared JSON-escaped context to raw newlines and used capped history. Coordinator timeouts blocked the corrected fixture and fresh main-side Gateway comparison. This PR has not been merged.
Current-main source confirmation: at
278d66f2459a088cd6c770a92fe30a2fa48cc226, the ACP caller and shared writer still omitrunId. The completion reader's exact-run lookup therefore misses and falls back to[truncated-by-retention: complete child answer unavailable]plus the terminal snapshot. The shared writer has the same Git blob (98a3ba0c2a680d8b00861aa983cebb100c16764f) at current main and the PR's merge base.Isolated maintainer proof
AWS lease
cbx_b618c3d07a3a(c7a.8xlarge), Node 24.21.0, pnpm 12.5.1. Launched from a clean trusted main worktree with itsscripts/crabbox-untrusted-bootstrap.sh,CRABBOX_ENV_ALLOW=CI,--provider aws --fresh-pr openclaw/openclaw#165800 --no-hydrate, and the exact full head SHA. The trusted bootstrap enforced IMDS no-role/404, the package-manager pin, and a fresh temporary HOME. No contributor runtime code executed on the maintainer host.Unit run:
run_058b4a9239883f80a017268114b8ad4c.pnpm test src/agents/command/transcript-persistence.test.ts --maxWorkers=1pnpm test src/agents/command src/commands/agent.acp.test.ts src/commands/agent.test.ts --maxWorkers=1pnpm tsgo:corepnpm tsgo:core:test --changed-paths-json '["src/agents/command/transcript-persistence.test.ts"]'transcript-persistence.tsrestored from the merge baseThe negative control failed at the real
visible-finallookup withReceived: undefined. The writer was restored from the candidate afterward andgit diff --exit-codepassed. Since the reverted writer is byte-identical to current main's writer, this confirms the current-main ownership defect.ClawSweeper review 6003081889 requested measured wall time and attributable CI seconds. The cold standalone file took 50.63 s, with Vitest reporting 46.83 s and 91% spent transforming modules; its two recovery cases took 190 ms combined. This test needs the actual SQLite transcript writer and finder to protect recovery, rather than merely asserting that a helper receives metadata. The exact-head CI file passed 4/4 with inner parallelism 1, 5.29 s runner wall time, 4.16 s Vitest duration, and 331 ms combined recovery-case time (CLI 280 ms, ACP 51 ms): file-cost log.
Exact-head CI passed, including module tests, production types, core test types, lint, docs, and
openclaw/ci-gate. The old head's gate had failed becausepr-fail-fastwas abandoned; that was not a failure of this test. Targeted local oxfmt, oxlint, andgit diff --checkpassed. Independent Codex autoreview was scoped-clean at P2 and above for the complete committed branch.Real Gateway observation and remaining gap
Live run:
run_57d190c02725de0df158a754efbefb17, on the same fresh secretless candidate-bound lease. The harness used a real child Gateway process, isolated state, an ephemeral port,chat.send, the actualsessions_spawn(runtime: "acp")path, a registered fake external ACP backend, and a loopback OpenAI Responses provider. It emitted three parts totaling 16,881 characters. The normal transcript and completion owners remained real.Command after preparing the Gateway with
pnpm openclaw --help:The full E2E build completed all 11 stages and built 96 plugins. The Gateway flow reached three provider requests and completed in 23.953 s. Inspection of the captured parent completion request, decoding its existing JSON conversation-data string, showed:
The first fixture nevertheless exited 1: its mock parent's decision/assertions searched for raw newlines in escaped context, and
chat.historyused its default display cap. The fixture was corrected to decode that context and requestmaxChars: 100000; no production change was required. Repeated coordinator GET-lease timeouts prevented the corrected rerun from starting. Therefore the corrected assertion suite, independent uncapped history inspection, and a fresh full-main Gateway comparison remain uncompleted. No external ACP executable or real model provider was tested.The contributor's earlier in-process Gateway comparison remains separate evidence: on baseline
a38b64b2fea, an 11,396-character / 400-line answer delivered only 148 lines and lost its end marker; the original fix delivered all 400 lines and the marker without the retention notice. ClawSweeper accepted that supplied trace. It is not relabeled as a fresh maintainer baseline run.Change size and disposition
PR numstat against the origin/main merge base
a38b64b2fea5b16aa4352147187a8c8ab2e7413a:src/agents/command/acp-execution.tssrc/agents/command/post-run.tssrc/agents/command/transcript-persistence.tssrc/agents/command/transcript-persistence.test.tsdocs/tools/subagents/announce.mdProduction 8 added / 9 removed (net -1); tests 56 / 1 (net +55); docs 3 / 1 (net +2). No changelog edit; this body retains release-note context and human contributor credit. The ClawSweeper cost-reporting finding is addressed; the campaign's remaining fresh-live comparison gap is explicit above. No merge was requested or performed.