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

How to specify the next agent? #187

Closed
huangbhan opened this issue Mar 17, 2025 · 5 comments
Closed

How to specify the next agent? #187

huangbhan opened this issue Mar 17, 2025 · 5 comments
Labels
question Question about using the SDK

Comments

@huangbhan
Copy link

generate_sql_agent = Agent(
        name="generate sql Agent",
        instructions='''
            1. You are responsible for generating SQL statements based on user requests..
           '''
        handoffs=[sql_checker_agent],
    )

 sql_checker_agent = Agent(
        name="SQL Checker Agent",
        handoff_description="Check the SQL statement generated based on the user's request.",
        instructions='''You are responsible for checking the SQL statement generated based on the user's request.
        ''',
        tools=[task_query],
    )

I am worried that handoffs may not be triggered. I need to ensure that sql_checker_agent is called after generate_sql_agent.
In the documentation(https://openai.github.io/openai-agents-python/multi_agent/) I found this: "Chaining multiple agents by transforming the output of one into the input of the next. You can decompose a task like writing a blog post into a series of steps - do research, write an outline, write the blog post, critique it, and then improve it."
But how to implement it with code?

@huangbhan huangbhan added the question Question about using the SDK label Mar 17, 2025
@DanieleMorotti
Copy link

Hi, if I'm not wrong this example from the github repo may be what you're looking for.
It first plans searches, then it actually performs them and at the end it writes a report.

@tameverfit
Copy link

hi @DanieleMorotti, do you have any advice on ensuring the agent can be handed off correctly when the chat history is too long?

@DanieleMorotti
Copy link

Hi, I believe this issue can be addressed using standard chat techniques.
It might be useful to summarize the conversation history to reduce token count. Perhaps you could implement an agent that automatically condenses the history once it exceeds a certain threshold.

These are just my opinions, so take them with a grain of salt :)

@huangbhan
Copy link
Author

huangbhan commented Mar 18, 2025

Yes, that's exactly what I want. Do you have any plans to add some code examples like this to the documentation? I think this will help people in need more quickly.

Hi, if I'm not wrong this example from the github repo may be what you're looking for.It first plans searches, then it actually performs them and at the end it writes a report.

@DanieleMorotti
Copy link

@rm-openai may answer to this. But if you're looking for other examples, there are some in the examples directory.

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