microsoft / autogen

A programming framework for agentic AI 🤖
https://microsoft.github.io/autogen/
Creative Commons Attribution 4.0 International
30.73k stars 4.48k forks source link

[Bug]: is_termination_msg:lambda x:True is invalid in GPTAssistantAgent which is subclass of ConversableAgent #1529

Closed yousonnet closed 7 months ago

yousonnet commented 7 months ago

Describe the bug

when the proxy agent send message TERMINATE to instance of GPTAssistant with is_termination_msg:lambda x:True can't end conversation

Steps to reproduce

from autogen import AssistantAgent, UserProxyAgent, ConversableAgent, GroupChat, GroupChatManager, config_list_from_json from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent from constants import openai_api_key from clients_setup import clients from typing import List from time import sleep

config_list = config_list_from_json(env_or_file="config.json")

def is_termination_msg(x):

print(x)

if (x.get("content", "").rstrip().endswith("TERMINATE")):
    print("yes")
    return True
print(x)
print("no")
return True

assistant = GPTAssistantAgent(name="Assistant", llm_config={ "seed": 42, # seed for caching and reproducibility "config_list": config_list, # a list of OpenAI API configurations "assistantid": "asst", "temperature": 0, # temperature for sampling

"request_timeout": 120, # timeout

}, is_termination_msg=lambda x: True

)

def multi_accounts_tweet(tweets: List[str]): counter = 0

for (client, tweet) in zip(clients, tweets):

#     client['account'].tweet(tweet)
#     counter += 1
#     if counter == 9:
#         break
return True

assistant.register_function( function_map={"multi_accounts_tweet": multi_accounts_tweet}) user_proxy = UserProxyAgent(name="proxy_agent", default_auto_reply="TERMINATE", human_input_mode="NEVER",

is_termination_msg=is_termination_msg,

                        code_execution_config=False)

user_proxy.initiate_chat( assistant, message="""please generate tweets,and press them by multi_accounts_tweet in one time""",)

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

No response

sonichi commented 7 months ago

@gagb @IANTHEREAL @jtrugman fyi

IANTHEREAL commented 7 months ago

@yousonnet would you like the Assistant to terminate when it receives a TERMINATE message? I think this capability is not yet supported, the implementation of the gpt_assistant does not execute a termination path now.

What are your thoughts about it? @gagb

yousonnet commented 7 months ago

@yousonnet would you like the Assistant to terminate when it receives a TERMINATE message? I think this capability is not yet supported, the implementation of the gpt_assistant does not execute a termination path now.

What are your thoughts about it? @gagb

thx,i got it,i personally implemented a_check_is_termination_func for GPTAssistant on a fork,would u take this kinda pr or not?the implementation doesn't take original ConversableAgent classmethod though.

yousonnet commented 7 months ago

@yousonnet would you like the Assistant to terminate when it receives a TERMINATE message? I think this capability is not yet supported, the implementation of the gpt_assistant does not execute a termination path now. What are your thoughts about it? @gagb

thx,i got it,i personally implemented a_check_is_termination_func for GPTAssistant on a fork,would u take this kinda pr or not?the implementation doesn't take original ConversableAgent classmethod though.

just found out using parent class's methods works.

1642 1642