fix(document-extract): render PDF image fallback per page so multi-page scans don't starve later pages#96390
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 7:54 AM ET / 11:54 UTC. Summary PR surface: Source +13, Tests +26. Total +39 across 2 files. Reproducibility: yes. at source level: current main batches fallback image extraction, and published Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the plugin-owner fix after maintainers explicitly accept or document the per-page Do we have a high-confidence way to reproduce the issue? Yes at source level: current main batches fallback image extraction, and published Is this the best way to solve the issue? Yes, with a merge-safety caveat: per-page AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1069c60e1e25. Label changesLabel justifications:
Evidence reviewedPR surface: Source +13, Tests +26. Total +39 across 2 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
|
…ge scans don't starve later pages clawpdf's mode:"images" extract applies a single maxPixels budget across every page, so the first page consumes it and later pages collapse to ~1x1 PNGs that vision OCR models reject. Render each selected page in its own extract() call so the pixel budget resets per page and every page yields a usable image.
99477c3 to
fde3690
Compare
|
Merged via squash.
|
…ge scans don't starve later pages (openclaw#96390) * fix(document-extract): render PDF image fallback per page so multi-page scans don't starve later pages clawpdf's mode:"images" extract applies a single maxPixels budget across every page, so the first page consumes it and later pages collapse to ~1x1 PNGs that vision OCR models reject. Render each selected page in its own extract() call so the pixel budget resets per page and every page yields a usable image. * fix(document-extract): preserve aggregate PDF render budget --------- Co-authored-by: Vincent Koc <[email protected]>
…ge scans don't starve later pages (openclaw#96390) * fix(document-extract): render PDF image fallback per page so multi-page scans don't starve later pages clawpdf's mode:"images" extract applies a single maxPixels budget across every page, so the first page consumes it and later pages collapse to ~1x1 PNGs that vision OCR models reject. Render each selected page in its own extract() call so the pixel budget resets per page and every page yields a usable image. * fix(document-extract): preserve aggregate PDF render budget --------- Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Closes #96389.
When a non-native model processes a scanned/image-based PDF,
document-extractextracts no text and falls back to rendering each page to a PNG for vision OCR.
That fallback issued a single
clawpdfcall:clawpdf's image renderer appliesmaxPixelsas one budget shared across thewhole call (
remainingPixelsis decremented after every page). On a multi-pagescan the first page consumes the budget and later pages are rendered with a
near-zero remaining budget — collapsing them to ~1×1 PNGs. Downstream vision
models then reject them, e.g.:
Why This Change Was Made
The shared-budget behavior lives in the
clawpdfdependency(
node_modules/clawpdf/dist/extract.js→renderImages), but the right ownerboundary for the fix is how this plugin calls clawpdf: each page in a fallback
render must be a usable image, so the pixel budget is meant to bound per-page
render quality, not be split across pages. Rendering each selected page in its
own
extract()call resetsremainingPixelsper page while keeping clawpdf'smaxPixels/maxDimensioncapping andformshandling intact (noreimplementation of the render budget in the plugin).
User Impact
Multi-page scanned/image PDFs now render every selected page at the full
per-page pixel budget instead of starving later pages to degenerate images, so
vision OCR succeeds on the whole document. No config or API surface changes;
single-page behavior is unchanged.
Evidence
Unit tests (
extensions/document-extract/document-extractor.test.ts, 7 passing)updated to assert each fallback page renders in its own
extract({ mode: "images", pages: [n], ... })call with the full per-page budget.Real-behavior proof against the actual
clawpdf0.3.0 dependency — a 3-pageUS-Letter PDF rendered at dpi=200 with
maxPixels=1,000,000:Test run (worktree-safe runner):
AI-assisted.