Skip to content

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

Closed
Pearcekieser wants to merge 2 commits into
kirodotdev:mainfrom
Pearcekieser:feat/mcp-session-continue
Closed

Pearcekieser wants to merge 2 commits into
kirodotdev:mainfrom
Pearcekieser:feat/mcp-session-continue

Conversation

@Pearcekieser

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 finally, 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 (#15436) 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.
  • Regenerate, or re-running a failed turn. That is session_retry.
  • Relaying to a remote crew. A crew-bound target is refused.

What changed (motivation → approach → change)

Stacked on #15436. Until that PR merges, this branch carries its commit (session_retry and the extraction of continue_slot_turn out of api_chat_slot_continue). Once it lands, this branch is rebased onto main and only the second commit remains. Please review the second commit.

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_continue calls the same continue_slot_turn without require_interrupted, so every refusal the button makes applies unchanged.

  • continue_slot_turn in dashboard/chat_handlers.py returns which body it queued, resumed or continued.
  • continue_target and retry_target in dashboard/session_control.py now share one helper, _continue_turn_of_target: prewarm, authorize_target, the remote-crew refusal, the synchronous re-check under the slot lock, and the audit line, which now records the body. The two verbs differ only in require_interrupted.
  • New route POST /api/session-control/continue (handler in dashboard/handlers/session_control.py), registered and added to _STRICT_INTERNAL_API_PATHS in dashboard/server.py.
  • New MCP tool session_continue(target) in mcp_dashboard.py. The reply names the body sent. It joins SESSION_CONTROL_TOOLS, CHANNEL_AGENT_BLOCKED_TOOLS in channel.py, MCP_DASHBOARD_SCHEMAS in validation.py, and mcp_tool_titles.json.
  • Docs: a session_continue section in 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.

Backwards compatibility

Compatible: a new tool and route. retry_target keeps its result shape and refusal codes. Its audit line gains a body detail, and the advisory text of its remote_target_unsupported refusal changes wording.

Tests

test/test_session_control_continue.py:

  • A turn with a reply and no error row is continued with the carry-on body and body: continued. 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, remote-bound, 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 in the strict internal set.
  • The MCP tool posts the verified caller key, names the body in its reply, reports refusals as errors, and has no prompt argument.

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

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

Fixes #15446

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

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Intent: let an agent hand a session it created back to that session's agent through the Continue button's own path, so a turn cut short by a restart or a killed process can be picked up without re-sending the prompt.
Not a goal: editing or replacing the prompt, re-running failed turns (that is session_retry in #15436), or relaying to a remote crew.

Stacked on #15436: until it merges this branch carries its commit, and the second commit is this PR's change. This stays a draft until #15436 lands and the branch is rebased onto main.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@Pearcekieser
Pearcekieser force-pushed the feat/mcp-session-continue branch from 00a8128 to 713c1ce Compare September 30, 2026 16:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto #15436's new head c32fb19. One conflict in the shared continuation helper: it now uses remote_bound_refusal(slot), the predicate #15436 switched session_retry to, so both verbs refuse crew-bound targets the same way the Continue endpoint does. No other change. Targeted tests (480) and lint/mypy on the changed files pass.

@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

1 similar comment
@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto #15436's new head ae2be5d (same patch on a newer main). Clean rebase, no change to this PR's commit; targeted tests pass.

@Pearcekieser
Pearcekieser force-pushed the feat/mcp-session-continue branch from 713c1ce to ef06902 Compare September 30, 2026 17:30
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 30, 2026
@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@Pearcekieser
Pearcekieser force-pushed the feat/mcp-session-continue branch from ef06902 to ae4b46e Compare September 30, 2026 18:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto #15436's new head 5b950cd. session_end_wait landed on main in the meantime, so the conflicts were in the tool lists and counts: both tools are kept, the docs now say 26 tools, and the session-control tool count test says 16. No behaviour change. Targeted tests (322, including the end_wait tests) and lint pass; the branch merges cleanly with main.

@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 30, 2026
@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@Pearcekieser
Pearcekieser force-pushed the feat/mcp-session-continue branch from ae4b46e to 8f670d1 Compare September 30, 2026 20:45
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto #15436's new head 5fc2d7c, which wraps the Continue audit line in a try/except. Clean rebase with no change to this PR's commit; targeted tests (277) pass and the branch merges cleanly with main.

@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

3 similar comments
@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@Pearcekieser
Pearcekieser force-pushed the feat/mcp-session-continue branch from 8f670d1 to d2bd2eb Compare September 30, 2026 23:15
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto #15436's new head 876b151 (same patch on a newer main). Clean rebase with no change to this PR's commit; targeted tests (277) pass and the branch merges cleanly with main.

@dwu96

dwu96 commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

1 similar comment
@dwu96

dwu96 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 1, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/mcp-session-continue branch from d2bd2eb to f318517 Compare October 1, 2026 05:30
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto #15436's new head 0371f80. The board-column tools landed on main meanwhile, so the only conflicts were the tool lists and counts in the docs (now 29 tools). No behaviour change; targeted tests (293) pass and the branch merges cleanly with main.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto #15436's new head 7219353 (on main d8d052f); new head a8d8acc. No behavior change: resolved docs and tool-count conflicts with session_reload by keeping both sides. Merges cleanly with current main; 1,192 targeted tests, flake8 and black pass.

@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

1 similar comment
@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 2, 2026
@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

6 similar comments
@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 2, 2026
@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

3 similar comments
@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

3 similar comments
@dwu96

dwu96 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

buluoray added a commit that referenced this pull request Oct 12, 2026
…-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

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Taking this over in #19590 since it has been idle; you are credited as co-author on the commits. Thanks for the groundwork.

buluoray added a commit that referenced this pull request Oct 12, 2026
…-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 added a commit that referenced this pull request Oct 13, 2026
…-short turn (#19590)

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>
@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you for this work, @Pearcekieser. The same change landed on main through #19590 (commit 005f1ae, "feat(session-control): session_continue picks up a peer session's cut-short turn"), which also closed #15446. Closing this one as superseded. If we got that wrong and something here is still missing from main, please reopen.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

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

4 participants