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
Open
fix(tools): prevent duplicate keyword arg when MCP tool param name shadows injection key#6929s-zx wants to merge 1 commit intoagno-agi:mainfrom
s-zx wants to merge 1 commit intoagno-agi:mainfrom
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6760.
FunctionCall._build_entrypoint_args()unconditionally injects the frameworkAgentandTeamobjects intoentrypoint_argsfor any entrypoint whose signature contains parameters literally namedagentorteam. The MCPcall_toolwrapper function intentionally uses these names as optional framework-injection parameters via**kwargsforwarding. However, when the actual MCP tool being called (e.g. Linear'ssave_issue) also exposes a parameter namedteam(as a normal string/ID parameter), the LLM provides it inself.arguments. The subsequententrypoint(**entrypoint_args, **self.arguments)call then hasteamin both dicts, raising:Fix: Before spreading both
entrypoint_argsandself.argumentsinto the entrypoint call, remove fromentrypoint_argsany key that already exists inself.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 inFunctionCall.No regression risk: For normal (non-MCP) tools,
self.argumentsnever 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
teamparameter (e.g. Linear'ssave_issue)TypeError: got multiple values for keyword argumentagent: Agent/team: Teaminjection still work correctly