-
Notifications
You must be signed in to change notification settings - Fork 1.6k
How to dynamically add/remove tools in a tool_use_behavior="run_llm_again"
-loop
#767
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
This is a good question. I'll have to think of a long term good answer, but the short term hack is: just add the tools in the
|
Thanks @rm-openai , unfortunately, it seems that extending the tools isn't enough reason to refresh the openai-agents-python/src/agents/run.py Line 518 in 6e078bf
run_llm_again loop (or I tested it wrong, ofc also possible).
Any other ideas? |
Ah you're totally right. Let me fix this - we shouldn't be caching the tools list. |
### Summary: Towards #767. We were caching the list of tools for an agent, so if you did `agent.tools.append(...)` from a tool call, the next call to the model wouldn't include the new tool. THis is a bug. ### Test Plan: Unit tests. Note that now MCP tools are listed each time the agent runs (users can still cache the `list_tools` however).
### Summary: Towards #767. We were caching the list of tools for an agent, so if you did `agent.tools.append(...)` from a tool call, the next call to the model wouldn't include the new tool. THis is a bug. ### Test Plan: Unit tests. Note that now MCP tools are listed each time the agent runs (users can still cache the `list_tools` however).
### Summary: Towards #767. We were caching the list of tools for an agent, so if you did `agent.tools.append(...)` from a tool call, the next call to the model wouldn't include the new tool. THis is a bug. ### Test Plan: Unit tests. Note that now MCP tools are listed each time the agent runs (users can still cache the `list_tools` however).
@Afstkla this is now fixed. I'd recommend using |
Please read this first
Question
I'm building an agent that's often running multiple tool calls sequentially, and sometimes tool
A
will 'unlock' toolsB
,C
, andD
. But I so far haven't found a way to 'inject' those during an automatedrun_llm_again
loop. And I'm really dreading writing all the logic required to manually handle the run loop.I've attempted using the
Hooks
to dynamically add new tools, I've been trying to work with various differentAgent
s as tools, where the tools of thoseAgent
s are added dynamically through the hooks. The only thing that's semi worked for me is to use thehandoff
feature, but then I can't give control back to the 'main' agent.My agent's flow will normally be like:
Runner
startsRunner
exitsBut this is a workflow that I can't currently figure out. Is there a way?
The text was updated successfully, but these errors were encountered: