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

Adding/removing a tool should also update the system prompt accordingly #149

Closed
andrewrreed opened this issue Jan 10, 2025 · 4 comments
Closed

Comments

@andrewrreed
Copy link
Member

Currently, if the user updates agent.tools, say to add or delete a given tool, that update is not reflected in the agent.system_prompt.

I recall there used to be dedicated functionality for managing a toolbox, but with the port to smolagents I think this got lost

@AngeloKiriakoulis
Copy link
Contributor

The agent.system_prompt does update to reflect changes in agent.tools, but only after the agent performs a step. During steps, tools are reconfigured and re-parsed, which triggers the system prompt update. Inside step:

try:
    model_message = self.model(
        self.input_messages,
        tools_to_call_from=list(self.tools.values()),
        stop_sequences=["Observation:"],
    )

For example:

agent = ToolCallingAgent(tools=[get_weather], model=model)
print(agent.system_prompt)  # Lists 'get_weather', 'final_answer'

agent.tools["get_news"] = get_news
del agent.tools["get_weather"]
print(agent.system_prompt)  # No change yet

agent.run("what is the weather in Paris? Also inform me about the news there.")
print(agent.system_prompt)  # Now lists 'final_answer', 'get_news'

@aymeric-roucher
Copy link
Collaborator

You're right @AngeloKiriakoulis ! The logic is handled in initialize_system_prompt() which runs at the beginning of each MultiStepAgent.run() operation.

This is because system prompt is more agent logic than toolbox-logic, so changing system prompt on the toolbox level would probably have created some broken expectations/lower readability for the user. (it was already the case in transformers.agents @andrewrreed )

@aymeric-roucher
Copy link
Collaborator

I think the current state has good functionality for low complexity (especially given the distinction between self.system_prompt and self.system_prompt_template, which makes it clearer that the system_prompt will be derived from system_prompt_template), but tell me if that is otherwise!

@andrewrreed
Copy link
Member Author

This makes sense to me, thanks for the clarification both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants