Repository navigation
fix(media): extract large managed inbound PDFs via media-understanding - #92220
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 15, 2026, 3:32 PM ET / 19:32 UTC. Summary PR surface: Source +149, Tests +365. Total +514 across 6 files. Reproducibility: yes. at source level: current main still uses the 5 MB / 4-page Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Rebase onto current main, preserve the merged #90115 gateway trust gate, and land the extraction-limit change for #90096 only if maintainers accept the expanded defaults. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main still uses the 5 MB / 4-page Is this the best way to solve the issue? No, not as the branch currently stands: the extraction-limit direction is still the right narrow fix, but the gateway half is now stale against current main. The best path is a rebase that preserves the merged gateway fallback and makes the expanded extraction envelope an explicit maintainer choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b3128ba93def. Label changesLabel justifications:
Evidence reviewedPR surface: Source +149, Tests +365. Total +514 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
#90096, #90097) Inbound PDF/document text already flows to agents through the canonical media-understanding pipeline (applyMediaUnderstanding -> extractFileBlocks), but it inherited the OpenResponses input_file limits (5MB / 4 pages), so large managed PDFs from channels/Control UI were skipped and locked-down agents saw only an attachment marker. - Size inbound file extraction from agents.defaults.mediaMaxMb (default 20MB, cap 25MB) and pdfMaxPages (default 20, cap 150) via a new resolveFileExtractionLimits; explicit gateway responses.files config still wins per-field. (#90096) - chat.send: let oversized (>5MB) managed inbound PDFs pass through sandbox staging with their managed media path instead of a 4xx, so host-side extraction reaches sandboxed agents without copying the file into every sandbox; non-PDF oversize files are still rejected. (#90097) Reuses the existing extraction/injection path; no parallel module or extra prompt-injection sites.
451ed20 to
845c5ea
Compare
|
/clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Rebase resolution: why this replaces the merged
|
Summary
Large inbound PDFs/documents from messaging channels and the Control UI were delivered to text-only/locked-down agents as just an attachment marker — the agent never saw the document text. This fixes that by extending the existing media-understanding extraction pipeline rather than adding a parallel one.
The canonical pipeline already extracts inbound document text, wraps it as untrusted content, and injects it into the prompt (
applyMediaUnderstanding→extractFileBlocksinsrc/media-understanding/apply.ts, invoked fromgetReplyFromConfig). It just inherited the OpenResponsesinput_filelimits — 5 MB / 4 pages — so anything larger was silently skipped.Changes
resolveFileExtractionLimits(src/media-understanding/file-extraction-limits.ts) sizes inbound file extraction from the agent's media config:agents.defaults.mediaMaxMb(default 20 MB, host-side hard cap 25 MB) andagents.defaults.pdfMaxPages(default 20, cap 150). An explicitgateway.http.endpoints.responses.filesoperator config still wins per-field. No new config keys.prestageMediaPathOffloadsnow lets oversized (>5 MB) managed inbound PDFs pass through sandbox staging with their managed media path instead of returning a 4xx. Host-side extraction reads them via the media-store root, so sandboxed/locked-down agents get the text without copying a large PDF into every sandbox. Non-PDF oversize files are still rejected; staged + pass-through files preserve attachment order.This is an alternative, narrower implementation of #90111 (closed). It reuses the existing extraction/injection path — no new
inbound-pdf-contextmodule, no second prompt-injection site, no prompt-string scanning, no parallelMediaExtractedContextfield, and so it avoids the duplicate-extraction and sandbox-path bugs in that approach. Net +161 / −43 non-test LOC.Thanks to @joeykrug for the original report and investigation in #90096/#90097/#90111.
Behavior
[media attached: media://inbound/...pdf (application/pdf)]; on a sandboxed agent,chat.sendrejected it with a sandbox staging-limit 4xx.chat.sendwithout the staging-cap rejection.Verification
Commands run (local, macOS):
node scripts/run-vitest.mjs src/media-understanding/file-extraction-limits.test.ts src/media-understanding/apply.test.ts src/gateway/server-methods/chat.directive-tags.test.ts— green (limits 7, apply 53, gateway 218)pnpm tsgo:core/pnpm tsgo:test:src— cleannode scripts/run-oxlint.mjs <changed src>— cleanpnpm exec oxfmt --checkon changed files — cleanpnpm build— clean (no[INEFFECTIVE_DYNAMIC_IMPORT])Regression coverage added:
file-extraction-limits.test.ts— limit derivation (defaults, mediaMaxMb/pdfMaxPages, 25 MB & 150-page ceilings, non-positive fallback, explicitresponses.filesoverride).apply.test.ts— a ~6 MB file is now extracted end-to-end throughapplyMediaUnderstanding(would have been skipped at the old 5 MB cap).chat.directive-tags.test.ts— oversized managed PDF passes through to dispatch with the managed path +MediaStaged; the existing oversize-rejection test repointed to a non-PDF to keep that 4xx covered.Proof gaps
maxPixelstweak.Closes #90096
Closes #90097