Skip to content

[dotnet-port-api] Add compaction-backed history provider - #1092

Merged
Quim Muntal (qmuntal) merged 4 commits into
mainfrom
copilot/dotnet-port-api-compaction-history-provider-fdbbd9f2ce32e8b7
Sep 29, 2026
Merged

Quim Muntal (qmuntal) merged 4 commits into
mainfrom
copilot/dotnet-port-api-compaction-history-provider-fdbbd9f2ce32e8b7

Conversation

@michelle-clayton-work

Copy link
Copy Markdown
Contributor

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

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

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.

Closes #1053

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 16, 2026 18:45
@github-actions github-actions Bot added area:agent Changes files in the agent area area:examples Changes files in the examples area size:xlarge More than 300 changed lines or 10 files labels Sep 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Two critical correctness issues remain in the history provider.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a compaction-backed history provider with persistence, tests, an updated example, and refreshed .NET parity documentation.

Changes:

  • Adds compaction.NewHistoryProvider.
  • Adds compaction persistence and summary replay tests.
  • Updates the additional-context example.
  • Refreshes the .NET/Go feature comparison.
File summaries
File Summary
examples/02-agents/agents/step17_additional_ai_context/main.go Uses the new bounded history provider.
docs/dotnet-go-sdk-feature-comparison.md Updates chat-history parity status.
agent/compaction/historyprovider.go Implements persisted compaction. Critical issues remain around including current input before compaction and applying filters before generated summaries; a concurrency test is also needed.
agent/compaction/historyprovider_test.go Tests compacted persistence and summary replay.
agent/compaction/doc.go Documents history-provider support.
Review details

Suppressed comments (1)

agent/compaction/historyprovider.go:146

  • This provider rewrites shared session state after appending and compacting each turn, but the new tests only exercise sequential Invoked calls. The existing in-memory provider has a same-session concurrent store/race test (agent/history_test.go:80-118); add the analogous test here with a real truncation strategy to verify that concurrent turns are not lost while compaction runs.
			compacted, err := compactHistory(ctx, cfg.Strategy, messages, cfg.TokenCounter, cfg.Logger)
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread agent/compaction/historyprovider.go Outdated
Comment thread agent/compaction/historyprovider.go Outdated
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:examples Changes examples or example-support metadata kind:tests Changes tests, fixtures, or test infrastructure labels Sep 16, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the public-api-change Pull Request changes public APIs label Sep 16, 2026
@michelle-clayton-work

Copy link
Copy Markdown
Contributor Author

Copilot address PR feedback

Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Copilot address PR feedback

Addressed the review feedback in 941efbc: pre-call compaction now includes filtered persisted history plus the current request exactly once, and filtering occurs before summarization. Added regression coverage for both cases.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated by Go API Consistency Review Agent for #1092 · copilot · auto · 117 AIC · ⌖ 6.8 AIC · ⊞ 9.6K

Comment thread agent/compaction/historyprovider.go
@michelle-clayton-work

Copy link
Copy Markdown
Contributor Author

Copilot address PR feedback

Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>

Copilot AI commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Copilot address PR feedback

Addressed the remaining review feedback in b591a02: history compaction now runs at one configurable lifecycle point, defaulting to before retrieval, with an after-message-added option. Added coverage for both modes and updated the bounded-storage sample.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Sep 21, 2026
@michelle-clayton-work

Copy link
Copy Markdown
Contributor Author

Copilot fix merge conflicts

…pi-compaction-history-provider-fdbbd9f2ce32e8b7

# Conflicts:
#	docs/dotnet-go-sdk-feature-comparison.md

Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>

Copilot AI commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Copilot fix merge conflicts

Resolved the merge conflict with current main in merge commit 9ae6e8e. The obsolete feature-matrix edit was dropped in favor of main’s new symbol-mapping guide, while the provider implementation, tests, and sample remain intact. Targeted race tests and CodeQL pass.

@github-actions github-actions Bot removed the kind:docs Changes documentation or comments label Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned public API, user-visible behavior, examples

Changed Go contract

New exported compaction.NewHistoryProvider, HistoryProviderConfig, and HistoryProviderTriggerEvent (BeforeMessagesRetrieval by default, or AfterMessageAdded). The step17_additional_ai_context example now uses this provider.

Upstream evidence reviewed

Implementation Source Contract checked
.NET InMemoryChatHistoryProviderOptions.cs (ReducerTriggerEvent, ChatReducerTriggerEvent) The default trigger is BeforeMessagesRetrieval. AfterMessageAdded is the other option.
.NET InMemoryChatHistoryProvider.cs (ProvideChatHistoryAsync, StoreChatHistoryAsync) The reducer runs on retrieval or after messages are stored, according to the trigger.
.NET Compaction/CompactionProvider.cs Upstream compaction strategies are exposed as an AI context provider.

I did not review the Python sources. I searched only .NET, and only main.

Assessment

The trigger names, the default (BeforeMessagesRetrieval), and the trigger semantics match the upstream in-memory history provider's reducer trigger. The strategy machinery is the existing compaction pipeline. The Go provider is opt-in, so no defaults change for existing users.

One difference is worth a maintainer's look, but I don't treat it as a finding. In BeforeMessagesRetrieval mode, .NET writes the reduced messages back to session state. Go compacts a copy for retrieval only, and Invoked then appends to the uncompacted stored history. Observable prompts should match, but stored session state grows until an AfterMessageAdded trigger is used. Strategies like summarization may also re-run on each retrieval.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • github.com
  • raw.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"
    - "raw.githubusercontent.com"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent for #1092 · copilot · auto · 28.7 AIC · ⌖ 9.73 AIC · ⊞ 13.8K · ◷

@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Sep 29, 2026
Merged via the queue into main with commit 7573f9a Sep 29, 2026
28 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the copilot/dotnet-port-api-compaction-history-provider-fdbbd9f2ce32e8b7 branch September 29, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Changes files in the agent area area:examples Changes files in the examples area kind:code Changes production behavior or code kind:examples Changes examples or example-support metadata kind:tests Changes tests, fixtures, or test infrastructure parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs size:xlarge More than 300 changed lines or 10 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-port-api] Add compaction-backed history provider

4 participants