Skip to content

feat(session-control): session_continue picks up a peer session's cut-short turn - #19590

Merged
buluoray merged 1 commit into
mainfrom
fix/session-continue-15446
Oct 13, 2026
Merged

buluoray merged 1 commit into
mainfrom
fix/session-continue-15446

Conversation

@buluoray

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: an agent can pick up a session it dispatched after that session's turn was cut short by a gateway restart or a killed process, the same way a person presses Continue.

A force-quit turn runs no cleanup, so it leaves no error row and reads like a finished turn. The dashboard's Continue control (POST /api/chat/slots/{slot}/continue) handles it. Agents have no equivalent: session_retry refuses exactly this case with turn_not_failed, and re-sending the prompt with session_send adds a second copy of the request and does not tell the model it was interrupted.

Why it matters

Conductor and patrol sessions restart their workers after every gateway restart. Today they re-send the last prompt by hand, which duplicates it in the worker's transcript and makes the model start over instead of checking what it already did.

Not a goal

  • Editing or replacing the prompt. The tool takes only target.
  • Regenerating or re-running a failed turn. That is session_retry.
  • Auto-approving the tool for crew members or conductors. It is in no grant tuple.

What changed (motivation → approach → change)

The Continue endpoint already chooses between two bodies: the interrupted pick-up when _is_interrupted says the last turn was cut short, and a carry-on message otherwise. session_retry (#15436) reaches that same continue_slot_turn with require_interrupted=True. The smallest correct verb is the same call without that flag, so every refusal the button makes applies unchanged.

  • continue_slot_turn (dashboard/chat_handlers.py) returns which body it queued, "resumed" or "continued". Its only other caller, the Continue endpoint, ignores the value.
  • retry_target and the new continue_target (dashboard/session_control.py) share one helper, _continue_turn_of_target: window load, prewarm, authorize_target, the relay-archive refusal, the synchronous re-check under the slot lock, and the audit line, which now records body. The two verbs differ only in require_interrupted and the operation name.
  • New route POST /api/session-control/continue (handler in dashboard/handlers/session_control.py, registered in server_runtime/mcp_routes.py, added to _STRICT_INTERNAL_API_PATHS).
  • New MCP tool session_continue(target) in mcp_dashboard.py (strict identity). The reply names the body sent. It joins CHANNEL_AGENT_BLOCKED_TOOLS, MCP_DASHBOARD_SCHEMAS and mcp_tool_titles.json.
  • agent.py: a comment records that the tool is withheld from the conductor and member grant tuples, and why.
  • Docs: a session_continue section in the user page docs/session-control.md, the tool count in docs/index.md, and rows in docs/architecture/mcp.md, docs/feature-map/README.md and docs/system-specs/modules/session-control.md.

Supersedes #15459 by @Pearcekieser (co-author). Review of #15459: the design is right (Continue's path without require_interrupted, report the body, one shared helper), but it was stacked on #15436, which merged reshaped (the Tool table, load_target_window, the relay-archive refusal instead of remote_target_unsupported), so its second commit no longer applied; this PR rebuilds that commit on main and ports its tests.

Backwards compatibility

Compatible: a new tool and a new route. retry_target keeps its result shape and refusal codes; its allowed audit line gains a body detail, and continue_slot_turn now returns a string that the Continue endpoint ignores.

Removes nothing: the diff only adds a verb and a return value.

Tests

test/test_session_control_continue.py (new, ported from #15459):

  • A turn with a reply and no error row is continued with the carry-on body, and body: continued is in the result and the audit line. session_retry refuses this same shape, so this is the case the tool exists for.
  • An interrupted turn gets the pick-up body and body: resumed.
  • The queued entry never carries the authenticated-human flag.
  • Refusals: running, queued messages, empty session, not the caller's child under the ownership fence, self target, session_start_repeat, relay archive, and a target that becomes channel-linked while the slot lock is awaited.
  • The handler returns the body and renders refusals with their code; the route is registered and strict-internal.
  • The MCP tool posts the verified caller key, names the body in its reply, reports refusals as errors, has no prompt argument, and is in no shipped grant tuple.

Updated: the tool lists in test_mcp_dashboard_registration.py, test_mcp_dashboard_folders.py and test_session_control.py, and the session-control group count in test_session_control_doc.py. The session_retry tests pass unchanged on the shared helper.

Mutation check: setting require_interrupted=True in continue_target reddens 4 tests; making continue_slot_turn always return "continued" reddens 1.

Manual verification

N/A, unit coverage sufficient: the route and the tool are thin wrappers over continue_slot_turn, which the Continue button already exercises, and the tests drive it on real slots with only the turn dispatcher stubbed.

Related Issues

Closes #15446
Supersedes #15459

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

Decision for the owner

Whether session_continue should join _MEMBER_DASHBOARD_GRANTS the way session_retry did, so a crew member's unattended patrol can restart its own workers without an approval prompt. This draft leaves it out of every grant because, unlike session_retry, it does not refuse a cleanly finished turn, and adding an auto-approval is a widening the owner should choose.

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

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision c7beb6f7f18ee13ff06b440a4490e2dfbde3094d 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 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Before merge, check one thing: a patrol that calls session_continue on a worker whose turn ended cleanly starts a new carry-on turn nobody asked for. Calls go through approval for now, so this is acceptable.

Suggestions

  • The stated benefit is that conductors and patrols stop re-sending prompts by hand, but no shipped skill tells them to use the new tool yet (no skill in builtin_skills/ mentions session_retry either). A follow-up should update the conductor and patrol guidance to call session_continue, and to check body before treating a continued result as a real pick-up.

[DESIGN-REVIEWED] c7beb6f

Description read

[DESCRIPTION-READ] 8f0375aa3e187bbf3674f728cf0188b18a712138e19d3cf8cfcc819465258a55

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

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c7beb6f7f18ee13ff06b440a4490e2dfbde3094d — 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

Check before merge: session_continue lets one session make another produce a fresh turn after a clean finish, which turn_not_failed refuses for retry.

What this change ships

Inventory (7 items) — 6 justified

Intent: an agent that dispatched a worker can pick up that worker's turn after a gateway restart or a killed process cut it short, without re-sending the prompt. ADDITION.

  1. Agents get a new session_continue(target) tool that does what the Continue button does for a session they control — justified
  2. New strict-internal route POST /api/session-control/continue — justified
  3. The tool's reply, and the route's result, say which fixed message was sent: resumed or continued — justified
  4. session_retry's allowed audit line now records body — rides along: a harmless one-field detail on the shared helper
  5. Channel-driven agents cannot call session_continue (added to CHANNEL_AGENT_BLOCKED_TOOLS) — justified
  6. The tool is in no auto-approval grant, so every call asks for approval — justified
  7. continue_slot_turn returns the body it queued; the only new consumer is _continue_turn_of_target — justified

[FIRST-PRINCIPLES-REVIEWED] c7beb6f

Description read

[DESCRIPTION-READ] ef6300e0730e7492295eb178b7ea69db66c9d23512f159a2dfad6f654ed03925

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

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] c7beb6f

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

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

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c7beb6f

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

…-short turn

Adds a kirocrew-dashboard MCP tool and POST /api/session-control/continue.
It calls continue_slot_turn without require_interrupted, the way the
Continue button does, so a force-quit turn that left no error row (and
that session_retry refuses as turn_not_failed) can be picked up.
continue_slot_turn now returns which body it queued, and the result and
the allowed audit line report it as body=resumed|continued. retry_target
and continue_target share one authorize / re-check / dispatch helper.

The tool takes no prompt text, is blocked for channel agents, and is in
no auto-grant tuple, so a member or conductor is asked before each call.

Supersedes #15459, rebuilt on main after #15436 merged.

Closes #15446

Co-authored-by: Pearce Kieser <5055971+Pearcekieser@users.noreply.github.com>
@buluoray
buluoray force-pushed the fix/session-continue-15446 branch from 548efba to c7beb6f Compare October 12, 2026 23:02
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Dispositions for the advisory notes on 548efba, plus the fix pushed as c7beb6f.

  • Backend Tests shard 6 (Linux and Windows): caused by this diff. test/test_dashboard_server_composition_contract.py pins the MCP route table's row count and digest, and the boot trace's _deferred calls. The new /api/session-control/continue route adds one to each. c7beb6f updates the pinned values (282 rows, new digest, one more _deferred in each of the two boot traces). That file now passes locally, 109/109.
  • Design: no grant tuple, so unattended callers get an approval prompt. This is intended, and it is the open owner decision in "Decision for the owner". Adding session_continue to _MEMBER_DASHBOARD_GRANTS is a one-line follow-up if the owner wants it.
  • First Principles: the force-quit case gets _MANUAL_CONTINUE_MSG. That is the body the Continue button sends for the same transcript shape, and the issue asks for "the same thing the dashboard's Continue button does". The message already says to take the next outstanding step, finish anything half-done, and not re-run completed steps. Rewording it would change the button too, so it stays out of scope.
  • First Principles: body on the retry audit line is always resumed. True. It falls out of the shared helper and costs nothing. I kept it so both verbs' audit lines have the same shape.

@buluoray
buluoray marked this pull request as ready for review October 13, 2026 00:20
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners October 13, 2026 00:20
@buluoray
buluoray requested a review from mbriones98 October 13, 2026 00:20
@buluoray
buluoray enabled auto-merge (squash) October 13, 2026 00:20
@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 13, 2026

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[code-review-sage]

Ship summary: no blocking issues; no must-fix or should-fix findings.

Problem: after a gateway restart or killed process, an agent that dispatched a worker has no way to pick up the worker's cut-short turn. session_retry refuses it with turn_not_failed because a force-quit leaves no error row, and re-sending the prompt duplicates it. Solution: a session_continue(target) tool and POST /api/session-control/continue route that call the same continue_slot_turn the Continue button uses, without require_interrupted. Retry and continue now share one helper (_continue_turn_of_target), so every refusal (running, queued, approval pending, sub-agents attached, session_start_repeat, relay archive, ownership fence, re-check under the slot lock) applies unchanged. The design is proportionate and the strongest alternative (extending session_retry) is correctly rejected because retry's turn_not_failed guard is deliberate.

Checked and found sound: the directive_user_origin=False path keeps agent-initiated turns from gaining the human flag; the tool takes only target, so no prompt text can be injected; the route is strict-internal; the tool is in CHANNEL_AGENT_BLOCKED_TOOLS and in no member/conductor grant tuple (so each call asks for approval); session_retry keeps its result shape and refusal codes, and only its allowed audit line gains a body detail; continue_slot_turn's new str return is ignored by the only other caller; the audit/operation naming flows through authorize_target and the re-check consistently; tool lists, schema table, titles, composition-contract pins and docs are all updated, and the PR description matches the diff in both directions. CI checks are green on this head.

Findings: none.

This is review feedback only and not an approval; the merge decision stays with the human reviewers.

@buluoray
buluoray merged commit 005f1ae into main Oct 13, 2026
107 checks passed
@buluoray
buluoray deleted the fix/session-continue-15446 branch October 13, 2026 02:15
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 13, 2026

@CrysisDeu CrysisDeu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed head. session_continue reuses session_retry's full authorize_target + under-lock re-check, refuses running/queued/approval-pending/empty, and the refusals are tested. 21 files are all registration points and pinned tables. CI green. Approving.

One wording fix, please: body == "continued" is rendered as "its last turn had ended, so it was told to carry on" (mcp_dashboard.py:2929-2931, and "ended cleanly" in docs/session-control.md). A force-quit turn leaves no error row and also yields continued, so a conductor would read a crashed worker as finished. Suggest: "no interruption was recorded, so it was told to carry on (a force-quit turn looks like this too)". Also default resp.get("body") to "" rather than the "had ended" sentence.

Posted by code-reviewer (Kiro Crew member) on behalf of @CrysisDeu. Full report on file.

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.

session_continue: let an agent pick up a peer session's cut-short turn the way Continue does

3 participants