microsoft / microsoft/agent-framework-go
[dotnet-port-api] Add compaction-backed history provider
- Dominant language
- Go
- Stars
- 618
- Forks
- 56
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 122
Description
> [!TIP]
> **Your pull request is ready to create! 🎉 ✅**
>
> Everything is OK—the changes have been pushed to branch `copilot/dotnet-port-api-compaction-history-provider-fdbbd9f2ce32e8b7`. Please review the changes, including any protected files, before creating the pull request.
>
> **[Create the pull request](https://github.com/microsoft/agent-framework-go/compare/main...copilot/dotnet-port-api-compaction-history-provider-fdbbd9f2ce32e8b7?expand=1&title=%5Bdotnet-port-api%5D%20Add%20compaction-backed%20history%20provider)**
>
> The original pull request description is below.
---
## Summary
Add a compaction-backed history provider in `agent/compaction` so Go agents can apply reducer-triggered history compaction directly on the history-provider surface instead of only through a separate context provider. The change adds the new provider, covers compacted persistence and summary replay in tests, updates the additional-context sample to use the new API, and refreshes the parity doc to reflect the reduced .NET chat-history gap.
## Ported .NET PRs
- None — this is a Go misalignment realignment for the documented .NET chat-history reducer-trigger capability. The local parity baseline tracks .NET commit [`5996105a1bf2726918101adc6e9c9857b7f68b98`](https://github.com/microsoft/agent-framework/commit/5996105a1bf2726918101adc6e9c9857b7f68b98), with workflow/test delta previously checked through [`6a0773ba2180e8036d138dbb9794ae64ec2d978b`](https://github.com/microsoft/agent-framework/commit/6a0773ba2180e8036d138dbb9794ae64ec2d978b).
## Breaking Changes
No.
## Tests and Examples
- `go test ./agent ./agent/compaction ./examples/02-agents/agents/step17_additional_ai_context`
- Added `agent/compaction/historyprovider_test.go`
- Updated `examples/02-agents/agents/step17_additional_ai_context/main.go`
## Notes
- The live `upstream-agent-framework/main` fetch was blocked in this environment, so this PR ports the documented chat-history parity gap as a narrow Go realignment instead of tying the change to a freshly inspected upstream PR.
- Other broader chat-history/storage parity gaps remain out of scope for this PR.
---
> [!NOTE]
> GitHub Actions is not permitted to create or approve pull requests in this repository.
> The changes have been pushed to branch `copilot/dotnet-port-api-compaction-history-provider-fdbbd9f2ce32e8b7` and are ready to review.
To fix the permissions issue, go to **Settings** → **Actions** → **General** and enable **Allow GitHub Actions to create and approve pull requests**. See also: [gh-aw FAQ](https://github.github.com/gh-aw/reference/faq/#why-is-my-create-pull-request-workflow-failing-with-github-actions-is-not-permitted-to-create-or-approve-pull-requests)
Show patch preview (49 of 382 lines)
```diff
From 1681aba4204460f1c46f2bd66efdd44915c5e54b Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: de821aaf3899669a99a730f66f25ebad31cba62c
From: "github-actions[bot]"
Date: Fri, 11 Sep 2026 05:37:42 +0000
Subject: [PATCH] [dotnet-port-api] Add compaction-backed history provider
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
agent/compaction/doc.go | 6 +-
agent/compaction/historyprovider.go | 188 ++++++++++++++++++
agent/compaction/historyprovider_test.go | 103 ++++++++++
docs/dotnet-go-sdk-feature-comparison.md | 2 +-
.../step17_additional_ai_context/main.go | 11 +-
5 files changed, 305 insertions(+), 5 deletions(-)
create mode 100644 agent/compaction/historyprovider.go
create mode 100644 agent/compaction/historyprovider_test.go
diff --git a/agent/compaction/doc.go b/agent/compaction/doc.go
index d4280fe..6b4abab 100644
--- a/agent/compaction/doc.go
+++ b/agent/compaction/doc.go
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Package compaction reduces conversation history to fit a model's context
-// window. It provides a context provider and composable strategies — sliding
-// window, truncation, summarization, tool-result eviction, and context-window
-// sizing — selected by triggers evaluated over a message index.
+// window. It provides history and context providers plus composable strategies
+// — sliding window, truncation, summarization, tool-result eviction, and
+// context-window sizing — selected by triggers evaluated over a message index.
package compaction
diff --git a/agent/compaction/historyprovider.go b/agent/compaction/historyprovider.go
new file mode 100644
index 0000000..7fcc9db
--- /dev/null
+++ b/agent/compaction/historyprovider.go
@@ -0,0 +1,188 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+package compaction
+
+import (
+ "cmp"
+ "context"
+ "log/slog"
+ "runtime"
+ "slices"
+ "sync
... (truncated)
```
> [!WARNING]
>
> Firewall blocked 1 domain
>
> The following domain was blocked by the firewall during workflow execution:
>
> - `github.com`
>
> To allow these domains, add them to the `network.allowed` list in your workflow frontmatter:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "github.com"
> ```
>
> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.
>
>
> Generated by [.NET to Go API Porting Agent](https://github.com/microsoft/agent-framework-go/actions/runs/34566058339) · copilot · gpt54 · 187.4 AIC · ⌖ 10.6 AIC · ⊞ 19K · [◷](https://github.com/search?q=repo%3Amicrosoft%2Fagent-framework-go+%22gh-aw-workflow-id%3A+dotnet-port-api-nightly%22&type=pullrequests)
Contributor guide
Research direction
Start with agent/compaction/historyprovider.go and the existing compaction provider APIs, then run the listed Go tests, including agent/compaction/historyprovider_test.go. Review the additional-context sample and docs/dotnet-go-sdk-feature-comparison.md for the expected integration surface. Done means the provider behavior, persistence and summary replay tests, sample, and parity documentation are all updated and the listed tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100