Repository navigation
Isolate default compaction state by strategy type - #1340
Quim Muntal (qmuntal) merged 1 commit into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change to isolate default compaction state by strategy type.
No open issues 🎉
What changed in this PR
This PR isolates compaction providers’ default session state by strategy type, preventing different strategies from inheriting each other’s saved exclusions.
Changes:
- Derives default state keys from concrete strategy type names while preserving explicit
StateKey, customSourceID, and message attribution behavior. - Documents key collisions and how to retain legacy state using
StateKey: "CompactionProvider". - Adds regression coverage for strategy isolation, provider recreation, session serialization, custom strategies, and legacy-state restoration.
| File | Description |
|---|---|
agent/compaction/provider.go |
Implements strategy-based default state keys and documents compatibility rules. |
agent/compaction/equality_test.go |
Verifies built-in strategy keys, override precedence, and unchanged source IDs. |
agent/compaction/compaction_test.go |
Tests state isolation, recreation, serialization, custom strategies, and legacy restoration. |
Review effort: Balanced
API consistency review
Changed Go contractNo exported identifiers changed. Upstream evidence reviewed
AssessmentGo now matches the .NET default: the state key is derived from the strategy type name, and an explicit key overrides it. The
|
Compaction context providers currently share the default session key
CompactionProvider, so different strategies can reuse each other's saved exclusions. For example, after truncation reduces six messages to two, a sliding-window provider with its trigger disabled also returns only two messages.Derive the default state key from the concrete strategy's type name, matching the .NET 1.22.0 default. Different built-in strategy types now retain separate state; recreating the same strategy type recovers its existing state, including after session serialization. Explicit
StateKeyand customSourceIDkeys retain their precedence and behavior. Message source attribution is unchanged.Compatibility: the default persisted key changes. To retain state saved under the old default, set
StateKey: "CompactionProvider"explicitly. Providers whose default keys match, including multiple instances of the same strategy type or types with the same unqualified name, still need distinct explicit keys for isolation. The API documentation describes these rules.Validation:
0c9944cc9f577d51277ac7c55dbc388b60a577af: the second strategy preserves all six messages, while the recreated original strategy retains its two-message view, both before and after session restoration.mainbase:go test ./...,go test -race -shuffle=on ./agent/compaction, and repository-widegolangci-lint runpass on macOS arm64 with Go 1.26.1.git diff --checkpass. Linux/Windows compaction test cross-compilation also passed during review; runtime coverage remains with CI.This PR is independent of #1339.