Repository navigation
[ENG-21106] feat(boon-pdf-prep): prepare inbound PDFs, mark cut attachment text - #273
Conversation
Construction drawing and spec sets often have more than 1,000 pages, and a message can carry several of them. The pdf-index skill now has a page-text search with a background preparation queue. The queue only starts when the agent first runs a pdf-index command, so the first question about a big new file often finds an index that is still empty. Add the bundled plugin boon-pdf-prep: - message_received: for each PDF attachment (a .pdf suffix or application/pdf), spawn `pdf-index enqueue <paths>` detached, with ignored stdio, and do not wait for it. A spawn error is swallowed, so a host without pdf-index is not affected. - before_prompt_build: for the media://inbound PDF refs in the prompt, run `pdf-index status` with a 1.5 s budget and add one short line per file to the model input through appendContext, for example `"plans.pdf" (sha256 <hex>): 1546 pages. Text search covers pages 1-400. The rest in about 57 s.` The note does not go into the session transcript. Files that the status call does not know yet are enqueued. A ready file is noted once per gateway process. - Every failure (a missing binary, an old pdf-index, a timeout, bad JSON) gives no note and no error. The turn goes on as before. File names in the note are cleaned of control characters and cut to 80 characters. Only media://inbound refs and absolute paths are passed to pdf-index, so a media line typed by a user cannot inject a flag. The plugin is enabled by default but loads only where plugins.allow lists it; the paid fleet adds it to the allow list in a separate change.
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
/cr |
…naged refs only A file shown as queued or text on an earlier turn never got its "Ready." line, because the seen set recorded every hash on first sight. Track only the hashes whose ready line was shown. before_prompt_build now reads only media://inbound refs from the prompt. An absolute path in a media line can come from user text. message_received still enqueues every PDF from the trusted attachment metadata. Docs: the status check can delay the model call by at most 1.5 s, and enqueue receives the inbound paths.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
A media line can carry MIME parameters, for example "application/pdf; charset=binary". The parser took the whole text as the ref and missed the PDF. It now accepts the parameters and compares the type before ";", case-insensitive. The enqueue child is not detached and has no timeout, so its handle kept the gateway event loop alive. Call unref() after the spawn. A text-state status with no page count now still gives the coverage sentence and the ETA instead of "Queued.".
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
…ings The ready line for a PDF was shown once per gateway process. Every later conversation that got the same file had no line for it, so the model had no hash and no hint to use pdf-index. The line is now shown once per session (sessionId, else sessionKey), and on every turn when the run has no session identity. pdf-index status can now report saved findings for a file. When it does, the line adds the finding count and pages and tells the model to run pdf-index recall before it reads those pages. The pages value is cleaned to digits, commas and hyphens.
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
The findings part of the ready line has no page list when status gives no usable pages value. Say so in the plugin page.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
A file name or failure reason with U+2028, U+2029 or U+0085 passed the cleaner and split the PDF preparation note into extra lines. The cleaner now removes all Unicode line and paragraph separators too.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
The agent never saved its page findings, because the save rule is only in the pdf-index skill file, which the agent does not open. A new thread then repeated the same visual count. When pdf-index status reports findings for a listed PDF, memory is available, so the note now ends with one line that asks the agent to save each result with pdf-index note. Older pdf-index versions and hosts without memory get no such line.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 13 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
A count read from page tiles was saved with the default text_layer source, because the save line did not name --source. List text_layer and vision in the line.
@orswn I have started the AI code review. It will take a few minutes to complete. |
Attached file text is cut at files.maxChars (60,000 characters by default) with no marker, and inbound PDF extraction stops at the configured page budget. The extractor reports the pages it covered, but that coverage was dropped. The model then saw a cut-off document as the whole file, and told users that sections after the cut did not exist. Add an "[Incomplete text: ...]" line to the file block when the text was cut by characters, or when PDF coverage reports a page or text limit. The line gives the shown and total characters or pages and asks the model to read the rest from the file before it says what the document contains or lacks. It follows the untrusted-content end marker, so the model reads it as a fact about the file and not as file content. maxChars still bounds the file text itself.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 22 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
The notice was added only after non-empty file text. A page-cut PDF that fell back to page images, or that had no text, got only the placeholder, so the model was not told that pages were missing. Add the notice after whatever the file block holds: the wrapped text, the images placeholder, or the no-text placeholder, in both the inbound attachment and the OpenResponses paths. In the low-text fallback the extractor counts rendered image pages as processed pages, so "covers N of M pages" overstated the text. When the extractor returned images, the notice now says only that part of the PDF was extracted.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 22 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
The extractor text limit can stop inside a page after every page was visited. The notice then said "covers 108 of the 108 pages" and asked the model to read other pages that do not exist. Use the page count only for a page cut on extracted text. A text-limit cut, like the image fallback, now says that only part of the PDF was extracted.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 22 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
The default coverage fixture had no requested pages, and the no-notice cases reused a page-cut coverage with its reasons removed. The extractor never reports either shape. Request the processed pages in the default, and use complete all-page coverage in the no-notice cases.
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 22 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
…g PDFs Asked to review a whole 32-page drawing set, the agent read four pages and the attached file text, which stops part-way, then said it had reviewed all 32 pages. The fan-out rule was only in the system prompt. In the same runs the agent did fan out when tool output next to the turn told it to. When a listed PDF that has not failed has more than 20 pages, add one line to the preparation note: split a whole-file read, summary or review into 10-20 page ranges with one sub-agent each, and attached file text is not a read of the file.
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
A sub-agent run allows five active children by default, and sessions_yield ends the turn. A PDF over 100 pages needs more than five 10-20 page ranges, so the line could lead to a rejected sixth spawn or a yield before every range was started. Tell the agent to spawn at most five, call sessions_yield last, and spawn the rest after the results arrive.
The line asked the agent to split a whole-file read of a PDF over 20 pages across sub-agents. In a local run on a 32-page drawing set, with the line in the note, the agent still read a few pages and the attachment text and did not fan out, the same as without it. A prompt line with no measured effect adds about 55 tokens to every turn that lists a big PDF. This reverts commits 2311280 and ba79bde.
There was a problem hiding this comment.
✅ Approved
Prepares inbound PDFs in the background via pdf-index and marks cut attachment text with clear out-of-band notices.
Strengths
- Clean non-blocking enqueue lifecycle (
unref(),stdio: ignore) onmessage_receivedand strict 1.5s timeout withSIGKILLonbefore_prompt_build. - Robust injection protection: command execution uses direct argv arrays (
spawn/execFile, no shell interpolation); prompt refs are restricted tomedia://inbound/; filenames, failure reasons, and page numbers are strictly sanitized and length-capped. - Safe failure behavior: missing
pdf-index, slow execution, or legacy CLI versions cleanly fall back to no injected note without crashing the gateway or failing the turn. - Accurate incomplete-text notices: distinguishes character cutoffs from PDF page/text extraction coverage limits, positioned after untrusted content wrappers so models treat them as system metadata.
- Per-session deduplication:
Ready.status is noted once per session ID/key (bounded LRU 1,000 entries), avoiding prompt bloat.
Technical Review
- ✅ Execution & Process Management: Subprocess spawning is non-blocking with proper error handling and process cleanup on timeout.
- ✅ Security & Prompt Safety: Strict sanitization regexes prevent prompt injection and shell escape risks.
- ✅ Attachment Handling:
buildTextNoticecorrectly computes text and coverage limits for both plain text and PDF files. - ✅ Test Coverage: All unit and contract tests pass (
extensions/boon-pdf-prep,input-files.text-notice,apply,openresponses-http).
Verification Evidence
- Tests:
extensions/boon-pdf-prep(72 tests across 2 files),src/media/input-files.text-notice.test.ts(12 tests),src/media-understanding/apply.test.ts(56 tests),src/gateway/openresponses-http.server.file-only.test.ts(8 tests) all pass. - Types & Lints:
pnpm tsgo:coreandpnpm tsgo:extensionsexit 0;oxlintandoxfmt --checkpass clean. - All 22 prior bot review threads are resolved.
PR is solid and ready to merge.
…ep-extension boon moved to 2026.6.34-boon.4 (#274), which bumped every plugin manifest. The new boon-pdf-prep manifest still said boon.3, so the release preflight would fail on the next version bump: plugins:sync:check reported "update required: @openclaw/boon-pdf-prep". Align it with pnpm plugins:sync. Regenerate the plugin inventory, the plugin reference page and the config baseline, which the new plugin changes and which plugins:inventory:check and config:docs:check reported as stale. The baseline also picks up tools.web.fetch.ssrfPolicy.allowedHostnames from #270, which boon did not regenerate. The remaining preflight drift is the npm shrinkwrap check on the @opentelemetry packages under @sentry/node. It is the same on boon.
…-> 2026.6.34-boon.5 (#277) Cut the fork release that ships the two commits on boon since v2026.6.34-boon.4. The bundled boon-pdf-prep plugin queues inbound PDFs for background text preparation and adds a short preparation note to the model input, and cut attachment text now says where it stops (#273, ENG-21106). A sub-agent stopped by /stop stays killed, and stopping a service-mode exec shell on Linux also signals its descendants (#276, ENG-16829). Bump root package.json and npm-shrinkwrap.json, all 136 plugin manifests, and the version and openclaw peer floor in every extension npm-shrinkwrap.json. Add the 2026.6.34-boon.5 CHANGELOG.md section and the generated extensions/matrix/CHANGELOG.md entry. No dependency changes.
Related: ENG-21106
What Problem This Solves
Construction drawing and spec sets often have more than 1,000 pages, and one message can carry several of them. The
pdf-indexskill can now search page text and prepare big PDFs in a background queue. Preparation only starts when the agent first runs apdf-indexcommand. So the first targeted question about a big new file often finds an empty index, and the agent does not know how far preparation has got.Why This Change Was Made
A new bundled plugin,
boon-pdf-prep, starts preparation when the message arrives. On each turn it adds one short status line per attached PDF to the model input:message_received: for each PDF attachment (a.pdfsuffix orapplication/pdf, MIME parameters allowed), it spawnspdf-index enqueue <paths>with ignored stdio. The child is unref'd, and the plugin does not wait for it.pdf-indexstarts its own background worker.before_prompt_build: for themedia://inboundPDF refs in the prompt, it runspdf-index statuswith a 1.5 s budget and returnsappendContext, for example:The note goes to the model input only. It is not written to the session transcript.
A file that
statusdoes not know yet is enqueued.A file that is not ready gets a line on every turn once its hash is known. Its
Ready.line is shown once per session (the session id, else the session key). A run with no session identity gets it on every turn.When
pdf-index statusreports saved findings for a file, its line ends withEarlier findings: <count> on pages <pages>. Run pdf-index recall <sha256> before you read these pages.The pages value keeps only digits, commas and hyphens. Olderpdf-indexversions report no findings.When
pdf-index statusreports findings for a listed file, even a count of 0, PDF memory is available. The note then ends with one line that asks the agent to save its results:Without this line, the agent did not save findings: the save rule was only in the skill file, which the agent does not open. Older
pdf-indexversions and hosts without memory get no such line.Cut attachment text is now marked. The gateway puts the extracted text of an attached file into the model input. That text is cut at
files.maxChars(60,000 characters by default) with no marker. Inbound PDF extraction also stops at the page budget (agents.defaults.pdfMaxPages), and the coverage that the extractor reports was dropped. In tests on a 108-page spec, two models saw about the first 22% of the text and told the user that later sections did not exist.[Incomplete text: it covers 120 of the 243 pages of this PDF. Read the other pages from the file before you say what the document contains or lacks.][Incomplete text: only part of this 243-page PDF was extracted. ...]maxCharsstill bounds the file text itself. An image-only limit gives no line.media-understanding/apply.ts) and OpenResponsesinput_file(gateway/openresponses-http.ts).Boundaries:
pdf-indexwithout these commands, a timeout, a non-zero exit, or bad JSON. A spawn error has a listener, so a missing binary cannot crash the gateway.before_prompt_buildreads onlymedia://inbound/refs from the prompt, so a media line typed by a user cannot inject a flag or name an arbitrary local file.message_receiveduses the trusted attachment metadata. File names and failure reasons are cleaned of control characters, Unicode line and paragraph separators, brackets and quotes, and cut to 80 characters.plugins.allowlist loads it only when the list holdsboon-pdf-prep(config-activation-shared.ts,not-in-allowlist). The fleet allow list changes in a separate deployment repository.readyfile. The model can still runpdf-index status.statuscall can run beforeenqueuehas hashed the file. That turn then gets no line. The next turn does. In the local tests below, the hash was known 0.5 to 0.7 s after receipt and the line was in the first turn.User Impact
Evidence
pnpm vitest run extensions/boon-pdf-prep src/plugins/bundled-plugin-metadata.test.ts src/plugins/contracts/boundary-invariants.test.ts:Test Files 4 passed (4),Tests 122 passed (122).Plugin contract and runtime-dependency tests:
479 passed.Cut-text line:
pnpm vitest run src/media/input-files.text-notice.test.ts src/media/input-files.fetch-guard.test.ts src/media-understanding/apply.test.ts src/gateway/openresponses-http.server.file-only.test.ts src/gateway/openresponses-http.test.ts extensions/boon-pdf-prep:Test Files 8 passed (8),Tests 222 passed (222). The newinput-filesand rendering tests failed before the change.pnpm tsgo:coreandpnpm tsgo:core:test: exit 0. Changed-file oxlint andoxfmt --check: clean.format:docs:check,lint:docs,docs:check-mdx,docs:check-links: pass.pnpm tsgo,pnpm tsgo:extensionsandpnpm tsgo:extensions:test: exit 0.Extension oxlint and
oxfmt --check: clean.docs:check-mdxanddocs:check-links: pass.docs:check-i18n-glossaryagainst the PR base: pass. The new page title has a zh-CN glossary entry.Not part of this change, fails on the base branch too:
pnpm config:docs:check(baseline hash drift), anddocs:check-i18n-glossaryagainstorigin/main(9 labels from earlier fork commits).CI: 118 checks pass.
security-fastfails on this PR and on other open PRs intoboon([ENG-20801] fix(agents): sub-agent resumed twice after a gateway restart #269 to [ENG-16829] fix(auto-reply): shell commands keep running after /stop #272):pnpm auditreports high advisories in existing production dependencies (simple-git,proxy-addr). The plugin has no runtime dependencies.Local agent smoke with real model calls: see the tables below.
Local agent smoke. A local agent with the web chat, a local Boon Core, and the matching
pdf-indexskill change. Model calls were real.enqueue0.3 s after receipt. Hash known 0.54 s after receipt. The line (Queued.) was in the first turn. Index ready 15.7 s afterenqueue. The agent searched, waited once and answered the right page. Reply 33.1 senqueue0.9 s after send. Answer fromsearchin the turn. 11 to 27 sReady. Earlier findings: 1 on pages 32. Run pdf-index recall .... The agent ranrecallfirst and answered in 15.7 s and 23.6 sCut-text line, agent level. The same stack, agent model Opus 4.8, one run each. The file is a public 108-page electrical specification with 256,818 characters of text, so the attached text is cut at 60,000.
[Incomplete text: it stops after 60000 of 200000 extracted characters, part-way through this 108-page PDF. ...]. The section is past the cut. The agent did not say it was missing:pdf-index search, thenpage-texton 5 pages. Correct section and rating, 29.0 s. A second new thread: the same tools and answer, 26.1 ssearch, then 2 pages. Correct, 24.5 sReal files, final heads. The same stack with the final heads of all companion PRs. The files are real PDFs: a 243-page permit drawing set, two smaller drawing sets, and 1,071-page and 796-page text books for size.
Queued.) was in the user turn 1.34 s after send.partial_no_matchat 100/1071, onestatus --wait, correct page, 71.7 scountfinding before it answeredEarlier findings: 2 on pages 6,196. The agent ranrecallfirst at +4.7 s and answered with no page read, 21.5 s