Repository navigation
feat(session-control): session_retry re-runs a failed turn like Resume - #16434
iamwhatever wants to merge 1 commit into
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the [DESIGN-REVIEWED] 82bd82b Description read[DESCRIPTION-READ] 3b6a437d1bb5ecc1e7257451c1cb58c9880a02edabc9a051f4d7782c35c63325 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 Check one thing before merge: the Resume endpoint now dispatches when its SEL audit write fails, where it used to return a 500. Confirm the audit owners accept a turn that runs with no What this change shipsInventory (7 items) — 7 justifiedIntent: let an agent re-run a failed turn in a session it created, the way a person presses Resume, without sending the prompt again (Fixes #15431). This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 82bd82b Description read[DESCRIPTION-READ] b280156cbb7f8bed6f1641487aeca6ac4e7f4a64af0b721905f471528ac089ec That sha256 names the PR description this verdict read. Recompute it with |
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: |
…turn the way Resume does Adds a kirocrew-dashboard MCP tool and POST /api/session-control/retry. The Continue endpoint's body moves into chat_handlers.continue_slot_turn, which both the Resume button and the new verb call. The verb passes require_interrupted=True, so a target whose last turn finished or was stopped is refused with turn_not_failed, and re-runs authorize_target under the slot lock before the continuation is queued.
8eadac1 to
82bd82b
Compare
|
Automated rebase attempt onto The single commit conflicts in 5 files. I didn't resolve them automatically because main has restructured the code this PR edits:
The author should rebase this by hand. |
This is an in-repo replacement of fork PR #15436, rebased onto current
main. The original is a fork PR, which cannot consume/ai-reviewoverrides for security-class lanes; this same-repo PR carries @Pearcekieser's identical commit (authored by them, so Rebase-and-merge lands their authorship). Conflict resolution only updated the three doc tool-count/list files thatmainmoved underneath the branch (thekirocrew-dashboardsurface now advertises 30 tools, so the doc count went 29 → 30); the feature mechanism is unchanged.Original description follows.
Problem / Motivation
Goal: an agent can restart a session it created whose last turn failed, the same way a person presses Resume, without re-sending the prompt.
When a session's last turn fails (
Request initialize timed outat start, or a backend error mid-turn), the only thing another agent can do today issession_sendthe prompt again. That puts a second copy of the user message in the transcript, and a patrol loop has to guess which message was the one that failed. The dashboard's Resume button (POST /api/chat/slots/{slot}/continue) already does the right thing for a person, but no MCP tool reaches it.Why it matters
Patrol and conductor loops restart timed-out worker sessions routinely. Each restart by re-send doubles a prompt in the transcript and can re-run the wrong request when the tail holds more than one user row.
Not a goal
session_revivecovers that.What changed (motivation → approach → change)
continue_slot_turninchat_handlers.pydashboard_continueaudit line is now best-effort, so an audit failure after the recovery entry is queued cannot leave that entry strandedretry_targetinsession_control.pyauthorize_target, refuses crew-bound targets with the sameremote_bound_refusalpredicate Continue uses, then callscontinue_slot_turnwithrequire_interrupted=Truesession_retryinmcp_dashboard.py,POST /api/session-control/retryvalidation.py) and its route, in_STRICT_INTERNAL_API_PATHSand inCHANNEL_AGENT_BLOCKED_TOOLSinchannel.pyI started from regenerate, as the issue suggested, and it is the wrong path.
api_chat_slot_regeneratewalks back from the tail for an assistant row and stops at the first user row, so the[user, error]tail a failed start leaves returnsno_assistant_message. Where it does apply, it moves a good reply into a variant. Resume is the dashboard's control for a failed turn, andis_turn_interruptedis the predicate that already decides when the composer offers it. So the verb calls the existing Continue logic directly, through one small shared helper, rather than going through regenerate.The helper takes two things only the verb uses.
require_interrupted=Truerefuses a target whose last turn finished or was stopped (turn_not_failed), so a retry cannot make a session answer again on top of a good reply.before_dispatchre-runsauthorize_targetsynchronously under the slot lock, right before the queue insert. The lock and the sub-agent probe are awaits, and a target can become channel-linked or be replaced in that window. Every refusal Continue already makes still applies, includingsession_start_repeatafter two identical failed starts.One difference from a Resume press is deliberate: the verb queues the recovery turn with
directive_user_origin=False, so the resumed turn does not carry the authenticated-human flag a person's press sets. An agent asked for it, not the person at the keyboard. The queue entry carries the caller'ssend_origin_slotstamp. The session-control audit line records the caller's session key, and the target'sdashboard_continueline recordsvia=session_control. Docs are updated insrc/kiro_crew/docs/session-control.md,docs/index.md,docs/system-specs/modules/session-control.md,docs/feature-map/README.mdanddocs/architecture/mcp.md, anddata/mcp_tool_titles.jsongets the tool's title.Backwards compatibility
Compatible: the Continue endpoint returns the same codes, statuses and bodies; its audit line keeps
metadata={"slot": ...}and only a session-control retry addsvia. The one behaviour change is on a failing audit: Continue now logs a warning and still dispatches, where it used to 500 with the entry left queued.Tests
test/test_session_control_retry.py: a retry still dispatches when the audit log raises; a failed start and a no-reply turn are both resumed with the resume body queued and no new user row; a finished turn and a stopped turn are refused withturn_not_failedand nothing queued; a running target, a target the fenced caller did not create, a crew-bound target, and Resume's repeat refusal are all refused with their own codes; a target that becomes channel-linked while the lock is awaited is refused by the re-check; the handler maps refusals to their code; the route is in the strict internal set; the tool posts the verified caller key and renders success and refusal.test/test_pending_boundary_consumer_semantics.py: therunningreader moved fromapi_chat_slot_continuetocontinue_slot_turn.test/test_session_control_doc.py,test/test_mcp_dashboard_registration.py,test/test_mcp_dashboard_folders.py: the tool count and advertised set includesession_retry.test/test_chat_slot_continue.pypasses unchanged against the refactored endpoint.Manual verification
N/A: unit coverage exercises the verb against a real
DashboardStatewith only the turn dispatcher stubbed, and the Continue endpoint's own suite passes unchanged.Related Issues
Fixes #15431
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)