You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using weaker or custom LLMs (e.g., smaller open-source models or custom endpoints) in deepagents and consumers like openwiki, the agent immediately crashes with a schema validation error on the first read_file call:
Root Cause
There are two contributing factors to this issue:
Schema Inconsistency: The ls tool defines its directory argument as path, while read_file, write_file, and edit_file define their target file argument as file_path. Models often generalize tool naming conventions and default to using path across all filesystem tools.
Confusing Prompt Examples: Both READ_FILE_TOOL_DESCRIPTION (in fs.ts) and the skills system prompt (in skills.ts) show documentation examples instructing the model to use path, e.g. read_file(path, limit=100). Less capable models strictly copy this behavior and fail the actual Zod schema validation because it expects file_path.
Proposed Solution
We should implement both a prompt correction and a defensive input normalization layer so that filesystem tools work reliably across all model tiers.
Schema Input Normalization: Add a z.preprocess helper to read_file, write_file, and edit_file schemas to dynamically map path to file_path if the model passes path.
Implementation Example:
functionnormalizeFilePathInput(input: unknown): unknown{if(typeofinput==="object"&&input!==null&&"path"ininput&&!("file_path"ininput)){const{ path, ...rest}=inputasRecord<string,unknown>;return{ ...rest,file_path: path};}returninput;}// Wrap schemas
schema: z.preprocess(normalizeFilePathInput,z.object({file_path: z.string().describe("Absolute path to the file to read"),// ...}))
Describe the bug
When using weaker or custom LLMs (e.g., smaller open-source models or custom endpoints) in
deepagentsand consumers likeopenwiki, the agent immediately crashes with a schema validation error on the firstread_filecall:Root Cause
There are two contributing factors to this issue:
lstool defines its directory argument aspath, whileread_file,write_file, andedit_filedefine their target file argument asfile_path. Models often generalize tool naming conventions and default to usingpathacross all filesystem tools.READ_FILE_TOOL_DESCRIPTION(infs.ts) and the skills system prompt (inskills.ts) show documentation examples instructing the model to usepath, e.g.read_file(path, limit=100). Less capable models strictly copy this behavior and fail the actual Zod schema validation because it expectsfile_path.Proposed Solution
We should implement both a prompt correction and a defensive input normalization layer so that filesystem tools work reliably across all model tiers.
fs.tsandskills.tsto usefile_path(as initiated in PR fix(deepagents): use file_path in read_file prompt examples #644).z.preprocesshelper toread_file,write_file, andedit_fileschemas to dynamically mappathtofile_pathif the model passespath.Implementation Example: