fix(deepagents): read_file must not emit unsendable document blocks for non-PDF binaries - #647
Open
Idan Shperling (Idan-Shperling) wants to merge 1 commit into
Conversation
…or non-PDF binaries read_file base64-encodes any non-text file into a `type: "file"` block, which provider adapters translate into a document block. Provider APIs only accept `application/pdf` for base64 document blocks, so reading any other binary (fonts, wasm, archives, etc.) fails with a 400: `document.source.base64.media_type: Input should be 'application/pdf'`. Gate the document block on application/pdf and return a short text note for other binary types. image/audio/video blocks and PDFs are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: ef5cde8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Idan Shperling (@Idan-Shperling) is attempting to deploy a commit to the LangChain Team on Vercel. A member of the Team first needs to authorize it. |
deepagents-acp
deepagents
@langchain/sandbox-standard-tests
@langchain/daytona
@langchain/deno
@langchain/modal
@langchain/node-vfs
@langchain/quickjs
commit: |
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.
Problem
read_filebase64-encodes any non-text file into atype: "file"content block, which provider adapters translate into a document block. Provider APIs only acceptapplication/pdffor base64 document blocks, so as soon as an agent reads any other binary file in a repo (fonts,.wasm, archives,.ico, etc.) the request fails:This makes
read_file(and thus any deep agent) unusable on repositories that contain non-PDF binaries — the agent only has to read one to hard-fail the run.Fix
In
createReadFileTool(libs/deepagents/src/middleware/fs.ts), gate thetype: "file"document block onapplication/pdf. Any other binary type returns a short text note instead of an unsendable block.image/,audio/,video/blocks and PDFs are unchanged.Tests
Added two unit tests in
fs.test.ts:application/octet-stream) → text note, never atype: "file"block (fails onmain).application/pdf→ still returns the document block (regression guard).oxfmt+oxlintclean.Context
Hit while running OpenWiki (which uses deepagents) against a large repo — the agent read a non-PDF binary and every run 400'd.