Repository navigation
Fix compaction provider passthrough without a session - #1339
Quim Muntal (qmuntal) merged 1 commit into
Conversation
There was a problem hiding this comment.
🟢 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
API consistency review
Changed Go contractNo exported API changes. Upstream evidence reviewed
AssessmentGo now matches .NET: no session means passthrough, and stateless compaction stays available through
|
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. NormalAgent.Runcalls 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:
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.git diff --checkpassed.