Skip to content

Add the summary message as a user message#1693

Merged
rumpl merged 1 commit intodocker:mainfrom
rumpl:session-compaction-user-message
Feb 11, 2026
Merged

Add the summary message as a user message#1693
rumpl merged 1 commit intodocker:mainfrom
rumpl:session-compaction-user-message

Conversation

@rumpl
Copy link
Member

@rumpl rumpl commented Feb 11, 2026

This fixes the case where the session was compacted and no user messages were present in the session any more.

There was no real reason why this was a system prompt in the first place...

@rumpl rumpl marked this pull request as ready for review February 11, 2026 10:47
@rumpl rumpl requested a review from a team as a code owner February 11, 2026 10:47
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review Complete - No Issues Found

I've analyzed the change and confirmed this is a correct bug fix.

What This Fixes

After session compaction, when all messages before the summary are removed, there's a scenario where no user messages remain in the active session history. Since the summary was previously a MessageRoleSystem, the message array sent to the LLM API could contain:

  • System messages (instructions)
  • Summary as system message
  • Only assistant/tool messages

This violates LLM API requirements (OpenAI, Claude, etc.) that require at least one user message in the conversation.

The Solution

Changing the summary message role from MessageRoleSystem to MessageRoleUser ensures there's always at least one user message present, preventing API errors that would break the session entirely.

Trade-offs Considered

The summary now counts against the maxItems limit in trimMessages(), but this is acceptable because:

  1. The summary represents previous conversation context and should count as conversation history
  2. The content is clearly prefixed with "Session Summary:" so the LLM understands its nature
  3. Without this fix, the API call would fail completely

Verdict: This change correctly fixes a real bug. Looks good! 🚀

This fixes the case where the session was compacted and no user messages
were present in the session any more.

There was no real reason why this was a system prompt in the first
place...

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
@rumpl rumpl force-pushed the session-compaction-user-message branch from b90a257 to ecc4dfb Compare February 11, 2026 10:54
@rumpl rumpl merged commit 5beaeb5 into docker:main Feb 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants