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

Python: improve agent samples and chat history handling #10301

Merged
merged 22 commits into from
Jan 29, 2025

Conversation

eavanvalkenburg
Copy link
Member

@eavanvalkenburg eavanvalkenburg commented Jan 27, 2025

Motivation and Context

When passing the same object to agent.reduce_history as is present in the history_reducer attribute of the agent that the function doesn't accurately behave. This fixes that.

Also updates the sample to be a bit more concise.

Also fixes the way the single_dispatch is setup in ChatHistory.

Also ensures system/developer messages are not reduced away as that might impact performance.

The reduce_history method was removed from the agent base class, in favor of having the caller manage the change history and reduction as needed. The reduce_history was added to the agent group chat, as the chat history is managed internally as agents are invoked.

Description

Contribution Checklist

@eavanvalkenburg eavanvalkenburg requested a review from a team as a code owner January 27, 2025 13:08
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Jan 27, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 27, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
semantic_kernel/agents
   agent.py57198%82
semantic_kernel/agents/chat_completion
   chat_completion_agent.py102793%82, 85, 94–99, 124, 188
semantic_kernel/agents/group_chat
   agent_chat.py124298%78, 171
   agent_group_chat.py1141289%70, 160, 210, 214–224
semantic_kernel/contents
   chat_history.py174697%103, 108, 263, 272, 283–284
semantic_kernel/contents/history_reducer
   chat_history_reducer.py29969%55–63
   chat_history_reducer_utils.py981288%103–105, 165–166, 181–186, 199, 204–205
   chat_history_summarization_reducer.py71790%96–97, 122–123, 130, 138, 171
   chat_history_truncation_reducer.py30390%50–53, 69
TOTAL17074185789% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3039 4 💤 0 ❌ 0 🔥 1m 30s ⏱️

@moonbox3 moonbox3 enabled auto-merge January 27, 2025 21:38
@eavanvalkenburg eavanvalkenburg changed the title Python: fix passing self.history_reducer to reduce_history in agent Python: improve agent samples and chat history handling Jan 28, 2025
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Jan 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 28, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Jan 29, 2025
Merged via the queue into microsoft:main with commit ec9b980 Jan 29, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants