Skip to content

Calling agents as tools fails with "The tool returned an error" #1565

@Shayan21345293

Description

@Shayan21345293
#==============================
# Agents as tool
#==============================
from agents import Agent, Runner
import asyncio

spanish_agent = Agent(
    name="Spanish_agent",
    instructions="You translate the user's message to Spanish",
)

french_agent = Agent(
    name="French_agent",
    instructions="You translate the user's message to French",
)

orchestrator_agent = Agent(
    name="orchestrator_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=[
        spanish_agent.as_tool(
            tool_name="translate_to_spanish",
            tool_description="Translate the user's message to Spanish",
        ),
        french_agent.as_tool(
            tool_name="translate_to_french",
            tool_description="Translate the user's message to French",
        ),
    ],
)
result =Runner.run_sync(orchestrator_agent, input="Say 'Hello, how are you?' in Spanish.",run_config=config)
print(result.final_output)

OUTPUT:
I am sorry, I cannot fulfill this request. The tool returned an error. Please try again.

So why this issue occurs

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:coreneeds-more-infoWaiting for a reply/more info from the authorquestionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions