Skip to content

fix(chat): a stopped throttle episode leaves no retry count for the next turn - #21937

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/throttle-stop-clears-retries
Oct 19, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/throttle-stop-clears-retries

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

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's turn_stats.retries and 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 a recovered outcome for an episode nobody recovered.

Why it matters

The Continue turn's row carried a wrong retries value, which latency reports read, and telemetry gained a false recovered point. #21907's own rule is that a user-cancelled episode emits nothing.

Not a goal

  • The throttle classifier. fix(chat): re-send a throttled turn with one copy of the prompt in history #21907's raw-frame AcpError.throttle stays: 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.
  • Any other Stop handling, including the transient budget on the still-resolving arm, the wait curve, or the rewind.

What changed (motivation → approach → change)

Stop during a throttle episode, then Continue Before After
turn_stats.retries on the Continue row the stopped episode's count absent
recovered outcome for the stopped episode emitted none

The 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 bare pass. Each now also sets slot._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_state is soft_pending when 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 no retries and no recovered point.
    • test_stop_during_the_fallback_rewind_drops_the_fallback_resend: now also checks the model-fallback Stop arm clears the count.
    • _KasHistory gains a before_failure hook, 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 -n0 of the changed file (12 passed each), 10 runs at -n 2 --dist loadgroup --max-worker-restart=2 with test/test_dashboard_chat_transient_stream.py and test/test_kas_manual_compact.py as 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

…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
@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 18, 2026 17:25
@iamwhatever
iamwhatever requested a review from buluoray October 18, 2026 17:25
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 7d16e360224f36e5344da98a9d29cd7d554db4eb touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7d16e360224f36e5344da98a9d29cd7d554db4eb — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

One thing to check before merge: the _transient_5xx_retries resets at chat_runner.py:14839 (thinking-mismatch rebuild) and :15836 (fresh-conversation requeue) still keep _turn_retries. That should be deliberate.

What this change ships

Inventory (5 items) — 5 justified

Intent: 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 recovered outcome. This is a FIX.

  1. A Stop that is still resolving when a re-send fails now clears the episode's retry count — justified
  2. A Stop that has resolved before the backoff now clears the count — justified
  3. A Stop after the backoff now clears the count, so the Continue row carries no retries and no recovered point — justified
  4. A Stop during the model-fallback wait now clears the count — justified
  5. Test stream helper gains a before_failure hook so a test can press Stop mid-attempt — justified

[FIRST-PRINCIPLES-REVIEWED] 7d16e36

Description read

[DESCRIPTION-READ] 4b82af5b96b8f92696fab72ac6997f6f9582037df1e65d272d4141522cf14e94

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 7d16e360224f36e5344da98a9d29cd7d554db4eb — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check the Stop arms outside the transient ladder: if the process dies (AcpProcessDied) during a throttled re-send and the user stops, the Continue turn still inherits _turn_retries.

Suggestions

  • These resets sit on each exit arm separately, and the PR's pattern harvest says the same: every new Stop arm would need its own reset. A simpler shape is to clear _turn_retries once, at the point where a Stopped turn queues its Continue recovery entry. Then a Stop can never pass a count to the next turn, whichever arm it took.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7d16e360224f36e5344da98a9d29cd7d554db4eb and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7d16e36

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7d16e360224f36e5344da98a9d29cd7d554db4eb: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 7d16e360224f36e5344da98a9d29cd7d554db4eb — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7d16e36

Verdict parsed from the review's SHA-scoped output markers for commit 7d16e360224f36e5344da98a9d29cd7d554db4eb.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7d16e360224f36e5344da98a9d29cd7d554db4eb: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 18, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 19, 2026 01:17
@KiroCrewCaptain
KiroCrewCaptain merged commit 287f58a into main Oct 19, 2026
106 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/throttle-stop-clears-retries branch October 19, 2026 01:47
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 19, 2026
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