Repository navigation
feat(session): pluggable compaction methods - #11377
jingchaodev wants to merge 1 commit into
Conversation
|
Intent: Let an operator choose a compaction at the auto-compact threshold that spends no model call: rotate the session and re-seed the successor from the transcript tail, optionally behind an elided digest of the dropped history. The default order stays |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS
Watch
[DESIGN-REVIEWED] 01093be Description read[DESCRIPTION-READ] cb82f954d45269df79da379c0a3236b47b05c2dff980681b4073acaa44f284ec That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — 🔴 changes requested (blocking)Reviewed 1 of 1 blocking finding(s) are security-class and were withheld from adjudication, so the blocking verdict stands. BLOCKING -- src/kiro_crew/dashboard/compaction_seed.py:108 -- Cron-linked tabs admit rotations that scheduled turns cannot replay Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 (fenced): I'm upholding it. Harm: the model loses saved context without anyone being told. The transcript stays on disk, so this is lost context for the model, not deleted user data. All three conditions are plausible in normal use, so a FLAG isn't justified:
Nothing here requires contradictory timing or input the system can't produce. The fix the finding proposes, refusing |
First Principles Review (Opus 5.5, fork) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK The new Not justified as shipped
What this change shipsInventory (10 items) — 7 justifiedIntent: let an operator replace the slow model-call
Blockers
[FIRST-PRINCIPLES-REVIEWED] 01093be Description read[DESCRIPTION-READ] f2113a74f4be3aedb9bbc5ad0a235cf4ba79064877dedcdd8480a923469b374e That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings that block the merge; one advisory. FINDING — src/kiro_crew/session_compaction.py:1132 — with [OPUS-REVIEWED] 01093be |
dfa03cd to
c5b7fa9
Compare
|
|
|
|
|
|
Round 1 at |
c5b7fa9 to
bb82582
Compare
|
|
|
|
|
|
|
Round 2 at Bundle Size Gate on the previous head: the |
bb82582 to
2f7e3d2
Compare
|
GPT, round 19 (judged head
|
|
Opus, round 19 (judged head
|
|
Design, round 19 (judged head
|
|
First Principles, round 19 (judged head
|
|
First Principles, round 19 (judged head
|
|
First Principles, round 19 (judged head
|
|
UX, round 19 (judged head
|
|
UX, round 19 (judged head
|
|
UX, round 19 (judged head
|
|
UX, round 19 (judged head
|
|
Round 19: This answers the 2026-09-30 triage (issuecomment-5909842366) and the 2026-10-05 rebase request (issuecomment-5998839384). The four decisions are made, so
|
|
Thanks for this PR. It now conflicts with main. Could you rebase onto the latest main and resolve the conflicts? We will review it again once it is rebased and CI is green. |
|
resolution: removed -- context_budget.py and its parity test are deleted, so the owners in context_assembly hold the only copies
|
|
resolution: narrowed -- only a dashboard tab's own session key may rotate, and shake with its digest rows is removed
|
|
Round 20: @bolichen97 thanks, it is rebased and the conflicts are resolved. The fork CI runs need a maintainer to approve them. This round narrows the PR:
A local review of the new head found five more defects, all fixed with tests:
The question left for a maintainer is the one from rounds 17 to 19: no first-time reader has seen "Soft" or "Session rotated (soft)", and a fork contributor cannot push the branch for that blind read. Please either push it for the read or accept the labels. With that, the author decisions are made, so |
|
Rebased onto How each conflict was resolved:
One more fix from main's new style tests: the French Heads-up: The fork CI runs for this head need a maintainer's approval again. |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own. Adds the opt-in setting An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How each conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
|
Rebased onto How the conflict was resolved:
|
At the auto-compact threshold the coordinator has one move: kiro-cli's /compact, a single model call over the whole window that took 2m12s at 99% of a 1M-token window. session.compaction_method chooses what runs there: native (the default, that same /compact, so nothing changes for a config that never sets it) or soft. Settings > Chat > Advanced carries a Compaction Method select beside the Auto-Compact Threshold, and the config PATCH allowlist accepts the key as an enum. An unknown stored name loads as native. soft is a rotation and makes no model call. The coordinator restarts the session the way every compaction restart does: it holds the turn permit, waits for sub-agents that share the process, then _restart_held starts the successor, hands it the turns queued behind the hold and recycles the old session. The successor's first turn replays the transcript tail through build_session_replay, under the replay_budget_chars figure that context_assembly.replay owns. A rotation runs only when the dashboard seed writer supports the key and its projection clears the threshold by the margin /compact must reach. Otherwise native runs. An ineffective rotation holds the key on native until the method, window or threshold its projection read changes. The rotation notices say the transcript on screen is intact and the agent's memory of earlier turns is gone. The replay leaves those notices out, so they spend none of the tail. With soft configured, the mid-turn notice says the chat "will be compacted" instead of "summarized", and the replay clips an oversized newest row.
|
Rebased onto How the conflict was resolved:
Two rules that reached
|
Problem / Motivation
Goal: let an operator pick a compaction that spends no model call, changing nothing for a config that never sets it:
session.compaction_methoddefaults tonative, today's/compact, and is set in Settings > Chat > Advanced.At the auto-compact threshold the coordinator has one move: kiro-cli's
/compact, a single model call over the whole window. At 99% of a 1M-token window that call took 2m12s, and every turn before it re-sent the whole window. A session that is mostly old tool output pays the same two minutes as one that is all decisions.Why it matters
The wait lands on the busiest sessions. A long babysit or goal loop crosses the threshold several times a day, and the dashboard shows nothing while the call runs. Kiro Crew already owns a model-free way back to headroom, a session restart plus
build_session_replay, but today it is reached only when/compactfails.Not a goal
native, today's/compact.nativeruns (Surface auto-compaction status in the UI — the dashboard looks frozen while it runs #8865 stays open).native.What changed (motivation → approach → change)
Motivation: at the threshold the only move is
/compact, one model call over the whole window, and the chat shows nothing while it runs.Approach: a second method,
soft, frees the window without a model call. It restarts the session on purpose with the restart every compaction fallback already uses: hold the turn permit, wait for sub-agents that share the process, then_restart_heldstarts the new session and hands it the queued turns. The new session's first turn replays the transcript tail throughbuild_session_replay, sized byreplay_budget_chars(80K chars at a 1M window, 16K at 200K).Change: one setting picks the method, and each case below either rotates or runs
native.native, the default/compact, as onmainsofton a dashboard tab's own sessionsofton a channel, cron, hook, sub-agent or workflow sessionnativesoftwhose estimate would not clear the thresholdnativesession.idle_compaction)native: the idle arm never restarts a sessionA rotation runs only when its estimate lands below the threshold by the margin
/compactmust reach. The new session's first context reading checks that estimate, and a rotation that freed too little arms the same failure cooldown asnative. A forced Stop during the sub-agent wait ends the rotation ascancelled, and its notice names the rotation. A raise after the new session started reportsfailed;nativenever runs on the replaced session. A stored method name the loader does not know, for example a retiredshake, loads asnative.The chat says what happened. A rotation posts "Session rotated (soft). The conversation above is still here; the agent remembers only the recent turns, earlier ones are gone from its memory." While it waits for sub-agents, it posts "The session is waiting for its sub-agents to finish before it rotates (soft). Your messages are kept." On a session that can rotate, the mid-turn notice says the chat "will be compacted" instead of "summarized", because a rotation writes no summary, and the replay leaves rotation notices out of the tail and clips an oversized newest row. A session that cannot rotate (a Claude backend, a cron-linked tab) keeps
main's replay and wording even withsoftset.The method switch, the rotation and its estimate live in
session_compaction.pyand the newsession_compaction_rotation.pyandsession_compaction_methods.py; the callback'smethodis insession_parts/policy.pyandsession_parts/turn_context.py, whichsrc/kiro_crew/session.pyre-exports. The tail budget and the replay switches are incontext_assembly/replay.py,context_assembly/budget.pyandcontext.py.dashboard/compaction_seed.pydecides which sessions may rotate: a tab's own session key only. The notices are indashboard/state_parts/session_events.pyanddashboard/chat_turn/. The key is inconfig/sections_session.py, with its PATCH entry indashboard/handlers/core_config_schema.pyand its class inchange_card_catalog_kinds.py. The Compaction Method select sits after Auto-Compact Threshold inwebsite/src/pages/settings/ChatPanel.tsx, with its labels in thewebsite/src/i18n/catalogs. The spec isdocs/system-specs/modules/session.md;config-baseline.json,settingsRegistry.gen.tsand the indexes undersrc/kiro_crew/docs/are regenerated.Backwards compatibility
Compatible:
session.compaction_methoddefaults tonative, and with it the coordinator dispatches exactly asmaindoes and the replay is byte-identical. The compact callback gains amethodkeyword; its one registrant insrc/(dashboard/state_parts/session_events.py:_on_compacted) and every test fake accept it.build_session_replay,replay_textandreplay_budget_charsgain keyword arguments with defaults.Removes nothing: no key, record, route or public function goes away, and a config without the key reads
native.Tests
test/test_compaction_ladder.py:nativereads no rotation seam;softruns or hands tonative; it waits for a shared sub-agent and says it is rotating, not failed; a Stop during that wait settlescancelled, namessoftand releases the turn permit once; a raise after the new session started isfailedwith nonativerun; queued messages reach the new session; an idle compaction never rotates; a weak rotation cools down and may rotate again.test/test_compaction_seed_writer.py: only a tab's own session key may rotate; a cron job tab, a cron run tab, a workflow tab and a channel session answer no.test/test_replay_rotation.py,test/test_compact_after_turn_notice.py: a Claude session and a cron-linked tab replay and read asnativewithsoftset; rotation notices spend none of the tail; the newest-row clip; the mid-turn notice's method.test/test_session_compaction_methods.py,test/test_compaction_method_config.py,test/metrics/test_business_counters.py,test/test_dashboard_state_ws.py: the estimate arithmetic; the key and its PATCH entry, an unknown name loading asnative; the counter for a rotation; the rotation notices, including a Stop's.website/src/test/SettingsChatPanelCoverage.test.tsx,website/src/test/CompactionCard.test.tsx: the select writes the key and shows the pick at once; the card says "compacted" forsoft, keepsmain's "summarized" otherwise, and draws no raw pause glyph on a waiting notice.The 1,467 tests in the 17 changed test files pass 5 runs at 4 workers and two shuffled orders in one process (seeds 11 and 4242).
Manual verification
nativetook 132 s at 99% of a 1M window (one model call, recorded 2026-09-05).softspends no model call: the new session starts with at mostreplay_budget_charsof replayed tail. Still required: a live gateway run withsoftthrough a real threshold crossing.Screenshots / video
Captured from a gateway of this branch (
kiro_crew.testing.harness.spawn_feature_gateway). The notice rows were written by the real compact callback, and the tab was reloaded from disk.A soft rotation, and the notice while it waits for sub-agents:
Settings > Chat > Advanced, closed and open:
The mid-turn notice with soft and with native, and the rotation notice at 420 px
Related Issues
Refs #8865 (the dashboard looks frozen while auto-compaction runs):
softshortens that wait when an operator picks it, and the default is unchanged, so #8865 stays open.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)