---
type: email
from: Areeba Fatima <notifications@github.com>
subject: Re: [openai/openai-agents-python] Calling agents as tools fails with

 "The tool returned an error" (Issue #1565)
received: 2026-03-06 07:15:30
date_header: Tue, 26 Aug 2025 23:57:58 -0700
priority: normal
status: awaiting_approval
uid: 28769
---

## Email Content

**From:** Areeba Fatima <notifications@github.com>
**Subject:** Re: [openai/openai-agents-python] Calling agents as tools fails with

 "The tool returned an error" (Issue #1565)
**Date:** Tue, 26 Aug 2025 23:57:58 -0700

### Body (preview)

AREEBA-FATIMA left a comment (openai/openai-agents-python#1565)



I ran into the same issue when calling agents as tools. The root cause is that each Agent requires its own model configuration, but in the current example no model was passed into the sub-agents (spanish_agent and french_agent).



When using Gemini’s API key through the OpenAI-compatible endpoint, tools don’t work out-of-the-box because Gemini doesn’t fully support the agent-as-tool pattern. The fix is to explicitly configure the model for each agent, for example:

```



spanish_agent = Agent(

    name="Spanish_agent",

    instructions="You translate the user's message to Spanish",

    model=model   # provide model here

)



french_agent = Agent(

    name="French_agent",

    instructions="You translate the user's message to French",

    model=model   # provide model here

)



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",

        ),

    ],

    model=model  # orchestrator also needs the model

)

```





With this change, the orchestrator can successfully call the sub-agents as tools, even when using Gemini via the OpenAI-compatible base URL.



So in short:



- Gemini API doesn’t natively support agent-as-tool



- To make it work, you must explicitly pass model=model into every agent (or else you’ll see "The tool returned an error"). 



Hope this clears it up!



-- 

Reply to this email directly or view it on GitHub:

https://github.com/openai/openai-agents-python/

---

## Suggested Actions
- [ ] Reply
- [ ] Archive
- [ ] Escalate
