Skip to content

Inbound non-image attachments exposed to the model as unresolvable media://inbound/... URI (PDFs/docs unreadable) #97237

Closed

Description

@gallup007

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:

  1. Downloads the file to ~/.openclaw/media/inbound/<name> (correct), and
  2. 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

  1. Configure an agent with shell/exec access and a PDF-reading helper (we use a pdf_read.sh that takes a filesystem path).
  2. Send the agent a PDF over Telegram.
  3. 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 from ctx.MediaPaths / ctx.MediaPath, which hold the media://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 the media:// 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)

  1. Emit a resolvable path in the media note. For local media://inbound/* attachments, have formatMediaAttachedLine (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 any exec-capable agent.
  2. Resolve media:// at the tool boundary. Teach exec / file-reading tools (and the built-in pdf tool) to resolve media://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 pdf tool was already non-functional in our setup, which is why the document path matters; but even with a working pdf tool, handing it a media:// URI it can't resolve would fail the same way.
  • Tracked internally as WAL-334.

Activity

  1. clawsweeper commented on Jun 27, 2026

    @clawsweeper
    Contributor

    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-in read/pdf support 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 read and pdf consumers 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:

    • The correct fix boundary is still a maintainer/security decision: exposing absolute host paths helps shell workflows but weakens the existing model-visible path privacy default.
    • The open related PR covers unsupported binary documents only and intentionally keeps PDFs on media://inbound/, so landing it as-is would not fully resolve this report.
    • This review established a high-confidence source-level reproduction but did not run a live Telegram attachment scenario.

    Codex review notes: model internal, reasoning high; reviewed against c5d34c8376f8.

    Label changes

    Label changes:

    • add 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:

    • [medium] Preserve inbound media path privacy — src/auto-reply/media-note.ts:19
      Current 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:

    • Repository policy read: Root AGENTS.md was read in full; its high-confidence source/history review, security-default, and channel/plugin boundary guidance affected the review. (AGENTS.md:1, c5d34c8376f8)
    • Current prompt note behavior: Current main rewrites absolute first-level managed inbound media-store paths to 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)
    • Prompt insertion point: buildReplyPromptBodies inserts 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)
    • Non-image attachments are not current-turn inline media: resolveAgentTurnAttachments returns 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)
    • Existing supported consumers are partial: The built-in media reference helpers can resolve 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)
    • Latest release still has the prompt URI behavior: The v2026.6.10 tag contains the same normalizeManagedInboundMediaRef rewrite to media://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:

    • steipete: Authored the merged inbound media reference resolution work and recent media/docs touches that define current media://inbound behavior. (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)
    • vincentkoc: Authored the read-tool inbound media ref support and Telegram prompt media path normalization adjacent to the reported tool-boundary behavior. (role: recent media/read-tool contributor; confidence: high; commits: 96c5d33d2b16, ba36291a8c8b; files: src/agents/sessions/tools/read.ts, src/agents/agent-tools.read.ts, extensions/telegram/src/prompt-media-path.ts)
    • amknight: Recent merged gateway work changed managed inbound PDF pass-through and extraction behavior, which overlaps the PDF side of this issue. (role: adjacent inbound PDF contributor; confidence: medium; commits: 67c80e941ecf, e850750754f2; files: src/gateway/server-methods/chat.ts, src/media-understanding/apply.ts)
    • MoerAI: Authored the merged media-note formatter dedupe work on the same prompt-rendering surface implicated here. (role: recent media-note contributor; confidence: medium; commits: 9e3d5310ccc6; files: src/auto-reply/media-note.ts, src/auto-reply/media-note.test.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jun 27, 2026
  3. self-assigned this
    on Jun 29, 2026
  4. joshavant commented on Jun 29, 2026

    @joshavant
    Collaborator

    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 managed media://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.

  5. locked as resolved and limited conversation to collaborators on Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions