Skip to content

Refactor compaction#2242

Open
dgageot wants to merge 4 commits intodocker:mainfrom
dgageot:refactor-compact
Open

Refactor compaction#2242
dgageot wants to merge 4 commits intodocker:mainfrom
dgageot:refactor-compact

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 25, 2026

No description provided.

dgageot added 4 commits March 25, 2026 14:42
Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
Add a retry counter (maxOverflowCompactions=1) to the auto-compaction
path in the runtime loop. When every model call returns a
ContextOverflowError, compaction is now attempted at most once before
the error is surfaced to the user. The counter resets after each
successful model call so future overflows can still trigger compaction.

Add TestCompactionOverflowDoesNotLoop to verify the guard.

Assisted-By: docker-agent
@dgageot dgageot marked this pull request as ready for review March 25, 2026 15:06
@dgageot dgageot requested a review from a team as a code owner March 25, 2026 15:06
// (minus the expected max length of the summary).
contextLimit := max(0, int64(m.Limit.Context)-maxSummaryTokens)
var tokens int64
for i := len(messages) - 1; i >= 0; i-- {
Copy link
Member

Choose a reason for hiding this comment

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

This needs more work, the cutoff could be in the middle of a tool call and we could end up with a session that contains a tool call assistant message without a tool call result.

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