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

During Teachability dialogues, the agent does not trigger is_termination_msg. #2680

Closed
kev1nzh37 opened this issue May 14, 2024 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@kev1nzh37
Copy link

Describe the bug

Although the is_termination_msg function is set for the agent in Teachability, it does not actually trigger when called.

def termination_msg(x):
       print(x)
        return (
            isinstance(x, dict)
            and "TERMINATE" == str(x.get("content", ""))[-9:].upper()
        )
teachability = Teachability(
        verbosity=1,
        reset_db=True,
        path_to_db_dir="./tmp/notebook/teachability_db",
        recall_threshold=1.5,
    )
    
user_proxy = autogen.UserProxyAgent(
        name="USER"
        is_termination_msg=termination_msg,
        description="A human admin as well as the boss of the group, who ask questions, give tasks and provide information.",
        human_input_mode="NEVER",
        code_execution_config=False,
    )
    
teachable_agent = AssistantAgent(
            name="Assistant",
            is_termination_msg=termination_msg,
            llm_config={
                "config_list": llm_list,
                "timeout": 60,
                "cache_seed": None,
            },
        )
teachability.add_to_agent(teachable_agent)

user.initiate_chats(
            [
                {
                    "recipient": teachable_agent,
                    "message": MSG,
                    "max_turns": 1,
                },
            ]
        )

Result:


********************************************************************************
Starting a new chat....

********************************************************************************
kevaaa (to Assistant):

call me kev

--------------------------------------------------------------------------------
# call me kev (is_termination_msg)
Seed_Assistant_B (to kevaaa):

Sure, Sager! How can I assist you today?

# Here, is_termination_msg does not trigger and there are no print statements.

Steps to reproduce

No response

Model Used

No response

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

No response

@kev1nzh37 kev1nzh37 added the bug Something isn't working label May 14, 2024
@rickyloynd-microsoft
Copy link
Contributor

What happens if you just comment out the line that calls add_to_agent and run the same test again?

@kev1nzh37
Copy link
Author

What happens if you just comment out the line that calls add_to_agent and run the same test again?如果您只是注释掉调用 add_to_agent 的行并再次运行相同的测试,会发生什么?

Thank you. After testing, it seems that the issue is not with Teachability. When I set max_turns to 2 or 3, I found that only the last response does not call the is_termination_msg function.

If I want the last response of each chat to also call the is_termination_msg function, what should I do?

@rickyloynd-microsoft
Copy link
Contributor

If I want the last response of each chat to also call the is_termination_msg function, what should I do?

I suspect that's not possible because the max_turns condition triggers first. But @ekzhu would know better.

@jtoy
Copy link
Collaborator

jtoy commented May 17, 2024

should both max_turns and is_termination_msg both trigger in this case?

@rickyloynd-microsoft
Copy link
Contributor

To be more exact, either condition (max_turns or is_termination_msg) will cause the termination here, so it's just a question of which condition is checked first in the code.

@ekzhu ekzhu added teach Issues related to teachability and removed teach Issues related to teachability labels May 22, 2024
@ekzhu
Copy link
Collaborator

ekzhu commented May 22, 2024

If I want the last response of each chat to also call the is_termination_msg function, what should I do?

@kev1nzh37 if the chat is terminated, you will get the messages from the ChatResult object returned. You can run your termination check. It's a weird usage, could you elaborate on your scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants