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

Preserve chat history when using 'agent.run' #1087

Merged

Conversation

rjambrecic
Copy link
Collaborator

@rjambrecic rjambrecic commented Feb 21, 2025

Why are these changes needed?

We should be able to use agent.run(... multiple times without losing chat history
e.g.

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 (without losing 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?"
--------------------------------------------------------------------------------

Related issue number

Closes #1006

Checks

@davorrunje davorrunje enabled auto-merge February 21, 2025 15:17
@davorrunje davorrunje added this pull request to the merge queue Feb 21, 2025
Merged via the queue into main with commit 0deb7f1 Feb 21, 2025
19 of 503 checks passed
@davorrunje davorrunje deleted the preserve-chat-history-for-multiple-run-function-executions branch February 21, 2025 15:50
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
autogen/agentchat/conversable_agent.py 75.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (8541b30) and HEAD (5d23a4a). Click for more details.

HEAD has 1169 uploads less than BASE
Flag BASE (8541b30) HEAD (5d23a4a)
3.13 84 0
ubuntu-latest 120 1
commsagent-discord 9 0
optional-deps 132 0
3.10 94 0
3.9 73 0
browser-use 3 0
core-without-llm 14 1
macos-latest 105 0
windows-latest 116 0
3.11 51 1
commsagent-slack 9 0
3.12 39 0
commsagent-telegram 9 0
crawl4ai 9 0
docs 6 0
graph-rag-falkor-db 6 0
interop 9 0
interop-crewai 9 0
interop-langchain 9 0
interop-pydantic-ai 9 0
jupyter-executor 9 0
twilio 9 0
retrievechat-pgvector 10 0
retrievechat 15 0
retrievechat-mongodb 10 0
retrievechat-qdrant 14 0
agent-eval 1 0
gpt-assistant-agent 3 0
anthropic 15 0
lmm 3 0
teachable 3 0
gemini 14 0
cerebras 14 0
retrievechat-couchbase 3 0
groq 14 0
llama-index-agent 3 0
websurfer 15 0
mistral 14 0
bedrock 14 0
long-context 3 0
ollama 14 0
cohere 15 0
swarm 14 0
reasoning 14 0
together 14 0
Files with missing lines Coverage Δ
autogen/agentchat/conversable_agent.py 66.69% <75.00%> (-2.60%) ⬇️

... and 43 files with indirect coverage changes

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

Successfully merging this pull request may close these issues.

[Bug]: chat_messages + agent.run() issues
2 participants