Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"agent.as_tool" not working with Gemini #243

Open
aasherkamal216 opened this issue Mar 19, 2025 · 2 comments
Open

"agent.as_tool" not working with Gemini #243

aasherkamal216 opened this issue Mar 19, 2025 · 2 comments
Labels
question Question about using the SDK

Comments

@aasherkamal216
Copy link

I have created 3 agents and passed them to an orchestrator agent as tools. But when orchestrator tries to call these agents (tools), it says an error occurred.

Did anybody else face similar issue with "agent.as_tool"??
(I am using google gemini 2.0 flash)

@aasherkamal216 aasherkamal216 added the question Question about using the SDK label Mar 19, 2025
@rm-openai
Copy link
Collaborator

Could you share the error (and ideally reproducible code)

@EnggQasim
Copy link
Contributor

EnggQasim commented Mar 19, 2025

Below code is working on my side

import asyncio
from agents import Agent, ItemHelpers, MessageOutputItem, Runner, trace

spanish_agent = Agent(
    name="spanish_agent",
    instructions="You translate the user's message to Spanish",
    handoff_description="An english to spanish translator",
    model=model
)

french_agent = Agent(
    name="french_agent",
    instructions="You translate the user's message to French",
    handoff_description="An english to french translator",
    model=model
)

italian_agent = Agent(
    name="italian_agent",
    instructions="You translate the user's message to Italian",
    handoff_description="An english to italian translator",
    model=model
)

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 in order."
        "You never translate on your own, you always use the provided 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",
        ),
        italian_agent.as_tool(
            tool_name="translate_to_italian",
            tool_description="Translate the user's message to Italian",
        ),
    ],
    model=model
)


async def main():
    msg = input("Hi! What would you like translated, and to which languages? ")

    orchestrator_result = await Runner.run(orchestrator_agent, msg)
    print(f"\n\nFinal response:\n{orchestrator_result.final_output}")


if __name__ == "__main__":
    asyncio.run(main())

you can check this link : https://github.com/panaversity/learn-agentic-ai/blob/main/00_openai_agents/08_agents_as_tool/agents_as_tools.ipynb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK
Projects
None yet
Development

No branches or pull requests

3 participants