Repository navigation
Description
Summary
When a user sends a non-image file (e.g. a PDF) to an agent over a channel (Telegram in our case), the gateway:
- Downloads the file to
~/.openclaw/media/inbound/<name>(correct), and - Injects a prompt-visible note:
[media attached: media://inbound/<name> (<mime>)].
The problem is step 2: the note carries the virtual media://inbound/... URI, not a resolvable filesystem path. Image attachments are separately base64-inlined for vision, so they work — but for any non-image attachment, the only reference the model receives is a media:// URI it has no tool to dereference. Shell/exec-based tools and document readers can't open media://, so the model concludes "no path/attachment came through" and the file is effectively unreadable, even though it's sitting on disk.
Version
openclaw 2026.6.10 (observed in the published dist).
Repro
- Configure an agent with shell/
execaccess and a PDF-reading helper (we use apdf_read.shthat takes a filesystem path). - Send the agent a PDF over Telegram.
- Ask it to read the PDF.
Expected: the model receives a usable local path and reads the file.
Actual: the model receives [media attached: media://inbound/<name>.pdf (application/pdf)], has no way to resolve media://, and reports it cannot access the attachment. The file is present at ~/.openclaw/media/inbound/<name>.pdf the whole time.
Evidence (from an agent trajectory log)
[media attached: media://inbound/Life_-_Annual_Report---<uuid>.pdf]
…while the file physically exists at:
~/.openclaw/media/inbound/Life_-_Annual_Report---<uuid>.pdf
i.e. the mapping is simply media:// → ~/.openclaw/media/.
Root cause (dist trace)
get-reply-*.js→buildInboundMediaNote(ctx)/formatMediaAttachedLine()build the[media attached: <value> (<mime>)]line.<value>is taken straight fromctx.MediaPaths/ctx.MediaPath, which hold themedia://inbound/...URI rather than the resolved local path.agent-turn-attachments-*.js→resolveAgentTurnAttachments()only resolves and base64-inlines image attachments (non-image attachments early-return false). So documents are never converted into model-consumable content, and themedia://URI in the text note is the model's only handle on the file.
Result: images work (vision inlining), documents/PDFs don't (URI the model can't dereference).
Suggested fixes (either or both)
- Emit a resolvable path in the media note. For local
media://inbound/*attachments, haveformatMediaAttachedLine(or its caller) print the resolved absolute path — e.g.[media attached: /abs/.openclaw/media/inbound/<name>.pdf (application/pdf)]— possibly alongside the URI. This is the smallest, highest-leverage change and immediately unblocks anyexec-capable agent. - Resolve
media://at the tool boundary. Teachexec/ file-reading tools (and the built-inpdftool) to resolvemedia://inbound/<name>→<media-root>/inbound/<name>so the URI works wherever a path is accepted.
Option 1 alone fixes the reported symptom; option 2 makes the media:// scheme robust everywhere it surfaces.
Workaround (no upstream change required)
Document the mapping in the agent's system prompt / tool guidance: translate media://inbound/<name> → ~/.openclaw/media/inbound/<name> before passing to a file reader. (We've done this across our agents as an interim fix.)
Notes
- Built-in
pdftool was already non-functional in our setup, which is why the document path matters; but even with a workingpdftool, handing it amedia://URI it can't resolve would fail the same way. - Tracked internally as WAL-334.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 27, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 27, 2026, 7:10 AM ET / 11:10 UTC.
Summary
Keep open: current main and v2026.6.10 still expose managed inbound attachments as prompt-visible
media://inbound/<id>refs, and existing built-inread/pdfsupport only partially addresses the reported shell/custom document-reader workflow. The related open PR is useful overlap, but it intentionally preserves PDF URI behavior and is not a merged full fix.Reproducibility: yes. source-level: current main maps managed inbound paths to
media://inbound/<id>in prompt notes and only image attachments are inlined into the current turn. I did not run a live Telegram bot reproduction.Next step
Manual maintainer/security review is needed to choose the path-privacy contract and coordinate with the partial open PR before implementation.
Security
Needs attention: The issue is security-sensitive because a likely fix path would expose host-local inbound media paths in model-visible prompts.
Review details
Best possible solution:
Keep this as the canonical media prompt/tool-boundary issue, then choose a scoped fix that either resolves
media://for shell/file helpers or exposes guarded real paths only where no managed consumer exists, with regression tests and explicit path-privacy review.Do we have a high-confidence way to reproduce the issue?
Yes, source-level: current main maps managed inbound paths to
media://inbound/<id>in prompt notes and only image attachments are inlined into the current turn. I did not run a live Telegram bot reproduction.Is this the best way to solve the issue?
No to unconditional absolute-path emission for all PDFs/documents: existing
readandpdfconsumers already support managed refs, so the safer fix needs a scoped prompt fallback or tool-boundary resolver rather than broad path exposure.AGENTS.md: found and applied where relevant.
Remaining risk / open question:
media://inbound/, so landing it as-is would not fully resolve this report.Codex review notes: model internal, reasoning high; reviewed against c5d34c8376f8.
Label changes
Label changes:
clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P2: The issue blocks affected inbound attachment-reading workflows but is bounded to media prompt/tool handling rather than a core outage.impact:message-loss: Inbound attachment content can be stored successfully while the agent receives only a reference that some document-reading workflows cannot use.Evidence reviewed
Security concerns:
src/auto-reply/media-note.ts:19Current media-note code deliberately rewrites managed inbound paths to
media://inbound/<id>so prompts do not leak host-specific paths; any fix that emits absolute paths should be narrowly scoped and reviewed as a path-privacy change.Confidence: 0.88
What I checked:
AGENTS.md:1, c5d34c8376f8)media://inbound/<basename>before rendering the prompt note, preserving path privacy but matching the reported unresolvable URI. (src/auto-reply/media-note.ts:11, c5d34c8376f8)buildReplyPromptBodiesinserts the media note into queued, command, and transcript prompt bodies, so the normalized media ref is model-visible. (src/auto-reply/reply/prompt-prelude.ts:51, c5d34c8376f8)resolveAgentTurnAttachmentsreturns false for non-image attachments before adding base64 current-turn attachments, so PDFs/documents depend on prompt text or a tool consumer rather than the image inlining path. (src/auto-reply/reply/agent-turn-attachments.ts:98, c5d34c8376f8)media://inbound/<id>to local paths, and the public PDF docs list managed inbound refs as supported, but that does not make arbitrary shell helpers or external document readers understand the URI. (src/media/media-reference.ts:188, c5d34c8376f8)normalizeManagedInboundMediaRefrewrite tomedia://inbound/<basename>, so the reporter's shipped-release observation is consistent with released code. (src/auto-reply/media-note.ts:11, aa69b12d0086)Likely related people:
media://inboundbehavior. (role: recent adjacent contributor; confidence: high; commits: 6290ed52ff9f, f1bdc91b64d4; files:src/media/media-reference.ts,src/agents/sandbox-media-paths.ts,docs/tools/pdf.md)src/agents/sessions/tools/read.ts,src/agents/agent-tools.read.ts,extensions/telegram/src/prompt-media-path.ts)src/gateway/server-methods/chat.ts,src/media-understanding/apply.ts)src/auto-reply/media-note.ts,src/auto-reply/media-note.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.joshavant commentedon Jun 29, 2026
Thanks for the clear report and repro details, @gallup007.
This was fixed by #97647. The issue was that managed inbound non-image attachments were stored correctly, but the agent prompt only exposed a
media://inbound/...reference that shell/document-reader workflows could not open. The fix extends the existing inbound media staging path so managedmedia://inbound/*files are copied into a runner-readable staged file before the agent turn, with sandbox and host-mode coverage.We also verified the Telegram PDF flow live with Crabbox: after the fix, the model prompt contained a real staged PDF path, the staged file existed, and the old
media://inbound-only prompt reference was gone.