Skip to content

Fix compaction provider passthrough without a session - #1339

Merged
Quim Muntal (qmuntal) merged 1 commit into
microsoft:mainfrom
gabisonia:fix/compaction-no-session-passthrough
Oct 30, 2026
Merged

Quim Muntal (qmuntal) merged 1 commit into
microsoft:mainfrom
gabisonia:fix/compaction-no-session-passthrough

Conversation

@gabisonia

Copy link
Copy Markdown
Contributor

When a compaction context provider receives no session, it currently applies its strategy and can remove input messages. Return the original messages and options without invoking the strategy, matching the .NET 1.22.0 provider.

This changes the previously documented behavior for direct provider calls and middleware calls with no session. Callers that need stateless compaction should use compaction.Compact. Normal Agent.Run calls continue to compact because the agent creates an implicit session.

Update the API documentation and add regression coverage for omitted/nil sessions, preservation of input messages and options, middleware passthrough, and normal agent execution with an implicit session. Existing source-attribution tests now provide a local session.

Validation on macOS arm64 with Go 1.26.1:

  • Regression tests fail against the original provider and pass with this change.
  • Executed equivalent cases against the published .NET 1.22.0 assembly, verifying source revision 0c9944cc9f577d51277ac7c55dbc388b60a577af. For six input messages, both implementations preserve all six without a session and retain two with an explicit session, an implicit agent session, or the standalone compaction API.
  • go test ./...: 54 packages passed.
  • go test -race -shuffle=on ./...: 54 packages passed, no races.
  • golangci-lint run (2.15.0): zero issues.
  • Formatting and git diff --check passed.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:20
@gabisonia
Irakli Gabisonia (gabisonia) requested a review from a team as a code owner October 29, 2026 20:20
@github-actions github-actions Bot added the area:agent Changes files in the agent area label Oct 29, 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.

🟢 Approval recommended

No active review issues are reported for the sessionless compaction passthrough change.

No open issues 🎉

What changed in this PR

This PR makes the compaction context provider pass through messages and options unchanged when no session is available. Stateless callers are directed to compaction.Compact, while normal agent runs retain compaction through implicit sessions.

Changes:

  • Skip strategy execution when the session is omitted or nil.
  • Document the session requirement and standalone compaction alternative.
  • Add regression coverage for passthrough and implicit-session behavior, and update source-attribution tests to use local sessions.
File Description
agent/​compaction/​provider.go Return inputs unchanged without a session; update documentation and debug logging.
agent/​compaction/​compaction_test.go Cover direct and middleware passthrough, implicit-session compaction, and session-backed source attribution.

Review effort: Balanced

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned user-visible behavior

Changed Go contract

No exported API changes. compaction.NewContextProvider now returns messages and options unchanged (without invoking the strategy) when there is no session. Previously it compacted statelessly.

Upstream evidence reviewed

Implementation Source Contract checked
.NET CompactionProvider.InvokingCoreAsync session is null returns context.AIContext unchanged. Ad-hoc compaction is via the static CompactAsync. Services-managed sessions are skipped.

Assessment

Go now matches .NET: no session means passthrough, and stateless compaction stays available through compaction.Compact, the counterpart of CompactAsync. Service-managed session skipping is unchanged. I did not review a Python equivalent. The .NET source is the parity reference cited by the PR and is sufficient for this change. No public-api-change label is needed.

Generated by Go API Consistency Review Agent · copilot · auto · 24.4 AIC · ⌖ 0.611 AIC · ⊞ 4.9K · ◷

@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Oct 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 29, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Oct 30, 2026
Merged via the queue into microsoft:main with commit a4ce32d Oct 30, 2026
23 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 parity-approved Go API consistency review found no parity issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants