Skip to content

fix(cli): chunk oversized compactions#10263

Merged
catrielmuller merged 4 commits into
mainfrom
axiomatic-gouda
May 14, 2026
Merged

fix(cli): chunk oversized compactions#10263
catrielmuller merged 4 commits into
mainfrom
axiomatic-gouda

Conversation

@catrielmuller

@catrielmuller catrielmuller commented May 14, 2026

Copy link
Copy Markdown
Contributor

Context

Fix CLI compaction overflow loops when long conversations or replayed turns still exceed the model context after the normal summary pass.

Implementation

  • Add Kilo-specific chunked compaction that splits oversized histories, summarizes chunks with a smaller output budget, then synthesizes a final summary.
  • Fall back to chunked compaction when the first compaction overflows, and compact oversized replay requests before auto-continuing.
  • Cap LLM maxOutputTokens based on estimated input and tool schema tokens so small-context models keep room for prompts.

Screenshots

2026-05-14_11-09-17.mp4

How to Test

  • From packages/opencode/, run bun test ./test/kilocode/session-compaction-chunks.test.ts.
  • Exercise a long CLI session that triggers compaction; oversized histories should compact through chunk summaries instead of ending in a context overflow loop.

Comment thread packages/opencode/src/kilocode/session/compaction-chunks.ts Outdated
Comment thread packages/opencode/src/kilocode/session/compaction-chunks.ts Outdated
Comment thread packages/opencode/src/kilocode/session/compaction-chunks.ts Outdated
Comment thread packages/opencode/src/kilocode/session/llm.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Previously Flagged — All Resolved

File Issue Status
packages/opencode/src/kilocode/session/compaction-chunks.ts WARNING: Concurrent mutation of input.agent.options — race condition ✅ Fixed: new agent const created, input.agent no longer mutated
packages/opencode/src/kilocode/session/compaction-chunks.ts WARNING: removeMessage not in Effect.ensuring — orphaned messages possible ✅ Fixed: removeMessage now wrapped in Effect.ensuring, runs on both success and fiber interruption
packages/opencode/src/kilocode/session/compaction-chunks.ts SUGGESTION: Depth counter increments twice on recovery path ✅ Addressed: synthesis call now uses depth + 2
packages/opencode/src/kilocode/session/llm.ts SUGGESTION: !input.configured short-circuits on configured = 0 ✅ Fixed: split into == null check and <= 0 check
Files Reviewed (2 files)
  • packages/opencode/src/kilocode/session/compaction-chunks.ts — 0 issues
  • packages/opencode/src/kilocode/session/llm.ts — 0 issues

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-4.6 · 217,950 tokens

Comment thread packages/opencode/src/kilocode/session/compaction-chunks.ts Outdated
@catrielmuller catrielmuller merged commit 7bc46c5 into main May 14, 2026
12 checks passed
@catrielmuller catrielmuller deleted the axiomatic-gouda branch May 14, 2026 18:16
jliounis pushed a commit to jliounis/kilocode that referenced this pull request May 19, 2026
fix(cli): chunk oversized compactions
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