langchain-ai/deepagents · error · ValueError
Context tool names conflict with criteria-agent tools: {name
Error message
Context tool names conflict with criteria-agent tools: {names}. What it means
`_create_goal_criteria_agent` builds an internal sub-agent whose tool namespace contains reserved names: the structured-output tool and, when a repository backend is attached, the repository tool set. If caller-supplied `context_tools` include a tool whose name collides with a reserved name, the factory raises this `ValueError` listing the conflicting names.
Source
Thrown at libs/code/deepagents_code/goal_rubric.py:1685
if isinstance(tool, BaseTool):
normalized_context_tools.append(tool)
elif inspect.iscoroutinefunction(tool):
normalized_context_tools.append(
StructuredTool.from_function(coroutine=tool)
)
else:
normalized_context_tools.append(StructuredTool.from_function(func=tool))
reserved_names = {_STRUCTURED_OUTPUT_TOOL_NAME}
if repository_backend is not None:
reserved_names.update(_REPOSITORY_TOOL_NAMES)
conflicting_names = sorted(
tool.name for tool in normalized_context_tools if tool.name in reserved_names
)
if conflicting_names:
names = ", ".join(conflicting_names)
msg = f"Context tool names conflict with criteria-agent tools: {names}."
raise ValueError(msg)
middleware: list[AgentMiddleware[Any, Any]] = [
ConfigurableModelMiddleware(
persist_model_state=False,
cli_max_retries=cli_max_retries,
),
_GoalContextFallbackMiddleware(),
_WebSearchBudgetMiddleware(),
_CriteriaContextBudgetMiddleware(),
CodeModelRetryMiddleware(max_retries=model_retries),
]
if repository_backend is not None:
# Annotated (not `cast`) so the type checker validates each literal
# against `FsToolName` and rejects a typo at check time.
repository_tools: list[FsToolName] = ["ls", "read_file", "glob", "grep"]
if fs_tools is not None:
repository_tools = [name for name in repository_tools if name in fs_tools]
middleware.extend(
[View on GitHub (pinned to a1af029e6e)
Solutions
- Filter `context_tools` to exclude any tool whose name is in the reserved set before calling the factory.
- Rename your custom tool to a distinct name that doesn't collide with repository or structured-output tool names.
- If you intended repository tools in the sub-agent, pass the `repository_backend` instead of hand-listing its tools as context tools.
Example fix
// before
agent = create_goal_criteria_agent(context_tools=all_parent_tools)
// after
reserved = {structured_output_tool_name, *repository_tool_names}
agent = create_goal_criteria_agent(context_tools=[t for t in all_parent_tools if t.name not in reserved]) Defensive patterns
Strategy: validation
Validate before calling
reserved = {structured_output_tool_name} | set(repository_tool_names if repository_backend else [])
conflicts = sorted(t.name for t in context_tools if t.name in reserved)
if conflicts:
raise ValueError(f"rename or drop tools conflicting with reserved names: {conflicts}") Type guard
def has_no_reserved_names(context_tools, reserved_names: set[str]) -> bool:
return not any(tool.name in reserved_names for tool in context_tools) Try / catch
try:
agent = create_goal_criteria_agent(context_tools=tools, repository_backend=backend)
except ValueError as e:
if "conflict with criteria-agent tools" in str(e):
tools = [t for t in tools if t.name not in reserved_names]
agent = create_goal_criteria_agent(context_tools=tools, repository_backend=backend) Prevention
- Never forward the parent agent's repository/file tools as context tools — pass `repository_backend` instead.
- Prefix custom tools (e.g. `myorg_lookup`) to avoid accidental name collisions.
- Keep the reserved-name check in a shared helper used by all sub-agent factories.
When it happens
Trigger: Calling `create_goal_criteria_agent`/`create_cli_agent` with `context_tools` containing a tool named like the structured-output tool or one of the repository tools (`_REPOSITORY_TOOL_NAMES`), including tools auto-wrapped from functions/coroutines whose function names collide.
Common situations: Passing the parent agent's full tool list (including repository/file tools) as context tools instead of a filtered subset; a custom tool accidentally named the same as a reserved repository tool; allowlist-intersection code that fails to exclude reserved names.
Related errors
- Invalid {SERVER_ENV_PREFIX}ALLOW_FS_TOOLS value: unknown fil
- shell_allow_list must be None or non-empty
- Invalid interpreter_ptc string {ptc!r}; expected 'safe', 'al
- interpreter_ptc list entries cannot include 'all'; use 'all'
- Could not parse embedded resource block. Block expected eith
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/5bfe610cb7037262.
Report an issue: GitHub.