Repository navigation
fix(chat): answer /compact at once in a brand-new chat - #24761
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix reuses the existing Notes
[DESIGN-REVIEWED] a7e9cfc Description read[DESCRIPTION-READ] 1ccf2ba6ab9982c87144a97d6a4604b3a3a8c567250dbb36aa561eb4e08710e1 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix reuses the existing What this change shipsInventory (4 items) — 4 justifiedIntent: a user who sends
[FIRST-PRINCIPLES-REVIEWED] a7e9cfc Description read[DESCRIPTION-READ] 722a941383cd1c2e2cb06869faec3a6bb33384b83763978413c657497cd7e67c That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
2b1e587 to
e6a455d
Compare
e6a455d to
9dbd8ed
Compare
|
CI status on 9dbd8ed: Replies to the non-blocking notes:
|
A /compact sent as the first message of a new dashboard chat reached a fresh kiro-cli session that holds no conversation. kiro-cli ends that turn with 'Conversation too short to compact.' and sends no compaction status, so the deferred wait ran the full compaction timeout and then reported a timeout. The fresh session's first-turn history debt is armed at admission and settled only by a kept non-slash turn, so it already tells the gateway the native session is empty without matching kiro-cli text. On a backend that does not compact inline, answer such a /compact at once with a 'nothing to compact yet' notice and leave the debt and skills context for the next prompt. Fixes #15722
9dbd8ed to
a7e9cfc
Compare
|
Head a7e9cfc is rebased on main after #24774 and includes the notice wording change. All checks are done: 0 pending, 0 failing. The 8 cancelled runs are duplicates, cancelled when the push and the body edit both started runs at 13:03. Each one has a passing twin on this head. Reply to the new non-blocking note, about a first prompt that failed before delivery: the user sees "Nothing to compact yet" once, and the next message settles the debt. Telling that case apart would mean reading kiro-cli's partial state. That is outside this fix, so I left it as is. On KAS and codex-acp the arm only fires while the session is empty, so nothing is lost there. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (4 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: answers /compact at once on a fresh provider session instead of waiting out the compaction timeout; with a test. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/providers.md.
Problem / Motivation
Goal:
/compactsent as the first message of a brand-new dashboard chat answers at once instead of holding the chat for 300 s and reporting a timeout.In a new chat on the kiro-cli backend,
/compactas the first message shows the compacting state with input disabled, then after 300 s shows "⚠ Compaction timed out." for a compaction that never started.Why it matters
Anyone who tries
/compactearly in a new chat loses the chat for five minutes and gets a misleading timeout notice.Not a goal
/compactcommands (see Sibling sweep).Intended?
No. #14700 lists this exact case under "Not a goal" as "a separate change", so it was left open on purpose, not chosen as the behavior. Nothing in
docs/system-specs/modules/providers.md, code comments or tests says a fresh session should wait out the timeout. On main @ 561b345 the only early exit in the/compactarm isif _replay_pending:in_turn_compact_command(src/kiro_crew/dashboard/chat_turn/slash_commands.py:805). A fresh session with no replay owed falls to theelsearm and awaitsclient.wait_for_compaction()for the full budget (slash_commands.py:820-829).Repro
Read from code on main @ 561b345 (no local test runs on this host; the new test runs in CI):
/compact.turn_admission.py:1138-1139armsfirst_turn_history_owedbecause the claim is FRESH (is_new and not resumed).provider_switch_replay_pendingis False, so_replay_pendingis False.end_turnand sends no_kiro.dev/compaction/status(the reporter's direct ACP check in [bug] /compact as the first message of a brand-new dashboard chat waits 300 s and reports a timeout #15722)._turn_compact_commandskips the_replay_pendingarm,compacts_inlineis False for kiro-cli, so it broadcastsrole: compactingand waitscompact_wait_budget_secs(). Resulttimeout-> "⚠ Compaction timed out." The reporter saw this twice (04:39:57 -> 04:45:13, 04:47:12 -> 04:52:25 UTC) with log lineDeferred compaction: waiting for compaction result.What changed (motivation → approach → change)
/compactin a new chat./compactarm only knows the replay-pending way a session can be empty. A FRESH session that no ordinary prompt has reached is empty too.first_turn_history_owedis armed at admission from a FRESH claim and settled only when a non-slash turn keeps its history with the provider (_turn_settle_debts), so while it is armed the native session holds no conversation. It also covers a second/compactin a row, which a one-shotis_newcheck would miss._turn_compact_command, a new arm after the replay-pending one: on a backend that does not compact inline, whenfirst_turn_history_owed_pending(session_key) is True, appendCOMPACT_FRESH_SESSION_NOTICE("Nothing to compact yet: the agent's session starts with your next message."; worded about the agent's session, not the chat, because a session restarted under an existing chat is fresh too while the chat still shows its messages) and return. It sends no compacting frame, waits for nothing, does not re-arm skills context and does not settle the debt.COMPACT_FRESH_SESSION_NOTICEsits besideCOMPACT_REPLAY_PENDING_NOTICEinchat_turn/recovery.py. The providers spec gets one bullet for the new case.Backwards compatibility
Compatible: only a
/compacton a session whose first-turn history debt is still armed changes. It used to wait and time out, and now answers at once. Every other/compactpath is unchanged.Removes nothing: the diff adds one arm and one constant and takes away no path, record, key or function.
Tests
test/test_dashboard_chat_compaction.py::TestRunChatCompactDeferredWait::test_fresh_session_compact_returns_without_waiting: a FRESH kiro-cli session (is_new=True, resumed=False, debt armed, no replay) given/compactmakes nowait_for_compactioncall, sends no compacting frame, arms no reinjection, does not settle the debt, and appends exactlyCOMPACT_FRESH_SESSION_NOTICEwith no timeout notice. On main this test fails: the turn awaitswait_for_compaction(the mock returnstimeout) and appends "⚠ Compaction timed out."/compacttests use aMagicMocksessions double whosefirst_turn_history_owed_pendingis notTrue, so they still take the wait arm unchanged.Proof: not provable -- other: this host never runs tests locally; the new test runs in CI
Static gates run locally on the changed files: black, isort, flake8 clean;
scripts/docs-lint.shpasses. mypy and the test suite run in CI.Manual verification
N/A — unit coverage is enough. The change is one branch in the turn-end
/compacthandler, and the test drives_run_chatend to end through it.Related Issues
Fixes #15722
Follow-up to #14700 (same shape for a replay-pending session).
Sibling sweep
Swept: git grep -n "wait_for_compaction(" -- src/
Sibling: src/kiro_crew/slack/handler_runtime/commands.py -- not affected -- refuses /compact unless a live session already exists, so a prior message has given it a conversation
Sibling: src/kiro_crew/telegram/dispatch/commands.py -- not affected -- compacts only an already-live session started by an earlier message
Sibling: src/kiro_crew/discord/transport_dispatch_commands.py -- not affected -- compacts only an already-live session started by an earlier message
Pattern harvest
Not generalizable: this is one missing "session is still empty" arm in the dashboard
/compacthandler, and the signal for it is local to this runner.Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.