Skip to content

Sub-Agent Usage in Multi-Agent System with Agent.as_tool #1108

@ahouse73

Description

@ahouse73

Please read this first

  • Have you read the docs? Yes
  • Have you searched for related issues? Yes

Question

TL;DR Can intermediate agents dynamically invoke their own tools/sub-agents during execution?

I am using the Agent SDK to develop a Multi-Agent System (MAS) and have implemented a hierarchical communication schema where agents delegate tasks to sub-agents. Each sub-agent is registered using Agent.as_tool, as I want the responses from sub-agents to be again utilized and no delegation of the task.

In my setup, I created a 3-level hierarchy:

  1. Level 1: Delegation agent (agent1) delegates tasks based on user input.
  2. Level 2: Translation agent (agent2), which should use its sub-agent tools for translation tasks.
  3. Level 3: Spanish-speaking agent (agent3), responsible for translating text into Spanish.

However, when testing this hierarchy, it seems that agent2 does not utilize its own sub-agent (agent3). Instead, agent2 responds directly without invoking the tool (translate_to_spanish) provided by agent3.

Is this behavior expected? Am I missing something in how tools or delegation work within nested agents?

Minimal example

from agents import Agent, Runner
import asyncio

agent3 = Agent(
    name="Spanish agent",
    instructions="You only speak Spanish.",
)

agent2 = Agent(
    name="Translation agent",
    instructions=(
        "You are a translation agent. You use the tools given to you to translate."
        "If asked for multiple translations, you call the relevant tools."
    ),
    tools=[
        agent3.as_tool(tool_name="translate_to_spanish", tool_description="Translate the user's message to Spanish")
    ],
)

agent1 = Agent(
    name="Delegation agent",
    instructions="Handoff to the appropriate agent based of the task of the request.",
    tools=[
        agent2.as_tool(tool_name="translation", tool_description="Translate the users message to different languages")
    ],
)


async def main():
    r = await Runner.run(agent1, input="Say 'Hello, how are you?' in Spanish.")
    print(r.final_output)
    # ¡Hola! Estoy bien, gracias por preguntar. ¿Y tú, cómo estás?
    return r

r = await main()

Observed Behavior

For this example:

  • The question is answered directly by agent2.

Expected Behavior

  • I would expect agent2 to invoke its tool (translate_to_spanish) provided by agent3. However, this does not happen — even though both agents and their respective tools are properly configured.

I tried different prompts and configurations but consistently observed that intermediate agents (e.g. agent2) do not utilize their own sub-agents/tools.

Any guidance or clarification regarding multi-agent delegation and tool invocation would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions