Closed
Conversation
There was a problem hiding this comment.
Code Review Summary
✅ No issues found
I've completed a thorough review of the compaction improvements. The implementation looks solid:
What was reviewed:
- Session compaction logic - Correctly checks if compaction succeeded by comparing message counts before/after
- Continuation message handling - Only adds the implicit user message when compaction actually produces a summary
- Token counter reset - Properly resets counters to 0 after successful compaction to prevent immediate re-triggering
- Error handling - Gracefully handles failed compaction by not adding stray messages
Test coverage:
The PR includes comprehensive tests covering:
- ✅ Continuation message is sent after successful compaction
- ✅ Token counters are reset and don't cause compaction loops
- ✅ Failed compaction doesn't add stray messages
The logic is sound and well-tested. Great work on improving the compaction feature!
rumpl
reviewed
Feb 10, 2026
Signed-off-by: David Gageot <david.gageot@docker.com>
e14b383 to
7f7b53e
Compare
trungutt
approved these changes
Feb 11, 2026
rumpl
reviewed
Feb 11, 2026
| // would be zero conversation messages. Providers (e.g. Anthropic) | ||
| // reject requests with no non-system messages, so we add a | ||
| // continuation message to bridge the gap. | ||
| sess.AddMessage(session.ImplicitUserMessage("The conversation was automatically compacted. Please continue where you left off.")) |
Member
There was a problem hiding this comment.
I think this is actually the issue, we are putting the session summary as a system prompt, but it should be a user message https://github.com/docker/cagent/blob/main/pkg/session/session.go#L602
Member
Author
|
@rumpl please take a look at fixing this right. I'm closing the PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I had cagent review the compaction code. Here's what it says:
Compact(). Tokens reset inruntime.go. Model gets a valid user message.Compact()returns early — no summary, no continuation, no token reset.Compact()returns early atif summary == "". Same as above./compactCompact(), then user sends a real message — both appear after the summary, model sees both. Harmless.