Skip to content

Keep generated compaction summaries out of chat history - #1185

Merged
Quim Muntal (qmuntal) merged 1 commit into
microsoft:mainfrom
gabisonia:fix/compaction-summary-history
Sep 29, 2026
Merged

Quim Muntal (qmuntal) merged 1 commit into
microsoft:mainfrom
gabisonia:fix/compaction-summary-history

Conversation

@gabisonia

Copy link
Copy Markdown
Contributor

Compaction-generated summaries are currently attributed as context-provider messages. The default history store filter treats them as new input, so it saves each summary alongside the original messages it summarizes.

Mark generated summaries as history instead, matching .NET's CompactionProvider. Summaries remain in the model request, while the default history provider excludes them from storage. Provider IDs and message cloning are preserved; custom filters observe the corrected source type.

The public-API regression starts with u1, a1 in history and compacts it before u2. It verifies that the request contains the summary and u2, while stored history after the response is exactly u1, a1, u2, a2. Before the fix, stored history also contains the generated summary. The existing source-attribution assertion and constructor documentation are updated accordingly.

Validation:

  • Regression fails before the fix and passes afterward.
  • go test -race -shuffle=on ./...
  • golangci-lint run --timeout=5m (0 issues)
  • Formatting and git diff --check
  • Equivalent public-API comparison with Microsoft.Agents.AI 1.12.0 matches the corrected history behavior.

Copilot AI balanced review requested due to automatic review settings September 25, 2026 12:37
@github-actions github-actions Bot added area:agent Changes files in the agent area size:medium At most 100 changed lines across at most 5 files labels Sep 25, 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.

Copilot review overview

🟢 Approval recommended

The implementation is focused, preserves cloning and source IDs, and includes targeted regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Updates compaction summary attribution so generated summaries remain in model requests but are excluded from persisted chat history.

Changes:

  • Marks generated summaries as history-provider messages.
  • Adds regression coverage for model-request inclusion and history exclusion.
  • Updates attribution assertions and documentation.
File Description
agent/​compaction/​provider.go Corrects generated-summary source attribution.
agent/​compaction/​compaction_test.go Verifies summary attribution and storage behavior.

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

@github-actions github-actions Bot added kind:code Changes production behavior or code kind:tests Changes tests, fixtures, or test infrastructure labels Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned user-visible behavior

Changed Go contract

agent/compaction/provider.go's contextProvider.markGeneratedMessages (invoked from the exported Invoking method of the provider returned by compaction.NewContextProvider) now stamps newly generated summary messages with agent.SourceTypeHistoryProvider instead of agent.SourceTypeContextProvider. This is user-visible: agent.NewHistoryProvider's default StoreInputRequestMessageFilter (notSourceTypes(SourceTypeHistoryProvider)) now correctly excludes generated summaries from being persisted to chat history, whereas previously they were stamped as context-provider-sourced and therefore stored as new messages on every turn.

Upstream evidence reviewed

Implementation Source Contract checked
.NET dotnet/src/Microsoft.Agents.AI/Compaction/CompactionProvider.cs#L187-L201 Generated compaction messages not already attributed as AgentRequestMessageSourceType.ChatHistory and not present in the incoming message list are re-stamped as ChatHistory (not as context-provider-sourced), preventing re-storage of summaries in chat history at the end of a run.

Assessment

The Go change makes contextProvider.markGeneratedMessages stamp generated summaries as SourceTypeHistoryProvider (Go's equivalent of ChatHistory), exactly mirroring the .NET CompactionProvider.InvokingCoreAsync logic that re-attributes newly generated compaction messages as AgentRequestMessageSourceType.ChatHistory rather than provider-sourced. Both implementations skip messages already marked as history and skip messages that are content-equal to the turn's input messages, only stamping genuinely new (summary) content. The new regression test (TestNewProvider_DoesNotStoreGeneratedSummaryInHistory) confirms stored history excludes the summary while the model request still includes it, matching upstream's stated intent ("we don't want to add them to chat history at the end of the run"). No exported Go symbols were added, removed, or renamed; this is a behavior-only bug fix restoring parity with .NET.

Warning

Firewall blocked 4 domains

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

  • github.com
  • proxy.golang.org
  • storage.googleapis.com
  • sum.golang.org

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

network:
  allowed:
    - defaults
    - "github.com"
    - "proxy.golang.org"
    - "storage.googleapis.com"
    - "sum.golang.org"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent · copilot · auto · 52.9 AIC · ⌖ 7.58 AIC · ⊞ 13.9K · ◷

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Sep 25, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Sep 29, 2026
Merged via the queue into microsoft:main with commit b442a82 Sep 29, 2026
28 checks passed
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 kind:code Changes production behavior or code kind:tests Changes tests, fixtures, or test infrastructure parity-approved Go API consistency review found no parity issues size:medium At most 100 changed lines across at most 5 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants