-
Notifications
You must be signed in to change notification settings - Fork 1.5k
How to set max_turn for agents set as tools. #497
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
Comments
Just added some docs for this here: #504 |
I see, but does this also applies for MCP tools? Since I'm also using tools obtained from MCP servers, I don't get to modify the tool implementations. |
Well MCP tools don't have a max_turns param - what are you trying to achieve with MCP tools? |
For example, Browser control MCP tool/agents often runs more than 10 turns. Each time the main agent gives another agent as tool a small task to finish on its own, and just report back the results. That way my main agent only sees the result and so my total context is reduced a bit, and so the agent can focus on accomplishing the big task without derailing its attention during the process. openai-agents-python/src/agents/run.py Line 47 in e8f14da
I see that the default max turn is hard coded here, can we modify it so that this can be override with some kind, environment variables perhaps? |
@yongkangzhao I think I'm not totally following.
You can just pass the |
This is a quick example, don't actually run it, it wouldn't take 10 turns.
I don't see a way for me to adjust the max_turn of browser_agent Agent here. |
@yongkangzhao do this instead:
then do That should do what you need. |
oh! 😳 Literally agent as tool 🤦♂️. Thank you! I also had to add async in front of def. Works for me now, thank you! |
Awesome, closing this out then. |
Uh oh!
There was an error while loading. Please reload this page.
Please read this first
YES, seems max_turn is only available to be set at Runner. but with the implementation of agents as tools, I don't get access to the Runner of the tool agents.
YES couldn't find any
Question
Describe your question. Provide details if available.
How to set max_turn when agents are being used as tools.
I have serveral agents as tool use case. and the main agent can set Runner.run(max_turn), but I couldn't figure out where so inject max_turn limits for agents created as tools.
exactly like this example here: https://github.com/openai/openai-agents-python/blob/main/examples/agent_patterns/agents_as_tools.py
if it is not already implemented, I would suggest having a parameters for Agent, so that each agent can have a different max_turn limits, while Runner.run max_turn can override it.
thanks!
The text was updated successfully, but these errors were encountered: