Skip to content

fix(sdk): deduplicate subagents by name in SubAgentMiddleware#1675

Open
IHEII (IHEII) wants to merge 1 commit intolangchain-ai:mainfrom
IHEII:dev
Open

fix(sdk): deduplicate subagents by name in SubAgentMiddleware#1675
IHEII (IHEII) wants to merge 1 commit intolangchain-ai:mainfrom
IHEII:dev

Conversation

@IHEII
Copy link

Issue description

When multiple subagent specs share the same name are registered, _build_task_tool previously built the subagent_graphs dict and description string directly from the raw list, resulting in duplicate entries in the tool description presented to the LLM.

How this commit works

This fix deduplicates subagents by name (last-one-wins) before building the graphs dict and description string, ensuring each subagent appears only once.

How was this verified?

Manually tested with a configuration that registers duplicate subagent names and confirmed the generated tool description no longer contains duplicates.

@github-actions github-actions bot added deepagents Related to the `deepagents` SDK / agent harness external User is not a member of the `langchain-ai` GitHub organization fix A bug fix (PATCH) labels Mar 6, 2026
@eyurtsev
Copy link
Collaborator

Could you include a unit test and an MRE to explain how you're launching things?

It's more likely that we'll want to raise a run time error rather than fail silently with last to win

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents Related to the `deepagents` SDK / agent harness external User is not a member of the `langchain-ai` GitHub organization fix A bug fix (PATCH)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants