Reputation: 837
I am writing following agent conversation:
from autogen import ConversableAgent
from typing import Annotated
from model_config import get_model_config
llm_config = get_model_config('GPT-4o')
# Define simple calculator functions
def add_numbers(
a: Annotated[int, "First number"], b: Annotated[int, "Second number"]
) -> str:
print(f"Adding {a} and {b}")
return f"The sum of {a} and {b} is {a - b}." ### Mistake is in purpose!!! ###
# Define the assistant agent that suggests tool calls.
assistant = ConversableAgent(
name="CalculatorAssistant",
system_message="You are a helpful AI calculator. Return 'TERMINATE' when the task is done.",
llm_config=llm_config,
)
# The user proxy agent is used for interacting with the assistant agent and executes tool calls.
user_proxy = ConversableAgent(
name="User",
is_termination_msg=lambda msg: msg.get("content") is not None
and "TERMINATE" in msg["content"],
human_input_mode="NEVER",
)
# Register the tool signatures with the assistant agent.
assistant.register_for_llm(name="add_numbers", description="Add two numbers")(
add_numbers
)
# Register the tool functions with the user proxy agent.
user_proxy.register_for_execution(name="add_numbers")(add_numbers)
user_proxy.initiate_chat(assistant, message="What is the sum of 9 and 6?")
I expect that the result will be: The sum of 9 and 6 is 3.
But I get the following result:
User (to CalculatorAssistant):
What is the sum of 9 and 6?
--------------------------------------------------------------------------------
>>>>>>>> USING AUTO REPLY...
CalculatorAssistant (to User):
***** Suggested tool call (call_IRs1aIYp0h7zv5dJReyAlLT0): add_numbers *****
Arguments:
{"a":9,"b":6}
****************************************************************************
--------------------------------------------------------------------------------
>>>>>>>> EXECUTING FUNCTION add_numbers...
Adding 9 and 6
User (to CalculatorAssistant):
User (to CalculatorAssistant):
***** Response from calling tool (call_IRs1aIYp0h7zv5dJReyAlLT0) *****
The sum of 9 and 6 is 3.
**********************************************************************
--------------------------------------------------------------------------------
>>>>>>>> USING AUTO REPLY...
CalculatorAssistant (to User):
**The sum of 9 and 6 is 15. TERMINATE**
It seems that the agent does not relay on the tool result and have a "second opinion" on it.
Is it possible to force the tool result on the agent?
Upvotes: 0
Views: 35