Repository navigation
fix: spawned child prompt omits staged attachment file paths - #123676
Conversation
sessions_spawn already writes named files, but the child system prompt only named the staging directory. File-consuming tools then failed with "Local media path is not a file". Closes openclaw#123583
|
🦞👀 Pull request received. I will update this pull request when review starts. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37e4c69a49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 5:24 AM ET / 09:24 UTC. ClawSweeper reviewWhat this changesThe PR makes native Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessThe patch correctly repairs the native spawned-agent path handoff, but merging it intentionally makes oversized otherwise-valid attachment batches fail; that compatibility change needs maintainer acceptance before merge. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits together
flowchart LR
A[Parent agent calls sessions spawn] --> B[Attachment staging]
B --> C[Validate names and render bounded paths]
C --> D[Child system prompt]
D --> E[Gateway agent request]
E --> F[Media tool reads staged file]
Decision needed
Why: The cap prevents unbounded model-visible context but changes behavior for existing callers that can submit up to 50 long filenames, so code review cannot choose that compatibility tradeoff alone. Before merge
Agent review detailsSecurityNone. PR surfaceSource +33, Tests +182. Total +215 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Accept the bounded exact-path list as the native attachment contract only if maintainers accept the explicit oversized-batch failure; keep the materializer as the single producer of both staged files and prompt guidance. Do we have a high-confidence way to reproduce the issue? Yes—source reproducible: current main emits only the attachment directory, while the media loader resolves the supplied relative path and requires a file; the PR also supplies an after-fix real-flow record. Is this the best way to solve the issue? Yes for the defect: the materializer is the only owner that knows the finalized staged filenames, so emitting exact bounded paths there is preferable to a directory-to-file fallback in consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2ebe24e9b258. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (11 earlier review cycles; latest 8 shown)
|
Reject prompt-separator names with the shared prompt-control owner, and fail batches whose rendered path list exceeds a 4096-char hard cap. Keep listing exact staged file paths so file tools do not receive a directory.
|
Addressed the two code blockers on this head:
Evidence in the PR body now includes a real spawn/materialize/launch prompt plus @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Reuse sanitizeForPromptLiteral so U+202E and remaining C1 controls fail before raw path rendering. Keep the 4096-char path-list cap.
|
Addressed the remaining P1 on this head:
Live Gateway child-run proof is still blocked here (no packaged dist, no CLI, no model keys). I did not invent a live trace and I am not calling @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Live after-fix Gateway child-run is now in Evidence. Real local Gateway process, real |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ted data
ACP only forwards {mediaType,data} and must still accept format-character filenames. Native staging keeps the Cc/Cf check and 4096 path-list cap, and renders staged paths through wrapUntrustedPromptDataBlock.
|
Addressed both P1s on this head (
Live Gateway proof rerun on this head. Real PR scope is sessions_spawn snapshot-by-value staging only. Inbound channel attachment resolution is unchanged. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…ve names Measure the wrapped untrusted path block, not raw paths, and reject oversize lists instead of truncating. Native names containing <, >, or & are rejected so the prompted path matches the staged file. ACP still accepts those names because it never renders them.
|
Addressed the two wrap blockers on
Live Gateway proof rerun on this head. Real PR body no longer uses @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Native spawn still rejects angle-bracket names that wrapUntrustedPromptDataBlock rewrites. Ampersand names stay staged and prompted as-is. Invalid-name tool errors no longer echo raw Cc/Cf. The optional mountPath hint starts on the line after the untrusted path block.
|
Addressed the three leftover findings on
Live Gateway proof rerun on this head. Real PR body still does not use @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Merged via squash.
|
…w#123676) * fix: list staged attachment file paths in the child spawn prompt sessions_spawn already writes named files, but the child system prompt only named the staging directory. File-consuming tools then failed with "Local media path is not a file". Closes openclaw#123583 * fix: bound and sanitize staged attachment paths in the child prompt Reject prompt-separator names with the shared prompt-control owner, and fail batches whose rendered path list exceeds a 4096-char hard cap. Keep listing exact staged file paths so file tools do not receive a directory. * fix: reject all Cc/Cf attachment names via shared prompt sanitizer Reuse sanitizeForPromptLiteral so U+202E and remaining C1 controls fail before raw path rendering. Keep the 4096-char path-list cap. * fix: scope prompt-safe names to native spawn and wrap paths as untrusted data ACP only forwards {mediaType,data} and must still accept format-character filenames. Native staging keeps the Cc/Cf check and 4096 path-list cap, and renders staged paths through wrapUntrustedPromptDataBlock. * fix: cap rendered attachment prompt size and reject non-lossless native names Measure the wrapped untrusted path block, not raw paths, and reject oversize lists instead of truncating. Native names containing <, >, or & are rejected so the prompted path matches the staged file. ACP still accepts those names because it never renders them. * fix: keep ampersand names, hide Cc/Cf in errors, separate mount hint Native spawn still rejects angle-bracket names that wrapUntrustedPromptDataBlock rewrites. Ampersand names stay staged and prompted as-is. Invalid-name tool errors no longer echo raw Cc/Cf. The optional mountPath hint starts on the line after the untrusted path block. * fix(agents): tighten spawned attachment path prompt --------- Co-authored-by: felirami <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Related to #123583. Native
sessions_spawnsnapshot staging only; inbound channel attachment resolution is unchanged.What Problem This Solves
A native child received only the attachment staging directory. File-only tools then used that directory and returned “not a file” even though the requested file had already been staged inside it.
Why This Change Was Made
The staging owner now emits every validated workspace-relative file path as bounded
untrusted-textin the child system prompt. The obsolete bare-directory instruction is removed, so the prompt has one canonical tool argument.Prompt integrity remains at the producer boundary:
</>, which the prompt wrapper cannot preserve losslessly.attachAs.mountPathstays outside the untrusted block.Exact paths intentionally repeat the UUID directory. At
maxFiles=50, measured render cost is 21.1µs/spawn and roughly 1.4K–2.5K tokens. This cost avoids another model round trip and avoids asking the model to reconstruct file-tool arguments.No directory-to-file fallback was added.
User Impact
Delegated native agents receive the exact staged file path accepted by image/media tools. Unsafe or over-budget path lists fail visibly at spawn. ACP behavior is unchanged.
Evidence
Exact pushed head:
a4040009698d300622536f59b9ba5de031b28c4f.Owner path:
spawnSubagentDirect→materializeSubagentAttachments→ bounded path block → child Gatewayagentrequest.Regression test:
src/agents/subagents/spawn/subagent-spawn.attachments.test.tsproves the staged regular file and exact child prompt path, while rejecting the old bare-directory wording. It fails on pre-fix main because the exact file path is absent.Codex contract checked at
openai/codex@4642370542739d5dd080b0c87a9de06a6435d3db:codex-rs/core/src/tools/handlers/view_image.rs:143-168resolves the supplied path against cwd, checks metadata, and rejects directories before reading bytes;codex-rs/core/tests/suite/view_image.rs:1118-1182covers that directory failure.Before-fix real Telegram proof on main: the child reported
CHILD_DIRECTORY_ONLY_123676; the captured prompt contained only.openclaw/attachments/{uuid}and omittedreceipt.jpg.Local proof on the exact head:
Distill removed the test-only production export, duplicate cap case, cross-owner media assertions, repeated prompt extraction, and obsolete directory prompt. Greybeard found no CPU/allocation issue and corrected the prompt-budget claim.
LOC versus current-main merge base: production +61/−28; tests +182/−0. Positive production LOC is the exact-path capability, bounded prompt owner, and shared control-character predicate; no fallback or compatibility path was added.
Final gates on the same exact head:
gpt-5.6-terra, high): patch correct; 0 findings; security cleared with 0 concerns; no maintainer decision; 0 Rank-up moves.spawn-attachment-path): sentTest native child attachment staging.(recorded Bot API message 14). Parent Code Mode calledopenclaw:core:sessions_spawnwith inlinereceipt.pngand returned accepted. The child prompt contained.openclaw/attachments/{uuid}/receipt.png; childview_imageused that exact path and returnedinput_imagecontent. Telegram observedSPAWN_ATTACHMENT_ACCEPTED(message 1609) then the child completionSPAWN_ATTACHMENT_PATH_OK(message 1610). NoLocal media path is not a fileappeared. Recorded timeline: 4 messages, 2 typing events, 1 cleanup deletion. Evidence:/tmp/telegram-e2e-pr123676-final.jT2Mv5/spawn-attachment-paths/.