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

[Feature Request]: Dynamically removing tools during agent conversation when the tools are not needed or not useful. #2666

Open
WebsheetPlugin opened this issue May 11, 2024 · 3 comments
Labels
enhancement New feature or request function/tool suggestion and execution of function/tool call

Comments

@WebsheetPlugin
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

To save tokens or improve GPT responses, it makes sense to remove certain tools when they are no longer needed.

Describe the solution you'd like

autogen.agentchat.unregister_function(
hello_world,
caller=picker,
executor=picker
)

Additional context

No response

@WebsheetPlugin WebsheetPlugin added the enhancement New feature or request label May 11, 2024
@Gr3atWh173
Copy link
Collaborator

Gr3atWh173 commented May 12, 2024

Can you please provide an example scenario where this will be useful?

@WebsheetPlugin
Copy link
Collaborator Author

Sure, I use this in my other chatbot all the time. Let's say you have diferent tools available for the Agent to choose from, but when a tool fails, because it's impossible to execute, you might want to remove it, save tokens, and let the Agent use other tools instead to complete the job.

Another example is simply removing tools to save tokens. Very often you can assume that certain tools will not be needed when other tools have been already picked. For example, if the Agent picked a weather_info tool, then you can assume that the stock_info tool might be not needed. So you remove it.

@ekzhu ekzhu added the function/tool suggestion and execution of function/tool call label May 21, 2024
@ekzhu ekzhu changed the title [Feature Request]: Remove Tools [Feature Request]: Dynamically removing tools during agent conversation May 21, 2024
@ekzhu ekzhu changed the title [Feature Request]: Dynamically removing tools during agent conversation [Feature Request]: Dynamically removing tools during agent conversation when the tools are not needed or not useful. May 21, 2024
@WebsheetPlugin
Copy link
Collaborator Author

Some observations:

  1. there is method update_tool_signature which even has "is_remove" flag. But it seems removing the function only from llm_config["tools"] but from function_map

I am not sure this is an issue for execution..

I was able to acomplish this feature myself with this code:

def remove_tool(agent, tool_name):
    """Remove tool from the tool list"""
    tools = agent.llm_config.get("tools")
    tools = [tool for tool in tools if tool.get("function", {}).get("name") != tool_name]
    agent.llm_config["tools"] = tools
    map_ =  agent._function_map
    del map_[tool_name]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request function/tool suggestion and execution of function/tool call
Projects
None yet
Development

No branches or pull requests

3 participants