fix(deepagents): avoid non-standard 'file' content block for binary files#651
Open
Robin (robinv8) wants to merge 3 commits into
Open
fix(deepagents): avoid non-standard 'file' content block for binary files#651Robin (robinv8) wants to merge 3 commits into
Robin (robinv8) wants to merge 3 commits into
Conversation
OpenAI-compatible providers such as DeepSeek reject the non-standard `type: "file"` content block produced by read_file for binary files (e.g. PDFs). Fall back to a text placeholder that preserves the MIME type and size metadata while keeping the request compatible. Fixes errors like: unknown variant `file`, expected `text` at line 1 column ...
🦋 Changeset detectedLatest commit: 7015d8c 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 |
|
Robin (@robinv8) 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: |
582b6b6 to
fb7a585
Compare
fb7a585 to
45ba254
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
When a binary file (e.g. PDF, archive, executable) is read via the
read_filetool, the middleware returns a content block withtype: "file". This content block is not part of the OpenAI chat completions message format and is rejected by OpenAI-compatible providers such as DeepSeek:As a result, agents using these providers crash as soon as they encounter a non-media binary file.
Change
For binary files that are not image/audio/video, fall back to a
type: "text"placeholder that preserves the MIME type and byte size metadata, while omitting the base64 payload. Image/audio/video blocks continue to be returned as before because providers that support vision/audio understand those block types.Test coverage
Added two unit tests in
fs.test.ts:textplaceholder.imageblock.◇ injected env (0) from ../../.env // tip: ⌁ auth for agents [www.vestauth.com]
RUN v4.1.9 /private/tmp/deepagentsjs-fork/libs/deepagents
✓ src/middleware/fs.test.ts (61 tests) 25ms
Test Files 1 passed (1)
Tests 61 passed (61)
Type Errors no errors
Start at 11:28:19
Duration 324ms (transform 69ms, setup 0ms, import 242ms, tests 25ms, environment 0ms)
Checklist