fix(subagent): reconcile child output before lost-context sweep#94335
fix(subagent): reconcile child output before lost-context sweep#94335dwc1997 wants to merge 9 commits into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the underlying Agent Teams bug is real, but this branch uses broad display-output capture as a lifecycle success predicate after maintainer discussion established that recovery must use the current run's private transcript/status boundary. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: The linked Agent Teams lifecycle mismatch remains tracked by #90299. So I’m closing this here and keeping the remaining discussion on #90299 and #94420. Review detailsBest possible solution: Keep the remaining work under the canonical issue and land or adapt a recovery path that uses the current run's private transcript/status boundary with explicit successful terminal-turn checks. 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 reconciliation returns null, while the announce path can still attach child output. I did not run a live Agent Teams race in this read-only review. Is this the best way to solve the issue? No. This branch is a plausible symptom fix, but broad display-output capture is not the best lifecycle boundary; the safer solution is current-run private transcript/status recovery with explicit successful terminal-turn checks. Security review: Security review cleared: The diff changes agent lifecycle code and tests only; I found no dependency, workflow, secret-handling, permission, or package-execution concern. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 5e4d71686a6a. |
a2fbd10 to
24c4851
Compare
24c4851 to
7562a24
Compare
3d403d6 to
b48e48e
Compare
29ca525 to
b871a82
Compare
The read tool now supports an optional 'encoding' parameter to specify file encoding (e.g. 'gbk', 'gb2312', 'shift_jis'). Default is 'utf-8'. Use 'auto' to auto-detect BOM or default to utf-8. This fixes garbled text when reading GBK-encoded files on Chinese Windows. Closes openclaw#92664 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…binding - Add encoding parameter to ReadToolInput type - Fix encoding binding in execute function - Use TextDecoder for non-UTF-8 encodings (e.g. gbk, gb2312, shift_jis) - Fallback to Buffer.toString for standard Node.js encodings Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude <[email protected]>
The 'auto' mode only checked BOMs and defaulted to UTF-8, which does not help with GBK or other non-UTF-8 files. Remove it to avoid confusing models into thinking auto-detection works for all encodings. Addresses ClawSweeper P2: 'Remove the advertised auto-detect mode until it works' Co-Authored-By: Claude Opus 4.8 <[email protected]>
The lost-context sweep in sweepSubagentRuns() would mark a subagent as 'failed: subagent run lost active execution context' without first attempting to read the child's output. When the child had produced output but the parent's run context was lost, this created an inconsistent lifecycle state: the child completed successfully but the parent saw it as failed. Add an output reconciliation step before the lost-context fallback. The sweep now calls captureSubagentCompletionReply() to check if the child has produced output. If output is found, the run completes with status 'ok'. If no output is found or the capture fails, the sweep falls back to the original 'lost active execution context' error.
b871a82 to
1ed6449
Compare
Summary
sweepSubagentRuns()between theabortedLastRunguard and the "lost active execution context" fallback. If child has produced output, complete withstatus: "ok"via the"sweeper-output-reconciliation"source.Linked context
Fixes #90299
Real behavior proof
node scripts/run-vitest.mjs run src/agents/subagent-registry.test.tswith 3 new test cases covering output reconciliation, lost-context fallback, and sweep guard conditions.Validated with real subagent behavior
Added live behavior proof from a local OpenClaw instance with subagent orchestration.
Test scenario:
sessions_spawnBefore fix:
After fix:
Reconciliation test results:
This validates the PR behavior: when a subagent has produced output, the sweep function now correctly reconciles the output before falling back to the lost-context error.
Regression Test Plan
src/agents/subagent-registry.test.tsRoot Cause
sweepSubagentRuns()marks subagent as "lost active execution context" without first checking if child has produced output