Skip to content

Inject bounded text context for managed inbound PDFs #90096

Closed

Description

@joeykrug

Summary

Inbound PDFs from messaging channels and the Control UI are represented as media pointers, but text-only/locked-down agents do not automatically receive bounded PDF text context. They can therefore see only an attachment name or media://inbound/... marker and fail to summarize the document.

Observed behavior

  • Signal group inbound PDF messages included MediaPath, MediaPaths, MediaType=application/pdf, and MediaTypes, but the prompt only contained a media marker.
  • The locked-down group bot did not have broad file/read/exec tools and should not receive them.
  • Control UI/Emma uses the embedded runner path, not the auto-reply path, so fixing only get-reply was insufficient.

Expected behavior

  • Auto-reply and embedded-runner prompt construction should inject bounded text extracted from managed inbound PDF media before the user request.
  • Extracted text must be clearly marked as untrusted document content.
  • The same behavior should work for Signal/group-bot and Control UI/embedded runner paths.

Safety constraints

  • Resolve only managed media://inbound/* or media-store-owned inbound paths.
  • Cap extraction at roughly 3 PDFs, 25 MB per PDF, 150 pages, 120k chars, and 15s timeout.
  • Do not grant group bots or Control UI agents broad read, exec, or arbitrary filesystem access.

Local runtime evidence

The local runtime fix extracted bounded PDF context for both the auto-reply path and embedded runner path. Joey's 15.6 MB / 58-page Control UI upload logged embedded inbound PDF context extracted ... chars=72791 and returned a substantive summary.

