fix(deepagents): degrade unsupported binaries in read_file instead of crashing the run - #649
Open
Kamal Gurbanov (kamaalg) wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 8fe9dc9 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 |
|
Someone 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: |
… crashing
read_file returned every non-text, non-image/audio/video binary as a
{ type: "file" } content block. For any MIME type other than
application/pdf this yields a provider request that is rejected:
Anthropic fails the whole turn with
`messages.N...document.source.base64.media_type: Input should be
'application/pdf'`, and OpenAI/OpenRouter only accept PDF (and images)
via input_file. Reading a .docx/.pptx/.xlsx — or any
application/octet-stream file — therefore aborted the entire agent run.
read_file now emits a `file` block only for PDFs (the one document type
accepted across providers) and degrades other binaries to a short text
note, so the agent can keep going. Adds tests covering office-doc and
octet-stream degradation plus PDF/image passthrough.
Kamal Gurbanov (kamaalg)
force-pushed
the
fix/read-file-unsupported-binaries
branch
from
July 6, 2026 07:10
b470e14 to
8fe9dc9
Compare
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
The built-in
read_filetool (increateFilesystemMiddleware) returns any non-text binary that isn't image/audio/video as a{ type: "file", mimeType, data }content block:For every MIME type except
application/pdf, that block cannot be delivered to the model provider:document, whosemedia_typemust beapplication/pdf. It returns a hard400and the whole turn fails:input_file, so they reject it too.So the moment a deep agent reads a
.docx/.pptx/.xlsx— or any file that resolves toapplication/octet-stream— the entire run aborts. This is easy to hit in practice (e.g. an agent documenting a repository that happens to contain office files). It surfaced downstream inopenwiki, which uses the stockread_filetool.Fix
Keep emitting a
fileblock only forapplication/pdf— the one binary document type accepted across providers — and degrade any other binary to a short text note (path, MIME type, size). The agent gets a model-safe, useful result and continues instead of crashing. As a bonus, this avoids pushing large, unusable base64 blobs into the context window.Tests
Added a
read_file binary handlingsuite:.pptx) → text note, nofileblockapplication/octet-stream) → text notefileblockimageblockvitest run src/middleware/fs.test.ts→ 63 passed, no type errors.oxlintandoxfmt --checkclean. Changeset included (deepagents: patch).