Repository navigation
fix(agents): dir_fetch attachments are dropped while the tool says they were sent - #144609
igs-rogenlo wants to merge 1 commit into
Conversation
`dir_fetch` builds `details.media.mediaUrls` from local gateway paths and returns a summary telling the model the channel attaches the first 25. Nothing attaches them. `filterToolResultMediaUrls` reduces an untrusted tool's media to `http(s)` entries, `dir_fetch` emits filesystem paths, so the list empties on every call and the handler returns before `queuePendingToolMedia`. The tool text has already been emitted by then, so the model relays a statement that is never true, with no warning and nothing logged. The mechanism for this already exists on both ends and nothing connects them. `setManifestPluginToolMeta` marks a bundled plugin tool `trustedLocalMedia` when the manifest's `contracts.tools` declares it — file-transfer declares `dir_fetch` — and `filterToolResultMediaUrls` already accepts a run-local `trustedLocalMediaToolNames` set that grants exactly this. No production caller ever populates it; only the e2e harness does. So the metadata is computed, the consumer is wired, and the value in between is always `undefined`. Collect the set where the run's tool surface is already assembled and thread it alongside `coreBuiltinToolNames` to the subscription. `collectTrustedLocalMediaToolNames` takes names from two sources and no others: the core allowlist, matched exactly as `isCoreToolResultMediaTrustedName` matches it today, so every tool trusted before this change is still trusted; and tools whose plugin metadata carries the bundled contract's `trustedLocalMedia` mark. Forwarding the whole builtin set would have granted local-media trust to every registered tool, including MCP tools, which is the boundary this set exists to hold. `TRUSTED_TOOL_RESULT_MEDIA` is untouched. openclaw#101434 moved this project away from widening that Set and openclaw#120718 ruled on the delivery mechanism; neither is reopened here. Alias behaviour is deliberately unchanged. Supplying the set activates `filterToolResultMediaUrls`'s exact-raw-name branch, and the set is built so that every name trusted today passes it. Tightening that gate for core names would change behaviour for `bash`, `cron` and `apply-patch` and belongs in its own change. Tests: the collector's two sources and its exclusion of unmarked plugin tools; the defect itself at the filter (`dir_fetch` local paths are dropped with no set, kept with one) and at the delivery boundary (`pendingToolMediaUrls` empty versus queued, with the tool text emitted either way); the run surface exposing the set from contract metadata; and core tools staying trusted once a run supplies its exact set. Fixes openclaw#138383
|
🦞👀 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 real behavior proof before merge. Reviewed September 10, 2026, 11:11 PM ET / September 11, 2026, 03:11 UTC. ClawSweeper reviewWhat this changesThe PR carries bundled tools’ local-media trust metadata into the embedded agent’s reply pipeline so fetched files can become channel attachments. Merge readiness⛔ Blocked before merge - 2 items remain Keep open: the attachment-filtering defect remains on current main and v2026.9.3. The patch is focused, but delivery proof is still limited to tests; the overlapping open repair is not yet a proven replacement. Priority: P2 Review scores
Verification
How this fits togetherThe embedded agent collects results from tools, filters their attachment paths, and queues permitted media for the assistant’s reply. File Transfer supplies files fetched from paired nodes to this pipeline. flowchart LR
A[Paired node files] --> B[File Transfer tools]
C[Registered tool metadata] --> D[Run-local trusted names]
B --> E[Tool-result media filter]
D --> E
E --> F[Pending reply attachments]
F --> G[Channel delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +46, Tests +137. Total +183 across 7 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Use the existing metadata-driven reply queue for bundled-tool attachments while preserving private-media rejection and the host’s channel and filesystem policies. Do we have a high-confidence way to reproduce the issue? Yes, at source level: dir_fetch returns local media paths, but current main supplies no trusted-name set and filters those paths out before queuing. A failing real channel run was not executed. Is this the best way to solve the issue? Yes, for the embedded runtime: connecting the existing producer metadata to its existing consumer is a narrow repair and preserves normal reply selection and delivery ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e62272f04a3e. LabelsLabel 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
|
|
Closing this in favour of #138427, which is the same repair, a week older, and broader. I opened this without checking for an existing PR against #138383 — the issue's automatic implementation had stopped before completion and I took that to mean the fix was unowned. It was not. The review's root-cause cluster is what surfaced #138427, and reading it through, the overlap is essentially total:
Both are blocked on the same thing, which is the real bottleneck rather than the code: delivery proof through a final reply. Splitting reviewer attention across two implementations of one fix does not help that. One correction to this PR's description, for the record. It quotes Offered to whoever carries #138427 forward, if useful — the tests on this branch are MIT-licensed to the project like any contribution here and can be lifted verbatim:
Happy to help produce the end-to-end proof if the author or a maintainer wants a hand; it needs a paired node and a channel on a clean build, which is the part neither PR has supplied yet. |
…138427) Fixes #138383. ## What Problem This Solves `dir_fetch` saved files fetched from a paired node, but the embedded runner and Codex bridge discarded their local attachment paths. The final reply contained no files. The earlier misleading directory summary was already removed by #138542. ## Why This Change Was Made Carry the existing concrete tool metadata into both reply pipelines. Keep core tool behavior, exact registered names, filesystem grants, private-media rejection, and MCP filtering. An unmarked plugin cannot gain trust by reusing a core name or setting a public result flag; the special TTS path uses the existing private core result provenance and its original URLs. Complete delivery through the existing host-selected path: suppress final text already sent as the same assistant message's file caption, append UI media supplements without recreating runtime-owned text, and read image downloads through the existing authenticated media route without relaxing the browser policy. ## User Impact Permitted files arrive with the final reply, up to the existing 25-file selection limit. The complete saved inventory remains available. No schema, configuration option, protocol, dependency, or direct adapter-send path is added. ## Evidence - Real embedded Control UI and Telegram Test Server baseline: successful paired-node fetch, zero final attachments. - Real Codex app-server baseline: 26 fetched files, zero final attachments. - Repaired native Codex flow: one caption and 25 final attachments from 26 files; image and document downloads match the source bytes, and attachments survive history refresh. - Real unmarked plugin calls succeed while local attachments remain blocked. An ungranted directory returns `POLICY_DENIED`. Core aliases, HTTP media, MCP provenance, private results, and TTS provenance also have focused owner-boundary coverage. - Telegram delivers one captioned photo and one document; the document matches the original bytes. Owned test messages and credential leases were cleaned up. - Focused integration, delivery, trust, and browser-policy checks plus the matching runtime/UI build passed on an isolated native runner. Independent source-blind acceptance passed both native and embedded public flows: final attachments, 25-file selection, all 26 saved-file hashes, image/document downloads, history refresh, and actual unmarked-plugin rejection. Baseline and Telegram results above are separate retained proof. Exact-head hosted checks and final review are required before landing. This preserves the implementation from @NianJiuZst and includes useful regression coverage offered by @igs-rogenlo in #144609. The two-runtime scope is retained; the older wording-only alternative is not reopened. Co-authored-by: igs-rogenlo <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#138427) Fixes openclaw#138383. ## What Problem This Solves `dir_fetch` saved files fetched from a paired node, but the embedded runner and Codex bridge discarded their local attachment paths. The final reply contained no files. The earlier misleading directory summary was already removed by openclaw#138542. ## Why This Change Was Made Carry the existing concrete tool metadata into both reply pipelines. Keep core tool behavior, exact registered names, filesystem grants, private-media rejection, and MCP filtering. An unmarked plugin cannot gain trust by reusing a core name or setting a public result flag; the special TTS path uses the existing private core result provenance and its original URLs. Complete delivery through the existing host-selected path: suppress final text already sent as the same assistant message's file caption, append UI media supplements without recreating runtime-owned text, and read image downloads through the existing authenticated media route without relaxing the browser policy. ## User Impact Permitted files arrive with the final reply, up to the existing 25-file selection limit. The complete saved inventory remains available. No schema, configuration option, protocol, dependency, or direct adapter-send path is added. ## Evidence - Real embedded Control UI and Telegram Test Server baseline: successful paired-node fetch, zero final attachments. - Real Codex app-server baseline: 26 fetched files, zero final attachments. - Repaired native Codex flow: one caption and 25 final attachments from 26 files; image and document downloads match the source bytes, and attachments survive history refresh. - Real unmarked plugin calls succeed while local attachments remain blocked. An ungranted directory returns `POLICY_DENIED`. Core aliases, HTTP media, MCP provenance, private results, and TTS provenance also have focused owner-boundary coverage. - Telegram delivers one captioned photo and one document; the document matches the original bytes. Owned test messages and credential leases were cleaned up. - Focused integration, delivery, trust, and browser-policy checks plus the matching runtime/UI build passed on an isolated native runner. Independent source-blind acceptance passed both native and embedded public flows: final attachments, 25-file selection, all 26 saved-file hashes, image/document downloads, history refresh, and actual unmarked-plugin rejection. Baseline and Telegram results above are separate retained proof. Exact-head hosted checks and final review are required before landing. This preserves the implementation from @NianJiuZst and includes useful regression coverage offered by @igs-rogenlo in openclaw#144609. The two-runtime scope is retained; the older wording-only alternative is not reopened. Co-authored-by: igs-rogenlo <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Fixes #138383.
What Problem This Solves
dir_fetchbuildsdetails.media.mediaUrlsfrom local gateway paths, caps the list at 25, and returns a summary saying the channel attaches the first 25. Nothing attaches them.filterToolResultMediaUrlsreduces an untrusted tool's media tohttp(s)entries.dir_fetchemits filesystem paths, so the list empties on every call andembedded-agent-subscribe.handlers.tools.results.tsreturns beforequeuePendingToolMedia. The tool text has already been emitted by then, so the model is handed a false statement and relays it. No warning, nothing logged, attachment count 0.Why This Change Was Made
The mechanism for this already exists on both ends, and nothing connects them.
setManifestPluginToolMeta(src/plugins/tools.ts) marks a bundled plugin tooltrustedLocalMediawhen the manifest'scontracts.toolsdeclares it.extensions/file-transfer/openclaw.plugin.jsondeclaresdir_fetch.filterToolResultMediaUrlsalready accepts a run-localtrustedLocalMediaToolNamesset, and a name in it is trusted for local media.No production caller populates that set — only
embedded-agent-subscribe.e2e-harness.tsdoes. The metadata is computed, the consumer is wired, and the value in between is permanentlyundefined.This collects the set where the run's tool surface is already assembled (
attempt-client-tools.ts, next tocoreBuiltinToolNames) and threads it throughattempt-execution-phase→attempt-stream-prepare→ the subscription, which already forwardsparams.trustedLocalMediaToolNames.collectTrustedLocalMediaToolNamestakes names from two sources and no others:isCoreToolResultMediaTrustedNamematches it today — so every tool trusted before this change is still trusted, and this half is not a widening.trustedLocalMediamark.Forwarding the whole builtin set — what the e2e harness does as its fallback — would have granted local-media trust to every registered tool including MCP tools, which is the boundary the set exists to hold.
TRUSTED_TOOL_RESULT_MEDIAis untouched. #101434 moved this project away from widening that Set, and #120718 ruled on the delivery mechanism. Neither is reopened here, and the issue explicitly asked for neither.Alias behaviour is deliberately unchanged. Supplying a defined set activates
filterToolResultMediaUrls's exact-raw-name branch, and the set is built so every name trusted today passes it. Tightening that gate for core names would change behaviour forbash,cronandapply-patch— a separate decision that does not belong in a delivery fix.User Impact
An agent that runs
dir_fetchto bring back a directory of images, logs or exported reports for a person to look at now has those files attached, which is what the tool already told the model would happen.file_fetch,dir_listandfile_writeare declared in the same manifest contract and are covered by the same collection.Nothing changes for any other tool: unmarked plugin tools and MCP tools keep being filtered to
http(s), and core tools behave exactly as before.Evidence
The defect and the fix are both pinned at the two boundaries the report names.
At the filter (
embedded-agent-subscribe.tools.media.test.ts) — this is repro A from the issue, which needs neither node pairing nor a policy grant:At the delivery boundary (
embedded-agent-subscribe.handlers.tools.media.test.ts), drivinghandleToolExecutionEndwith adir_fetchresult carrying two local paths:state.pendingToolMediaUrls[]{dir_fetch}["/tmp/run/a.png", "/tmp/run/b.png"]The second row is the contradiction closing: the summary and the attachments finally agree.
The collector is covered directly: both sources included, unmarked plugin tools excluded,
dir_listwithout the mark excluded, unnamed tools ignored, and core tools (exec,read) still trusted once a run supplies its exact set — that last one is the regression guard for turning the set on at all.The wiring is pinned in
attempt-client-tools.test.ts: a run holding a markeddir_fetch, an unmarked MCP tool andexecexposes exactly{dir_fetch, exec}, so dropping the call site fails a test rather than silently restoring the bug.Checks
d331583bbf0attempt-client-tools16,attempt-stream-prepare+dir-fetch-tool43,handlers.tools.media32,tools.media46 — all passingtsgo -p tsconfig.json: no errors insrc/agents; the pre-existingscripts/**andextensions/qa-lab/**errors on that project are untouched by this branchoxlintandoxfmt --check: clean on all seven changed filesOpen questions
MEDIA_URL_CAPslicing — that is a much smaller diff and I am happy to send it instead.mediaNoteis only appended when the directory holds more than 25 files, butdetails.media.mediaUrlsis populated regardless. This fix covers both; the false sentence and the dropped attachments had different trigger conditions.