microsoft / microsoft/agent-framework

.NET Compaction - Introduce preconfigured `CompactionStrategy` pattern

Open
#4,603 0 comments 2 reactions 2 assignees View on GitHub

Nobody has claimed this yet.

.NET compaction
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

I expect many developers will ask: How do I configured my `CompactionStrategy`? ...which one do I use? ...what thresholds work best?

We can expose a factory that creates a pre-configured `CompactionStrategy` according to a set of options:

```c#
// Setup a chat client for summarization
IChatClient summarizingChatClient = ...;

// Create a compaction strategy based on a menu selection of characteristics
CompactionStrategy tunedStrategy =
CompactionStrategy.Create(
Approach.Balanced,
Size.Compact,
summarizingChatClient);
```

In this example, "size" could be:
- Compact
- Moderate
- Generous

And "approach" could be:
- Aggressive
- Balanced
- Gentle

Perhaps the "size" parameter is informed by the maximum input tokens allowed by a given model, with a default based on a conservative estimate of the most common usage.

Behind the scenes the combination of these two axes map to a certain `CompactionStrategy` configuration. As we improve our configuration, developers using this pattern will automatically realize those improvements.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.