Repository navigation
Conversation
…site formatChildResultData was the last of three identical Child result/Subagent result wrapPromptDataBlock call sites without maxEscapedChars/truncationMarker. wrapPromptDataBlockWithTag truncates to maxChars before escaping <>, so an angle-bracket-dense child result (code/XML/HTML output) could still expand the escaped block up to ~4x the intended 512-char budget. Bring this site in line with the other two, already fixed by carrier PR openclaw#119731 (agent-steering-queue.ts, internal-events.ts).
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 24, 2026, 2:02 AM ET / 06:02 UTC. ClawSweeper reviewWhat this changesThis PR moves child-result truncation into the shared prompt sanitizer’s escaped-output budget and adds regression coverage for angle-bracket-heavy and control-character-prefixed subagent output. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked until stronger real behavior proof is added - 3 items remain The patch is correct and follows the canonical escaped-budget pattern, but its terminal proof names an earlier head while the current head also changes sanitization/truncation order; refresh after-fix proof on the current head before merge. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherSubagent completion text is formatted into a prompt-data block for the parent agent. The shared sanitizer removes unsafe controls, escapes angle brackets, and bounds the resulting model-visible text before the parent prompt is assembled. flowchart LR
A[Subagent completion] --> B[Child-result formatter]
B --> C[Prompt sanitizer]
C --> D[Escaped-output budget]
D --> E[Parent-agent prompt]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -7, Tests +32. Total +25 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the sanitizer-owned escaped cap and publish a redacted current-head terminal capture demonstrating both the escaped-output bound and preservation of useful text after unsafe controls are removed. Do we have a high-confidence way to reproduce the issue? Yes—source establishes a focused path: feed angle-bracket-dense completion text through buildChildCompletionFindings on current main, where raw truncation precedes escaping and can exceed the 512-character escaped budget. Is this the best way to solve the issue? Yes—the shared sanitizer is the narrowest owner because it sanitizes before calculating the escaped budget, matching the current sibling child-result projection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c43166a9208c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Preserve contributor ancestry and current subagent completion behavior while delegating escaped child-result budgets to the canonical prompt sanitizer. Remove the obsolete raw pre-truncation so sanitized control characters cannot discard useful completion text. Co-authored-by: masatohoshino <[email protected]>
|
Maintainer verification for exact head The root cause was producer-side truncation before prompt sanitization and HTML escaping. The current owner now delegates directly to the shared sanitizer, removing the obsolete raw truncation and enforcing the existing 512-character escaped budget with a visible marker. Production delta: +3/-10 (net -7); both sibling projections already use the same contract. Direct imports of the actual current-main and exact-head {
"before": {
"head": "b0d6fff9f951bf709e37bae396628446f01cb2cd",
"angleDense": { "escapedChars": 1973, "within512": false, "visibleMarker": true },
"removableControlPrefix": { "preservesUsefulResult": false, "falselyTruncated": true },
"ordinaryResultPreserved": true,
"aggregate": { "chars": 2382, "within4096": true, "preservesActionableFailure": true }
},
"after": {
"head": "04b6d93c5573d533997cffd427d5fdb18fb09cb7",
"angleDense": { "escapedChars": 509, "within512": true, "visibleMarker": true },
"removableControlPrefix": { "preservesUsefulResult": true, "falselyTruncated": false },
"ordinaryResultPreserved": true,
"aggregate": { "chars": 4087, "within4096": true, "preservesActionableFailure": true }
}
}The new 700-control-character regression also failed against pre-fix production code for the intended reason (the real completion text disappeared), then passed after the canonical owner repair. Coverage includes angle-heavy escaping, UTF-16/entity integrity, control-first sanitization, the 4,096-character aggregate, actionable-failure priority, ordinary output, both sibling projections, and the current pending-error timeout behavior from #125357. Focused formatting, fresh isolated structured review, independent review, and native This directly addresses the latest ClawSweeper rank-up move with current-head evidence for both escaped output and removable control prefixes. |
|
Merged via squash.
|
…site (openclaw#124171) formatChildResultData was the last of three identical Child result/Subagent result wrapPromptDataBlock call sites without maxEscapedChars/truncationMarker. wrapPromptDataBlockWithTag truncates to maxChars before escaping <>, so an angle-bracket-dense child result (code/XML/HTML output) could still expand the escaped block up to ~4x the intended 512-char budget. Bring this site in line with the other two, already fixed by carrier PR openclaw#119731 (agent-steering-queue.ts, internal-events.ts). Co-authored-by: Peter Steinberger <[email protected]>
…49223) Most added lines cover regressions and move formatting beside exact-run reads; archived histories now stream through the existing storage worker. ## What Problem This Solves Completed child answers could lose required fields before their parent read them. Closes #138555. Reported by @aleps001. ## Why This Change Was Made The parent receives the complete visible final answer from the selected child run, including its registered deletion archive. Descendant results remain input to the child's synthesis. A persisted final message-tool reply remains authoritative after a later same-run `NO_REPLY`. The shared 4,096-character terminal snapshot stays bounded for lifecycle and durable evidence. This state has one writer. Stored shapes, retention, and cleanup ownership are unchanged. Complete answers use more parent context. The owner's September 15 decision replaces projection limits from #119731 and #124171 while preserving escaping, metadata limits, stable order, and whole-item queue delivery. ## User Impact Waiting and returning parents receive complete answers while the exact-run transcript remains retained. If archive pruning has removed it, that completion uses its capped published result with a `truncated-by-retention` marker. Healthy siblings and the parent continue. Public and private nested children forward their own conclusions. Large archived histories no longer require one decoded string on the Gateway thread. ## Evidence An 8,638-character answer lost its required tail on the baseline. Served Chat now delivers all 11,758 escaped characters to the resumed parent and retains them after child deletion. A public nested case delivers the middle child's distinct conclusion. Earlier aggregate, nested-yield, and ordinary completion captures also pass. The registered `maybeWakeRequesterAfterAllChildrenSettled` regression uses capped visible terminal evidence and a complete >4,096-character exact-run transcript with a trailing same-run `NO_REPLY` row. It fails on the original implementation and passes here. The producer contract is covered by [run-entry-terminal.ts](https://github.com/openclaw/openclaw/blob/a97d75a928ed8f5a9f70ee7977da8e767d03acea/src/agents/embedded-agent-runner/run-entry-terminal.ts#L153) and [run-entry.test.ts:928–931](https://github.com/openclaw/openclaw/blob/a97d75a928ed8f5a9f70ee7977da8e767d03acea/src/agents/embedded-agent-runner/run-entry.test.ts#L928). Native children cannot call `message` under the existing hard deny, so that live cell is excluded. A returning parent can receive a kept child’s answer and then continue after that child starts a valid follow-up. The registered tool-result continuation fails on `a97d75a9` and passes here. Initial source rejection, parent cancellation, and pre-prompt compaction remain covered. The registered `attempt-prompt-submit.retention.test.ts` regression publishes and prunes a child archive, then consumes deferred results through the real parent session (`node scripts/run-vitest.mjs run src/agents/embedded-agent-runner/run/attempt-prompt-submit.retention.test.ts`). It fails before the correction and passes with the marked retained result, the healthy sibling’s complete answer, cleared delivery leases, and a successful next parent turn. [Scenario and captures](https://gist.github.com/obviyus/cce960c04dafd949c21141686af3696e). | Before | After | | --- | --- | |  |  | ## Compatibility No public API, schema, retention, or retrieval feature changes. Archive hash, header, session, and owner checks remain. The existing worker scans a 536.9 MB decoded archive whose previous whole-string decoder failed. ## Consumers Requester settlement, deferred turns, nested announcements, event projections, and retained parent history use the complete result, or the marked retained snapshot when its exact answer is unavailable. ## Invalidation Run, producer, generation, batch, requester, and lease authority are rechecked after reads and before delivery. Failed prompt assembly releases its lease. Deferred source validation ends after the first foreground stream is acquired; parent abort checks remain active. ## Tests The retained complete-result proof covers 374 tests across 15 files, including the format suite. The retained owner and sibling proof covers 379 passing tests across 17 files on a fresh merge with main, including the format and retention regressions. Four additional consumer suites update their explicit session-accessor mocks for the exact-run reader; their 286 tests pass on a fresh merge with main, with behavior assertions unchanged. Registered settlement, deferred-input, and continuation regressions fail on their original source. Type-aware preflight, structural checks, and test registration pass. Production growth is 422 lines: result +241; output −130; queue +27; registry API +8; prompt build/phase/submit +6/+1/+16; wake/message −44/+54; announce +13; events −16; archive read/session/types/dispatch/worker/history +183/+6/+14/+20/+9/+11; history export +3. Growth accepted under the owner's standing acceptance (2026-09-15). Co-authored-by: Ayaan Zaidi <[email protected]>
…enclaw#149223) Most added lines cover regressions and move formatting beside exact-run reads; archived histories now stream through the existing storage worker. ## What Problem This Solves Completed child answers could lose required fields before their parent read them. Closes openclaw#138555. Reported by @aleps001. ## Why This Change Was Made The parent receives the complete visible final answer from the selected child run, including its registered deletion archive. Descendant results remain input to the child's synthesis. A persisted final message-tool reply remains authoritative after a later same-run `NO_REPLY`. The shared 4,096-character terminal snapshot stays bounded for lifecycle and durable evidence. This state has one writer. Stored shapes, retention, and cleanup ownership are unchanged. Complete answers use more parent context. The owner's September 15 decision replaces projection limits from openclaw#119731 and openclaw#124171 while preserving escaping, metadata limits, stable order, and whole-item queue delivery. ## User Impact Waiting and returning parents receive complete answers while the exact-run transcript remains retained. If archive pruning has removed it, that completion uses its capped published result with a `truncated-by-retention` marker. Healthy siblings and the parent continue. Public and private nested children forward their own conclusions. Large archived histories no longer require one decoded string on the Gateway thread. ## Evidence An 8,638-character answer lost its required tail on the baseline. Served Chat now delivers all 11,758 escaped characters to the resumed parent and retains them after child deletion. A public nested case delivers the middle child's distinct conclusion. Earlier aggregate, nested-yield, and ordinary completion captures also pass. The registered `maybeWakeRequesterAfterAllChildrenSettled` regression uses capped visible terminal evidence and a complete >4,096-character exact-run transcript with a trailing same-run `NO_REPLY` row. It fails on the original implementation and passes here. The producer contract is covered by [run-entry-terminal.ts](https://github.com/openclaw/openclaw/blob/a97d75a928ed8f5a9f70ee7977da8e767d03acea/src/agents/embedded-agent-runner/run-entry-terminal.ts#L153) and [run-entry.test.ts:928–931](https://github.com/openclaw/openclaw/blob/a97d75a928ed8f5a9f70ee7977da8e767d03acea/src/agents/embedded-agent-runner/run-entry.test.ts#L928). Native children cannot call `message` under the existing hard deny, so that live cell is excluded. A returning parent can receive a kept child’s answer and then continue after that child starts a valid follow-up. The registered tool-result continuation fails on `a97d75a9` and passes here. Initial source rejection, parent cancellation, and pre-prompt compaction remain covered. The registered `attempt-prompt-submit.retention.test.ts` regression publishes and prunes a child archive, then consumes deferred results through the real parent session (`node scripts/run-vitest.mjs run src/agents/embedded-agent-runner/run/attempt-prompt-submit.retention.test.ts`). It fails before the correction and passes with the marked retained result, the healthy sibling’s complete answer, cleared delivery leases, and a successful next parent turn. [Scenario and captures](https://gist.github.com/obviyus/cce960c04dafd949c21141686af3696e). | Before | After | | --- | --- | |  |  | ## Compatibility No public API, schema, retention, or retrieval feature changes. Archive hash, header, session, and owner checks remain. The existing worker scans a 536.9 MB decoded archive whose previous whole-string decoder failed. ## Consumers Requester settlement, deferred turns, nested announcements, event projections, and retained parent history use the complete result, or the marked retained snapshot when its exact answer is unavailable. ## Invalidation Run, producer, generation, batch, requester, and lease authority are rechecked after reads and before delivery. Failed prompt assembly releases its lease. Deferred source validation ends after the first foreground stream is acquired; parent abort checks remain active. ## Tests The retained complete-result proof covers 374 tests across 15 files, including the format suite. The retained owner and sibling proof covers 379 passing tests across 17 files on a fresh merge with main, including the format and retention regressions. Four additional consumer suites update their explicit session-accessor mocks for the exact-run reader; their 286 tests pass on a fresh merge with main, with behavior assertions unchanged. Registered settlement, deferred-input, and continuation regressions fail on their original source. Type-aware preflight, structural checks, and test registration pass. Production growth is 422 lines: result +241; output −130; queue +27; registry API +8; prompt build/phase/submit +6/+1/+16; wake/message −44/+54; announce +13; events −16; archive read/session/types/dispatch/worker/history +183/+6/+14/+20/+9/+11; history export +3. Growth accepted under the owner's standing acceptance (2026-09-15). Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes an issue where a subagent's completion result containing many
</>characters (e.g. code, XML, or HTML output — no adversarial input required)
could produce a "Child result" prompt block up to ~4x the intended 512-char
budget when surfaced to the parent agent via
formatChildResultData(
src/agents/subagents/announce/subagent-announce-output.ts).Why This Change Was Made
wrapPromptDataBlock(src/agents/sanitize-for-prompt.ts) delegates to itsinternal
wrapPromptDataBlockWithTag, which truncates text tomaxCharsbefore escaping
</>to</>, then only enforces a second,post-escape bound (
maxEscapedChars) when the caller supplies it. Of thethree call sites that use
wrapPromptDataBlockfor "Child result"/"Subagentresult" data
(
src/agents/agent-steering-queue.ts,src/agents/internal-events.ts,src/agents/subagents/announce/subagent-announce-output.ts), the first twoalready pass both params — added by
#119731
("fix(agents): bound task-completion result prompts", merged
2026-08-12), which established this exact pattern and its own test
coverage (
src/agents/agent-steering-queue.test.ts,src/agents/internal-events.test.ts) forthe same expansion. The third (
formatChildResultData) was the only sitestill missing them.
The Fix
This PR fixes the missing bound by adding
maxEscapedCharsandtruncationMarkerto thewrapPromptDataBlockcall insideformatChildResultData, reusing the sameMAX_CHILD_COMPLETION_RESULT_CHARS/
CHILD_RESULT_TRUNCATION_NOTICEconstants the function already declaresfor its pre-escape truncation — matching the exact param shape #119731
applied to the other two call sites of the same helper (production-code
diff: +2/-0 in one file; test-file diff is separate, see Evidence).
Non-Scope
agent-steering-queue.ts/internal-events.ts— already fixed by fix(agents): bound task-completion result prompts #119731wrapPromptDataBlockWithTagitself (src/agents/sanitize-for-prompt.ts) —its contract is correct and unchanged
truncateUtf16SafeinsideformatChildResultData— unrelated to the escape-budget defect, left as-is(only the two new
wrapPromptDataBlockparams are added)CHANGELOG.mdUser Impact
Subagent completion results embedded in a parent prompt now stay within
their declared context budget even when the child's output is dense in
angle brackets, matching the guarantee #119731 already gives the other two
call sites of the same helper. No behavior change for output whose escaped
form already stays under the 512-char budget; output with enough
</>characters to have exceeded that budget after escaping is now truncated with
a visible marker instead of being passed through oversized.
Evidence
Real behavior proof
Behavior addressed:
formatChildResultDataembedding a child result whosetext is dense in
<characters (e.g.`${"<".repeat(6_000)}-tail`) intothe parent-visible "Child result" prompt block.
Real environment tested: Linux x86_64, node v24.18.0, patch at commit
163f511b120c318c569b26ea6859933ad3dfb1ea(current PR head).Exact steps or command run after this patch:
Before (pre-fix):
Evidence after fix:
Observed result after fix:
blockLengthis the length of the full escaped<prompt-data>...</prompt-data>block (escaped content plus truncationmarker, if any) for the per-child 512-char budget — separate from the
unrelated 4096-char aggregate budget across all children, discussed below.
The angle-dense case's
blockLengthdrops from 1973 to 509 and ends withthe truncation marker before and after — pre-fix, only the earlier
maxChars: 512pre-escape truncation was active, and escaping thenre-expanded that already-truncated text past 512; post-fix, the added
maxEscapedChars: 512re-truncates the escaped output itself to the same512-char budget. The plain-text control case is unchanged (33 chars, no
marker, both sides), confirming the fix is scoped to the escape-expansion
defect and does not alter normal output.
What was not tested: this harness drives
buildChildCompletionFindingsdirectly (the only caller of
formatChildResultData), not a live gatewaysession end-to-end. The separate 4096-char aggregate budget across
multiple children (
MAX_CHILD_COMPLETION_FINDINGS_CHARS) is coveredinstead by
src/agents/subagents/announce/subagent-announce-output.test.ts'sbuildChildCompletionFindingsdescribe block, whose invariant is that anactionable (failed) child's finding is always retained even when successes
must be dropped to fit the budget. Two of its pre-existing tests exercising
that invariant (
retains a later actionable failure when earlier children exceed the remaining budget,prioritizes an oversized failed completion over a competing oversized success) needed their oversized-child countsincreased — not their assertions weakened — because bounding the per-item
escape budget changed how many oversized children now fit inside the
aggregate cap (empirically measured: it now takes 6-7 oversized children to
reach the cap, not 1-2). Both were re-verified to fail against pre-fix
source for the same reason before the fix was restored.
Focused tests
46 passed (46) in
src/agents/subagents/announce/subagent-announce-output.test.ts, includingone new regression test (
bounds a single child result's escaped output with a visible marker) that fails against pre-fix source for the intendedreason.
Precheck
ocw review precheck subagent-child-result-escape-budget— PASS (codexreview: 0 findings).