Activity

  1. clawsweeper commented on Jun 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 15, 2026, 7:38 AM ET / 11:38 UTC.

    Summary
    Keep open: current main still does not satisfy the large managed-PDF case, and the canonical implementation is the still-open linked PR at #92220.

    Reproducibility: yes. at source level: current main still has 5 MB / 4-page extraction defaults and rejects a 6 MB sandboxed PDF offload before dispatch. I did not run a live Signal or Control UI repro in this read-only review.

    Next step
    Do not queue a new fix PR because the issue already has an open linked implementation PR for maintainers to review.

    Security
    Needs attention: The issue is security-sensitive because the fix must preserve managed-media-only resolution and untrusted document wrapping.

    Review details

    Best possible solution:

    Review and land #92220 if maintainers accept the extraction envelope and managed-media fallback contract, then close this issue after that merge.

    Do we have a high-confidence way to reproduce the issue?

    Yes, at source level: current main still has 5 MB / 4-page extraction defaults and rejects a 6 MB sandboxed PDF offload before dispatch. I did not run a live Signal or Control UI repro in this read-only review.

    Is this the best way to solve the issue?

    Yes, the linked implementation direction appears best because it reuses the existing media-understanding extraction and injection path instead of adding a parallel prompt-context module. The remaining decision is whether maintainers accept the larger default extraction envelope and managed-media fallback behavior.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Current main and the latest release still leave large managed PDFs below the gateway parse cap but above the sandbox/file-extraction caps without the requested extracted text behavior.
    • Automatic PDF prompt injection crosses untrusted-document and managed-media trust boundaries, so maintainers still need to accept the extraction envelope, timeout behavior, and managed-PDF fallback contract before merge.

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

    Label changes

    Label changes:

    • add clawsweeper:needs-security-review: Current issue advisory state selects this label.
    • remove clawsweeper:needs-maintainer-review: Current issue advisory state no longer selects this label.

    Label justifications:

    • P2: The issue affects PDF understanding for locked-down agents but is bounded to media prompt construction and gateway media handling rather than a core outage.
    • impact:security: The requested fix must preserve managed-inbound-media resolution and untrusted-document boundaries without granting broad file or exec access.
    • impact:message-loss: Large inbound PDF content can be reduced to a media marker or rejected before dispatch, so the document text is not delivered to the model.
    Evidence reviewed

    Security concerns:

    • [medium] Preserve managed PDF trust boundary
      Any fix should extract only managed inbound PDF media and wrap extracted content as untrusted; granting broad read or exec access would cross the intended sandbox boundary.
      Confidence: 0.9

    What I checked:

    • Repository policy read: Root review policy requires current source, tests, shipped behavior, related PRs, and scoped guides before a verdict; gateway and embedded-runner scoped guides were also read. (AGENTS.md:11, 8682d0701b27)
    • Vision fit: VISION.md prioritizes security and safe defaults, bug fixes and stability, and improved major messaging-channel support, which fits this locked-down inbound document handling issue. (VISION.md:21, 8682d0701b27)
    • Current extraction limits: Current main still derives media-understanding file extraction from gateway responses.files, so default behavior inherits the input_file defaults instead of the issue's larger managed-inbound PDF envelope. (src/media-understanding/apply.ts:102, 8682d0701b27)
    • Input-file defaults remain below request: The current defaults are 5 MB, 60k chars, 10s timeout, and 4 PDF pages, which does not cover the reported 15.6 MB / 58-page PDF or the requested roughly 25 MB / 150-page cap. (src/media/input-files.ts:126, 8682d0701b27)
    • Current gateway rejects oversized sandbox PDFs: Sandboxed non-image media offloads larger than MEDIA_MAX_BYTES are rejected before staging, so a 6 MB managed PDF still does not reach dispatch on current main. (src/gateway/server-methods/chat.ts:1375, 8682d0701b27)
    • Regression test documents current rejection: The current gateway test explicitly expects a 6 MB PDF to be rejected as exceeding the sandbox staging limit. (src/gateway/server-methods/chat.directive-tags.test.ts:5576, 8682d0701b27)

    Likely related people:

    • amknight: Authored the open maintainer-labeled PR that directly closes this issue by changing media-understanding extraction limits and managed-PDF gateway fallback behavior. (role: active linked fix author; confidence: high; commits: 451ed20afb20; files: src/media-understanding/apply.ts, src/media-understanding/file-extraction-limits.ts, src/gateway/server-methods/chat.ts)
    • steipete: GitHub path history shows recent media-understanding and input-file helper work, including documenting media understanding defaults and media helper contracts. (role: recent media area contributor; confidence: medium; commits: 9b42f399a1af, f1bdc91b64d4, 77f1359612f6; files: src/media-understanding/apply.ts, src/media/input-files.ts)
    • samzong: GitHub path history shows the non-image attachment offload feature that this issue depends on was introduced through the chat.send/media attachment path. (role: introduced adjacent offload behavior; confidence: medium; commits: 25ef9c0c419d; files: src/gateway/server-methods/chat.ts, src/media-understanding/apply.ts)
    • vincentkoc: Recent gateway history includes chat and session fixes on the same server-methods surface that handles Control UI chat.send dispatch. (role: recent gateway contributor; confidence: medium; commits: cf4000b47b78, f85ef0d1147f, b9e8e6d66ea6; files: src/gateway/server-methods/chat.ts)
    • joeykrug: Provided the original live runtime evidence and authored the earlier closed unmerged implementation PR, which is useful context for reproducing and comparing fixes. (role: reporter and prior implementation contributor; confidence: medium; commits: 1cef7dc189d8; files: src/media/inbound-pdf-context.ts, src/auto-reply/reply/prompt-prelude.ts, src/gateway/server-methods/chat.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
    P2
    impact:security
    impact:message-loss
    issue-rating: 🦞 diamond lobster
    clawsweeper:source-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    clawsweeper:needs-product-decision
    on Jun 4, 2026
  3. added
    clawsweeper:linked-pr-open
    clawsweeper:needs-security-review
    and removed
    clawsweeper:needs-maintainer-review
    on Jun 15, 2026
  4. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:linked-pr-openclawsweeper:needs-product-decisionclawsweeper:needs-security-reviewclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:message-lossimpact:securityissue-rating: 🦞 diamond lobster

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions