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

[Bug]: chat_messages + agent.run() issues #1006

Closed
alecsolder opened this issue Feb 18, 2025 · 1 comment · Fixed by #1087
Closed

[Bug]: chat_messages + agent.run() issues #1006

alecsolder opened this issue Feb 18, 2025 · 1 comment · Fixed by #1087
Assignees
Labels
bug Something isn't working

Comments

@alecsolder
Copy link
Collaborator

Describe the bug

When creating an agent and specifying chat_messages, those messages are only sent to the LLM if the sender matches:

reply = self.generate_reply(messages=self.chat_messages[sender], sender=sender)

This is hard when using .run() because it creates the other agent with

with self._create_executor(
which would make it impossible to get those messages included.

Not sure exactly how to solve this, but the end state is that there should just be a way to add in messages to the history that will be sent to the LLM.

Steps to reproduce

No response

Model Used

No response

Expected Behavior

No response

Screenshots and logs

No response

Additional Information

No response

@alecsolder alecsolder added the bug Something isn't working label Feb 18, 2025
@davorrunje davorrunje added this to ag2 Feb 19, 2025
@rjambrecic rjambrecic moved this to Todo in ag2 Feb 21, 2025
@rjambrecic rjambrecic moved this from Todo to In Progress in ag2 Feb 21, 2025
@rjambrecic
Copy link
Collaborator

Hi @alecsolder ,

if I understood correctly you want to be able to do:

assistant = AssistantAgent(
    name="Assistant",
    llm_config=llm_config,
)

chat_result = assistant.run(
    message="what is two plus two?",
    max_turns=1,
    user_input=False,
)
user (to Assistant):

what is two plus two?

--------------------------------------------------------------------------------
Assistant (to user):

Two plus two equals four.

--------------------------------------------------------------------------------

And then send another message but with preserved chat history:

chat_result = assistant.run(
    message="What was my last question?",
    max_turns=1,
    user_input=False,
)
user (to Assistant):

What was my last question?

--------------------------------------------------------------------------------
Assistant (to user):

Your last question was, "what is two plus two?"
--------------------------------------------------------------------------------

Is that correct?

@rjambrecic rjambrecic moved this from In Progress to Waiting for merge in ag2 Feb 21, 2025
@github-project-automation github-project-automation bot moved this from Waiting for merge to Done in ag2 Feb 21, 2025
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
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants