fix(subagent): recover terminal transcript before lost context#94420
fix(subagent): recover terminal transcript before lost context#94420yu-xin-c wants to merge 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 7:01 AM ET / 11:01 UTC. Summary PR surface: Source +152, Tests +222. Total +374 across 4 files. Reproducibility: yes. source-reproducible: current main can reach the stale active-run lost-context fallback after session-store reconciliation returns null, while the announcement path can still attach child output to a failed outcome. I did not run a live Agent Teams race in this read-only review. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land or adapt the current-run private transcript recovery after maintainers accept the successful-terminal-turn predicate and exact-head validation passes on current main. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main can reach the stale active-run lost-context fallback after session-store reconciliation returns null, while the announcement path can still attach child output to a failed outcome. I did not run a live Agent Teams race in this read-only review. Is this the best way to solve the issue? Yes, provisionally: the private current-run transcript predicate is narrower than broad display-output recovery and matches the safer terminal-success direction. Final acceptance still needs maintainer review because it changes lifecycle state and parent delivery semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 695fa4e112f1. Label changesLabel justifications:
Evidence reviewedPR surface: Source +152, Tests +222. Total +374 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
This pull request has been automatically marked as stale due to inactivity. |
Fixes #90299.
Summary
This keeps the lost-context sweeper from reporting a failed subagent when the current run already wrote a successful terminal assistant turn to its private transcript.
The new path is deliberately narrower than display-output recovery: it reads only
entry.execution.transcriptFile, ignores copied stale history before the registry run start, and accepts only an explicit successful terminalstopReason(stop/end_turn).error,aborted, andtoolUseturns still fall through to the existing recovery/error paths.Real behavior proof
Behavior addressed:
When the subagent registry sweeper loses the in-memory run context, it now checks the current run's private transcript before emitting
subagent run lost active execution context. A successful recovery requires a current-run assistant terminal turn, not merely visible/displayed output.Real environment tested:
Local OpenClaw worktree on macOS after
pnpm install --frozen-lockfile. The live proof below ran OpenClaw source throughtsx, wrote an actual private JSONL transcript on disk, and invoked the real transcript-reader-backedresolveCompletionFromCurrentRunTranscripthelper outside Vitest/CI.Exact steps or command run after this patch:
pnpm exec tsx -e '...'script that created a private child transcript containing one stale copied assistant result beforestartedAtand one current assistant turn withstopReason: "stop", then calledresolveCompletionFromCurrentRunTranscriptagainst that file.node scripts/run-vitest.mjs src/agents/subagent-session-reconciliation.test.ts src/agents/subagent-registry.test.ts.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental false.pnpm exec oxfmt --check --threads=1 src/agents/subagent-session-reconciliation.ts src/agents/subagent-registry.ts src/agents/subagent-session-reconciliation.test.ts src/agents/subagent-registry.test.ts.node scripts/run-oxlint.mjs src/agents/subagent-session-reconciliation.ts src/agents/subagent-registry.ts src/agents/subagent-session-reconciliation.test.ts src/agents/subagent-registry.test.ts.Evidence after fix:
Copied terminal output from the local OpenClaw live proof command:
Observed result after fix:
The real transcript reader recovered
status=okfrom the current private terminal turn, ignored the stale copied pre-run output, and used the terminal turn timestamp instead of the fallback lost-context time. The focused registry regression also completes the stale active run asokand preservesprivate transcript resultinstead of emitting the lost-context error.What was not tested:
No live Agent Teams UI/gateway conversation was run manually. The live proof covers the private transcript recovery boundary directly, and the focused registry test covers the sweeper path with the session store still reporting
status: running.Validation
node scripts/run-vitest.mjs src/agents/subagent-session-reconciliation.test.ts src/agents/subagent-registry.test.ts-> 2 files passed, 71 tests passed.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental false-> exited 0.pnpm exec oxfmt --check --threads=1 ...-> all matched files use the correct format.node scripts/run-oxlint.mjs ...-> exited 0.