Skip to content

fix(tools): prevent duplicate keyword arg when MCP tool param name shadows injection key#6929

Open
s-zx wants to merge 1 commit intoagno-agi:mainfrom
s-zx:fix/6760-mcp-tool-param-name-collision
Open

fix(tools): prevent duplicate keyword arg when MCP tool param name shadows injection key#6929
s-zx wants to merge 1 commit intoagno-agi:mainfrom
s-zx:fix/6760-mcp-tool-param-name-collision

Conversation

@s-zx
Copy link

@s-zx s-zx commented Mar 9, 2026

Summary

Fixes #6760.

FunctionCall._build_entrypoint_args() unconditionally injects the framework Agent and Team objects into entrypoint_args for any entrypoint whose signature contains parameters literally named agent or team. The MCP call_tool wrapper function intentionally uses these names as optional framework-injection parameters via **kwargs forwarding. However, when the actual MCP tool being called (e.g. Linear's save_issue) also exposes a parameter named team (as a normal string/ID parameter), the LLM provides it in self.arguments. The subsequent entrypoint(**entrypoint_args, **self.arguments) call then has team in both dicts, raising:

TypeError: functools.partial(...) got multiple values for keyword argument 'team'

Fix: Before spreading both entrypoint_args and self.arguments into the entrypoint call, remove from entrypoint_args any key that already exists in self.arguments. This lets the LLM-provided value win and eliminates the collision. The change applies to both the sync (execute) and async (aexecute) code paths in FunctionCall.

No regression risk: For normal (non-MCP) tools, self.arguments never contains framework-reserved names (agent, team, run_context, etc.) because the LLM only sees user-defined parameters. The deduplication only takes effect when there is an actual name collision.

Test Plan

  • Create an agent with MCPTools connected to a server that exposes a tool with a team parameter (e.g. Linear's save_issue)
  • Verify the tool call succeeds without TypeError: got multiple values for keyword argument
  • Verify that regular agents with tools using agent: Agent / team: Team injection still work correctly

… injection key

FunctionCall._build_entrypoint_args() injects framework objects (Agent,
Team, RunContext) as kwargs keyed by their parameter names. If an MCP
tool's own schema has a parameter literally named 'agent' or 'team',
_build_entrypoint_args pre-fills that key with the framework object.
When aexecute then calls entrypoint(**entrypoint_args, **self.arguments)
the same key appears in both dicts, raising:

  TypeError: got multiple values for keyword argument 'team'

Fix: strip from entrypoint_args any key that already exists in
self.arguments before spreading both dicts into the call. This lets
the LLM-provided value win and avoids the collision without changing
the framework-injection behaviour for normal tools.

Fixes agno-agi#6760.
@s-zx s-zx requested a review from a team as a code owner March 9, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MCPTools: TypeError "got multiple values for keyword argument" when tool has parameter named 'team' or 'agent'

1 participant