Having AgentTools using Tools #7082
Replies: 2 comments
-
|
the "no parameters" error usually comes from how openai's function calling validates tool schemas - even if a tool takes no arguments you still need to pass an explicit empty parameters object. when you wrap tools on the inner agent, make sure each tool's schema includes rough pattern that works: from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.tools import AgentTool
# inner agent with its own tools
inner_agent = AssistantAgent(
name="inner",
model_client=...,
tools=[your_tool_func], # make sure these have proper type hints so the schema generates
)
# wrap it as a tool for the outer agent
inner_as_tool = AgentTool(agent=inner_agent)
outer_agent = AssistantAgent(
name="outer",
model_client=...,
tools=[inner_as_tool],
)the main thing is that the inner agent's tools need type annotations on their parameters so autogen can generate a valid json schema. if your tools take no arguments at all, you might need to pass a dummy param or restructure so the task context gets passed in. what does the tool signature look like? that'd help narrow it down. |
Beta Was this translation helpful? Give feedback.
-
|
yeah this architecture works, the trick is the inner agent's tools need proper type annotations so autogen can build the schema. if your tools genuinely take no args, wrap the context you need using a closure when you define the tool, so it gets baked in at creation time rather than passed at call time. something like: def make_my_tool(some_context):
async def my_tool(query: str) -> str:
"""Does the thing."""
return some_context.do_something(query)
return my_tool
inner_agent = AssistantAgent(
name="inner",
model_client=model_client,
tools=[make_my_tool(your_context_object)],
)
inner_as_tool = AgentTool(agent=inner_agent)the outer agent calls if you share the actual tool signatures i can be more specific. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I'm having a problem trying to work with AutoGen. I am building an agent that has an AgentTool, but I would like that AgentTool to be able to call other tools. The parameters of the tools are all instantiated at the creation of the agents and the tool has no parameters in the call but the AgentTool answer the main Agent that it has no parameters to run the tool. Is there a way to have this kind of architecture work? I hope I explained clearly the issue, if you do not understand just ask for clarifications. Thanks everyone in advance.
Beta Was this translation helpful? Give feedback.
All reactions