Repository navigation
feat(llm-helper): attachments on a single llm.chat call - images and PDF pages named by reference and read by the helper (RFC-0016, step 2) - #145
Merged
Conversation
…PDF pages named by reference and read by the helper (RFC-0016, step 2) llm.chat took text only, so a bounded AI node that had to read a page could not show it to the model. A request may now name files inside llm.attachments.root: the helper reads them in a worker thread and inside the call's deadline, decides the kind by the first bytes and sends base64 image and document blocks before the last turn's text; pages cuts a PDF to the pages named. One root with the agent tools' workspace rules, the provider's limits checked before any model call, never on llm.stream or a loop turn. With the audit of a single call, the record keeps a reference with the source file's size and SHA-256, never its bytes. The Node twin of Accenture/mercury-python#82. The reading is a module of its own, attachments.mjs, run in a worker thread: a hash, base64 and a PDF's cut are CPU work, and the helper's event loop carries every other call and stream. A new optional package, @cantoo/pdf-lib (a devDependency here), cuts pages and tells an encrypted PDF. The shared file test/vectors/llm-attachments-vectors.json (48 cases) over eight fixture files, all byte for byte the Python pack's, and seven tests pin it; thirty-three mutations of the code, the file and a fixture were each caught by a test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
acn-ericlaw
added a commit
to Accenture/mercury-composable
that referenced
this pull request
Nov 24, 2026
…of both features merged Step 2 of both build plans is on main in the Node pack: Accenture/mercury-nodejs#144 (the audit of a single call) and Accenture/mercury-nodejs#145 (attachments). The two RFC entries do not record it yet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
acn-ericlaw
added a commit
that referenced
this pull request
Nov 24, 2026
acn-ericlaw
added a commit
to Accenture/mercury-composable
that referenced
this pull request
Nov 24, 2026
…e pack, and the Node twin's PDF library as the maintainer's choice (#670) Each entry's resolution records step 2 as built and merged (Accenture/mercury-nodejs#144 and Accenture/mercury-nodejs#145): the Node twin from the same shared vector files and fixtures, what proves it, where it differs from the Python helper by its runtime and what the step did not do. In RFC-0016 the Node twin's PDF library leaves the open questions: the maintainer chose @cantoo/pdf-lib, and the shared vectors assert a cut document by its pages. Both entries stay Open. The threads and the session log follow. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
acn-ericlaw
added a commit
to Accenture/mercury-python
that referenced
this pull request
Nov 24, 2026
…cord both steps Accenture/mercury-nodejs#144 and Accenture/mercury-nodejs#145; Accenture/mercury-composable#669 and Accenture/mercury-composable#670. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RFC-0016 in mercury-composable (Accenture/mercury-composable#668), build plan step 2: the Node twin of Accenture/mercury-python#82. The field request is Accenture/mercury-python#78. Stacked on #144 (
feat/llm-chat-single-call-audit): this one's diff is the attachments alone, and its audit part needs the first.attachmentson a singlellm.chatcall: a non-empty list whose entries are a path insidellm.attachments.root, or{path, pages}for pages of a PDF (13,1-3,7). The request names a file and never carries one.imageblocks (PNG, JPEG, GIF, WebP) anddocumentblocks (PDF) before the text of the last turn.pagessends a new PDF with only those pages, in the order named.extensions/llm-helper/attachments.mjs). A hash, base64 and a PDF's cut are CPU work, and the helper's event loop carries every other call and every stream, so the reading never runs on it. The Python twin uses a thread of its pool for the same reason.params.timeout_mscovers the reading and the model: the caller has its 408 at the deadline whatever a read is doing, and the model call gets what the reading left.llm.attachments.max.count(20), more bytes of files thanllm.attachments.max.bytes(20 MB, from the files' sizes before they are read), an image over the backend's limit base64-encoded (10 MB on the Claude API, 5 MB on Amazon Bedrock), an encrypted or unreadable PDF, a page the document does not have. No folder configured is a 503; a folder that is not one stops the application at start;pageswithout the PDF package is a 503 that names it.attachmentsonllm.streamor a loop turn is a 400.@cantoo/pdf-lib(MIT, the maintained fork of pdf-lib; the maintainer's choice). It cuts pages and tells an encrypted PDF;pdfjs-dist, already here for the agent tools, only reads. A devDependency here, installed where pages are used; without it a whole document goes as it is. The lockfile gains it and its four dependencies (tslib,culori,fflate,node-html-better-parser).npm installalso movedjoseinto alphabetical order inpackage.json.requestkeeps each file as{type: attachment, path, pages, media_type, bytes, sha256}, the size and the hash of the source file as it was read, never its bytes.llm_attachments,llm_attachment_bytes), never a path or a file's content.test/vectors/llm-attachments-vectors.json(48 cases) over the eight fixture files oftest/fixtures/attachments(marked-textin.gitattributes, since their digests are pinned), all byte for byte the Python pack's, and seven tests: an image's limit by backend, the helper without the PDF package, the deadline over the read, the worker thread, the log, the start with a folder that is not one. Every case passed with no change to a case or a message: the two helpers answer the same statuses in the same words. A cut PDF is checked page by page, never byte for byte.resources/application.yml, CHANGELOG, the thread.Why
A bounded AI node that has to read a page - a scanned form, a table printed as an image, a chart, chosen pages of a long PDF - could not give the model what it had to read: text extracted outside the graph loses the layout, and a file's bytes in the request are too large for the event and would reach every log, trace and stored record. The Python pack has taken files by reference since Accenture/mercury-python#82; the two helpers speak one contract, so this pack takes the same field, the same limits and the same messages, proven by the same vector file and fixtures.
Read before merging: every caller that can reach the helper can have a file of the folder sent to the provider and read back in the reply. The folder is deployment configuration, and the README says so.
Defaults: the Python step's, which are RFC-0016's open questions as proposed (one root; the byte bound on source files; no page limit of the helper's own; not on
llm.stream; hidden entries refused with no switch).Checked on the full tree, installed with
npm cifrom the new lockfile:npm test827 tests, 751 passed, 0 failed, 76 skipped. Thirty-three mutations of the code, the vector file and a fixture, applied one at a time, were each caught by a test. Not done: no live call with an attachment (no token was spent), and no measurement of a PDF cut beside a running stream, which the worker thread answers by construction only.After the first pull request is merged and its branch deleted, GitHub moves this one's base to
main, as it did for the Python pair.🤖 Generated with Claude Code