Repository navigation
fix(chat): a stopped throttle episode leaves no retry count for the next turn - #21937
Conversation
…ext turn Follow-up to #21907. A Stop that ended a throttle episode reset the transient budget (or, for a Stop still resolving, nothing) but kept _turn_retries. A later Continue runs as a recovery turn, which keeps the running count, so it reported the stopped episode's retries in turn_stats and emitted a "recovered" outcome for it. Each of the four Stop arms on the ladder (a Stop still resolving, before the backoff, after it, and during the model-fallback wait) now clears the count. Refs #21876
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS One thing to check before merge: the What this change shipsInventory (5 items) — 5 justifiedIntent: when a user stops a throttled turn and then presses Continue, the Continue turn should not report the stopped episode's retries or a false
[FIRST-PRINCIPLES-REVIEWED] 7d16e36 Description read[DESCRIPTION-READ] 4b82af5b96b8f92696fab72ac6997f6f9582037df1e65d272d4141522cf14e94 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check the Stop arms outside the transient ladder: if the process dies ( Suggestions
[DESIGN-REVIEWED] 7d16e36 Description read[DESCRIPTION-READ] cf624523a949b8849cb39fe20aa3655a866fc930f5cfd81c634502ccc2983fab 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 — ✅ 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: |
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: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Every review lane on the head is clean (only runner notices and PR Scope size warnings); held by the triage cron on a path, category, checklist or P0-area rule, not a finding. Approved on the watch holder's request.
Problem / Motivation
Goal: A throttle episode the user stopped leaves no retry count for a later turn.
#21907 counts each re-send of a throttled turn in
slot._turn_retries, for the landed row'sturn_stats.retriesand the recovery-outcome counter. A Stop that ends the episode kept that count: while the Stop is still resolving, before the backoff, after it, or during the model-fallback wait. Continue runs as a recovery turn, which keeps the running count, so the Continue turn reported the stopped episode's retries and emitted arecoveredoutcome for an episode nobody recovered.Why it matters
The Continue turn's row carried a wrong
retriesvalue, which latency reports read, and telemetry gained a falserecoveredpoint. #21907's own rule is that a user-cancelled episode emits nothing.Not a goal
AcpError.throttlestays: the dependency signal reads the formatted message, which calls a transient model-unavailable error a "capacity throttle", so moving to it would back those errors off 3x longer and delay the model swap by about 28 s.What changed (motivation → approach → change)
turn_stats.retrieson the Continue rowrecoveredoutcome for the stopped episodeThe transient ladder in
_run_chat(src/kiro_crew/dashboard/chat_runner.py) has four arms where a Stop ends the episode without a re-send. Three already reset_transient_5xx_retries, and the still-resolving arm was a barepass. Each now also setsslot._turn_retries = {}. No landed or re-sending path changes, so their counts are kept.Backwards compatibility
Compatible: four added assignments on paths that already end the turn. Nothing else changes.
Tests
test/test_dashboard_chat_transient_throttle.py:test_a_stop_still_resolving_drops_the_episode_count: the arm for a Stop still resolving (_stop_stateissoft_pendingwhen the re-send fails).test_a_stop_during_a_resend_drops_the_episode_count: the Stop arm before the backoff (Stop lands while a re-send is in flight).test_a_stopped_episode_leaves_no_retries_for_the_continue_turn: the Stop arm after the backoff, then a Continue that lands with noretriesand norecoveredpoint.test_stop_during_the_fallback_rewind_drops_the_fallback_resend: now also checks the model-fallback Stop arm clears the count._KasHistorygains abefore_failurehook, where a test presses Stop during an attempt.Red before the fix: the changed test file on
origin/main(a9898a0) fails all four by assertion ({'throttle': 1} == {}twice,'retries' not in {...},{'throttle': 3} == {}); the other 8 pass. Dropping each arm's reset one at a time fails exactly that arm's test.Determinism: 20 runs at
-n0of the changed file (12 passed each), 10 runs at-n 2 --dist loadgroup --max-worker-restart=2withtest/test_dashboard_chat_transient_stream.pyandtest/test_kas_manual_compact.pyas co-tenants (49 passed each), and one shuffled order, seed 27906 (12 passed).Local gates: isort, flake8, black and mypy on the changed files, the backend static scripts from the profile (all 20 pass), and 20 related test files (1,022 passed). Local review: GPT found nothing, and Opus's one finding was about the classifier change, which this PR leaves out. A focused Opus check of this commit confirmed the four resets are the whole production change.
Manual verification
None: the change adds four assignments on Stop paths and sends nothing new.
Related Issues
Refs #21876
Pattern harvest
Rule candidate: review-prompt
Pattern: an episode counter reset on the landed and terminal arms must also be reset on every arm a Stop takes, or the next recovery turn inherits it.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)