fix(deepagents): use file_path in read_file prompt examples - #644
Open
Mike Frolov (TrueNight) wants to merge 1 commit into
Open
fix(deepagents): use file_path in read_file prompt examples#644Mike Frolov (TrueNight) wants to merge 1 commit into
Mike Frolov (TrueNight) wants to merge 1 commit into
Conversation
The read_file tool schema requires `file_path`, but the built-in tool
description and the skills workflow prompt illustrated the call as
`read_file(path, ...)`. Models copying the example emitted a `path`
argument and failed schema validation:
Invalid input: expected string, received undefined
-> at file_path
Align the four example lines in fs.ts and skills.ts with the schema, and
guard the read_file examples with a test that derives the allowed
argument names from the tool's schema (so the examples can never again
name a parameter the tool does not accept).
🦋 Changeset detectedLatest commit: 15d9263 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 |
|
Mike Frolov (@TrueNight) 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: |
Colin Francis (colifran)
pushed a commit
that referenced
this pull request
Jul 8, 2026
…th atomic update support and testing (#659) ## Problem Addresses #658. When using weaker or custom LLMs (e.g., smaller open-source models) in `deepagents` and consumers like `openwiki`, the agent immediately crashes with a schema validation error on the first filesystem tool call: This occurs because: 1. `ls` defines its directory argument as `path`, but `read_file`, `write_file`, and `edit_file` expect `file_path`. Models often default to `path` across all filesystem tools. 2. The description prompt examples in `fs.ts` and `skills.ts` show `read_file(path, ...)`, instructing models to use the wrong parameter name. ## Proposed Changes This PR solves both prompt inconsistencies and schema validation failures with a fully backward-compatible input normalization helper: 1. **Prompt Alignment**: Fixed references in `fs.ts` and `skills.ts` to instruct the model to use `file_path` (aligned with the prompt fixes in #644). 2. **Schema Input Normalization**: Added a `normalizeFilePathInput` preprocessor helper to the `read_file`, `write_file`, and `edit_file` Zod schemas using `z.preprocess`. This dynamically maps the `path` key to `file_path` if the model still passes `path`. ## Verification & Tests - Added unit tests in `fs.test.ts` to assert that: - `path` parameter normalization maps correctly to `file_path` for `read_file`, `write_file`, and `edit_file`. - All instruction examples contain only valid schema fields. - Verified that `zod-to-json-schema` unwraps the `z.preprocess` layer perfectly, preserving the original schema descriptions and definitions sent to the LLM. - Ran all filesystem tests successfully (`npx vitest run src/middleware/fs.test.ts` passes).
Author
|
Hi Hunter Lovell (@hntrl)! Could you take a look at this PR when you have a moment? It’s ready for review |
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
read_filetool schema requires the argumentfile_path, but two built-in prompts illustrate the call with an argument namedpath:READ_FILE_TOOL_DESCRIPTIONinlibs/deepagents/src/middleware/fs.ts(read_file(path, limit=...),read_file(path, offset=..., limit=...))libs/deepagents/src/middleware/skills.ts(read_file(path, limit=...))Models that copy the example emit a
pathargument and fail schema validation on the very first read:Change
Align the four example lines with the actual schema by renaming the example argument
path→file_path. This is a prompt/documentation fix only — the tool schema (file_path) is unchanged, so there is no API/behavior change for callers.Test
Adds one test under
createFilesystemMiddleware › toolsinfs.test.tsthat derives the allowed argument names from theread_filetool's schema (schema.toJSONSchema().properties) and asserts every argument shown in the tool description'sread_file(...)examples is one of them. It fails if an example ever references an argument the tool does not accept (verified red before this change, green after).Verification
pnpm build— passespnpm --filter deepagents typecheck— passespnpm --filter deepagents test:unit— 1177 passedA patch changeset is included.