You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Motivation and Context
Our chat completion agent concept samples need to be cleaned up to
improve readability and maintainability.
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
### Description
Simplify the chat completion agent concept samples so we're not trying
to do too much in each sample. Update some of the APIs using the new
patterns.
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
The following samples demonstrate advanced usage of the `ChatCompletionAgent`.
4
+
5
+
---
6
+
7
+
## Chat History Reduction Strategies
8
+
9
+
When configuring chat history management, there are two important settings to consider:
10
+
11
+
### `reducer_msg_count`
12
+
13
+
-**Purpose:** Defines the target number of messages to retain after applying truncation or summarization.
14
+
-**Controls:** Determines how much recent conversation history is preserved, while older messages are either discarded or summarized.
15
+
-**Recommendations for adjustment:**
16
+
-**Smaller values:** Ideal for memory-constrained environments or scenarios where brief context is sufficient.
17
+
-**Larger values:** Useful when retaining extensive conversational context is critical for accurate responses or complex dialogue.
18
+
19
+
### `reducer_threshold`
20
+
21
+
-**Purpose:** Provides a buffer to prevent premature reduction when the message count slightly exceeds `reducer_msg_count`.
22
+
-**Controls:** Ensures essential message pairs (e.g., a user query and the assistant’s response) aren't unintentionally truncated.
23
+
-**Recommendations for adjustment:**
24
+
-**Smaller values:** Use to enforce stricter message reduction criteria, potentially truncating older message pairs sooner.
25
+
-**Larger values:** Recommended for preserving critical conversation segments, particularly in sensitive interactions involving API function calls or detailed responses.
26
+
27
+
### Interaction Between Parameters
28
+
29
+
The combination of these parameters determines **when** history reduction occurs and **how much** of the conversation is retained.
30
+
31
+
**Example:**
32
+
- If `reducer_msg_count = 10` and `reducer_threshold = 5`, message history won't be truncated until the total message count exceeds 15. This strategy maintains conversational context flexibility while respecting memory limitations.
33
+
34
+
---
35
+
36
+
## Recommendations for Effective Configuration
37
+
38
+
-**Performance-focused environments:**
39
+
- Lower `reducer_msg_count` to conserve memory and accelerate processing.
40
+
41
+
-**Context-sensitive scenarios:**
42
+
- Higher `reducer_msg_count` and `reducer_threshold` help maintain continuity across multiple interactions, crucial for multi-turn conversations or complex workflows.
43
+
44
+
-**Iterative Experimentation:**
45
+
- Start with default values (`reducer_msg_count = 10`, `reducer_threshold = 10`), and adjust according to the specific behavior and response quality required by your application.
0 commit comments