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: Introduce the agent chat history reducer #10190

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

moonbox3
Copy link
Contributor

Motivation and Context

The SK Python framework has been missing the ability to configure a chat history reducer of type ChatHistoryTruncationReducer and ChatHistorySummarizationReducer which have existed in the .Net SK Agent framework for some time.

Description

This PR:

  • Introduces the chat history reducer functionality in Python -- both the ChatHistoryTruncationReducer and ChatHistorySummarizationReducer.
  • Add unit tests for code coverage.
  • Adds a sample Chat Completion History Reducer to show how to configure both reducers and what each parameter does.
  • Updates the Agent SelectionStrategy, KernelFunctionSelectionStrategy and KernelFunctionTermination strategy to use the reducer.
    • Additionally updates the classes above to use a new select_agent abstract method so that one can define an initial agent to run in a particular scenario.
  • Closes Python Agents: ChatHistoryReducer #7969

Contribution Checklist

@moonbox3 moonbox3 self-assigned this Jan 15, 2025
@moonbox3 moonbox3 requested a review from a team as a code owner January 15, 2025 10:40
@markwallace-microsoft markwallace-microsoft added python Pull requests for the Python Semantic Kernel documentation labels Jan 15, 2025
@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
semantic_kernel/agents
   agent.py441077%48–57, 70–71
semantic_kernel/agents/history
   chat_history_reducer_extensions.py30487%27, 74, 83–85
   chat_history_summarization_reducer.py79692%94, 127–130, 136–137, 148
   chat_history_truncation_reducer.py32391%39, 56–59
semantic_kernel/agents/strategies/selection
   kernel_function_selection_strategy.py54198%62
   selection_strategy.py18194%41
   sequential_selection_strategy.py27196%73
semantic_kernel/agents/strategies/termination
   kernel_function_termination_strategy.py44198%54
TOTAL16892180589% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3025 4 💤 0 ❌ 0 🔥 1m 24s ⏱️

@moonbox3 moonbox3 added agents experimental Associated with an experimental feature labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents documentation experimental Associated with an experimental feature python Pull requests for the Python Semantic Kernel
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Python Agents: ChatHistoryReducer
2 participants