[PR #328] [CLOSED] fix: warn at construction time when user tools shadow built-in filesystem/shell tool names #364

Closed
opened 2026-06-05 17:22:49 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/328
Author: @wicked-tc130
Created: 3/19/2026
Status: Closed

Base: mainHead: fix/detect-builtin-tool-name-collision


📝 Commits (2)

  • 8d43b5a fix: warn when user tools shadow built-in filesystem/shell tool names
  • 5f24451 chore: add changeset for built-in tool collision warning

📊 Changes

2 files changed (+36 additions, -0 deletions)

View changed files

.changeset/warn-builtin-tool-collision.md (+5 -0)
📝 libs/deepagents/src/agent.ts (+31 -0)

📄 Description

Closes #327

Problem

When a caller passes a tool to createDeepAgent whose name matches one of the built-in FilesystemMiddleware tools (ls, read_file, write_file, edit_file, glob, grep, execute), the custom tool silently shadows the built-in. The model then generates a call with arguments that satisfy the custom schema but fail the built-in's strict zod schema, producing a cryptic error inside LangGraph's ToolNode:

Error invoking tool 'write_file' with kwargs {}
Invalid input: expected string, received undefined → at file_path

This is especially easy to hit when wrapping MCP servers, which commonly expose tools with generic names and permissive z.record schemas.

Solution

Add a collision check in createDeepAgent immediately after the tools parameter is destructured. When a conflict is detected a console.warn is emitted so the developer sees the problem at construction time rather than as an opaque runtime failure.

[deepagents] Warning: the following tool name(s) passed to createDeepAgent
conflict with built-in filesystem/shell tools: write_file.
The custom tools will shadow the built-ins, which may cause schema-validation
errors at runtime. Rename your tools or remove the conflicting entries.

Changes

  • libs/deepagents/src/agent.ts: add BUILTIN_TOOL_NAMES set and collision detection with console.warn.

Why console.warn and not throw?

Throwing would be a breaking change for anyone who accidentally has a collision today and whose agent still works (e.g. if the custom tool schema is compatible). A warning gives immediate, actionable feedback without breaking existing code. A follow-up could make it configurable (strict: true → throw).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/328 **Author:** [@wicked-tc130](https://github.com/wicked-tc130) **Created:** 3/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/detect-builtin-tool-name-collision` --- ### 📝 Commits (2) - [`8d43b5a`](https://github.com/langchain-ai/deepagentsjs/commit/8d43b5a7f0fc4fa20cdfc989b4fc89e36f6f93a8) fix: warn when user tools shadow built-in filesystem/shell tool names - [`5f24451`](https://github.com/langchain-ai/deepagentsjs/commit/5f24451d1567299a6098a030423d3a8a6f4cb8d2) chore: add changeset for built-in tool collision warning ### 📊 Changes **2 files changed** (+36 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/warn-builtin-tool-collision.md` (+5 -0) 📝 `libs/deepagents/src/agent.ts` (+31 -0) </details> ### 📄 Description Closes #327 ## Problem When a caller passes a tool to `createDeepAgent` whose name matches one of the built-in `FilesystemMiddleware` tools (`ls`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`, `execute`), the custom tool silently shadows the built-in. The model then generates a call with arguments that satisfy the custom schema but fail the built-in's strict zod schema, producing a cryptic error inside LangGraph's `ToolNode`: ``` Error invoking tool 'write_file' with kwargs {} Invalid input: expected string, received undefined → at file_path ``` This is especially easy to hit when wrapping MCP servers, which commonly expose tools with generic names and permissive `z.record` schemas. ## Solution Add a collision check in `createDeepAgent` immediately after the `tools` parameter is destructured. When a conflict is detected a `console.warn` is emitted so the developer sees the problem **at construction time** rather than as an opaque runtime failure. ``` [deepagents] Warning: the following tool name(s) passed to createDeepAgent conflict with built-in filesystem/shell tools: write_file. The custom tools will shadow the built-ins, which may cause schema-validation errors at runtime. Rename your tools or remove the conflicting entries. ``` ## Changes - `libs/deepagents/src/agent.ts`: add `BUILTIN_TOOL_NAMES` set and collision detection with `console.warn`. ## Why `console.warn` and not `throw`? Throwing would be a breaking change for anyone who accidentally has a collision today and whose agent still works (e.g. if the custom tool schema is compatible). A warning gives immediate, actionable feedback without breaking existing code. A follow-up could make it configurable (`strict: true` → throw). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 17:22:49 -04:00
yindo closed this issue 2026-06-05 17:22:49 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#364