Skip to content

feat(session-control): session_retry re-runs a failed turn like Resume - #15436

Merged
buluoray merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/mcp-session-retry
Oct 9, 2026
Merged

buluoray merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/mcp-session-retry

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

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 out at start, or a backend error mid-turn), the only thing another agent can do today is session_send the 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

  • Editing the prompt before re-running it (edit-resend).
  • Switching or regenerating variants of a turn that succeeded.
  • Reopening archived sessions; session_revive covers that.
  • A readiness gate the Resume button does not have.

What changed (motivation → approach → change)

Piece What it does
continue_slot_turn in chat_handlers.py The Continue endpoint's body, moved out. The Resume button and the new verb both call it. Its dashboard_continue audit line is now best-effort, so an audit failure after the recovery entry is queued cannot leave that entry stranded
retry_target in session_control.py Authorizes with authorize_target, refuses an old relay chat with the same is_relay_archive check Continue uses (relay_archive_read_only), then calls continue_slot_turn with require_interrupted=True
session_retry in mcp_dashboard.py, POST /api/session-control/retry The MCP tool, a Tool(...) entry in the session family of the table from #17098 (schema in validation.py), and its route, registered in server_runtime/mcp_routes.py, listed in _STRICT_INTERNAL_API_PATHS and in CHANNEL_AGENT_BLOCKED_TOOLS in channel.py

I started from regenerate, as the issue suggested, and it is the wrong path. api_chat_slot_regenerate walks back from the tail for an assistant row and stops at the first user row, so the [user, error] tail a failed start leaves returns no_assistant_message. Where it does apply, it moves a good reply into a variant. Resume is the dashboard's control for a failed turn, and is_turn_interrupted is 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=True refuses 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_dispatch re-runs authorize_target synchronously 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, including session_start_repeat after 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's send_origin_slot stamp. The session-control audit line records the caller's session key, and the target's dashboard_continue line records via=session_control. Docs are updated in src/kiro_crew/docs/session-control.md, docs/index.md, docs/system-specs/modules/session-control.md, docs/feature-map/README.md and docs/architecture/mcp.md, and data/mcp_tool_titles.json gets the tool's title.

A crew member's DM session gets session_retry without an approval prompt: it is added to _MEMBER_DASHBOARD_GRANTS in agent.py, beside session_send and session_stop, so a member's unattended patrol can restart a worker whose turn timed out. The member's created_by ownership fence bounds it to worker sessions that member opened. Conductors still get an approval prompt, and the WITHHELD list says why: they have no ownership fence. test_agent_refactor_contracts.py pins both tuples.

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 adds via. 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_chat_slot_continue.py::test_a_failing_audit_write_does_not_strand_the_queued_continue: drives POST /api/chat/slots/{slot}/continue with a raising audit write. It fails on main (assert 500 == 200, the entry stays queued and every later press is refused with slot_queue_pending) and passes here, where the turn dispatches.
  • 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 with turn_not_failed and nothing queued; a running target, a target the fenced caller did not create, an old relay chat, 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: the running reader moved from api_chat_slot_continue to continue_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 include session_retry.
  • test/test_chat_slot_continue.py passes unchanged against the refactored endpoint.

Manual verification

N/A: unit coverage exercises the verb against a real DashboardState with only the turn dispatcher stubbed, and the Continue endpoint's own suite passes unchanged.

Related Issues

Fixes #15431

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: give an agent the Resume button's action for a session it created whose last turn failed, so a timed-out or errored turn can be restarted without re-sending the prompt.
Not a goal: regenerating or editing a turn that succeeded, switching variants, reviving archived sessions, or adding a readiness gate that Resume itself does not have.

@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 marked this pull request as ready for review September 30, 2026 14:54
@Pearcekieser
Pearcekieser requested a review from a team as a code owner September 30, 2026 14:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of d0d28e0b23b8d6a25465610768d4e920a7a8398d via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that _is_interrupted treats every failure tail patrol loops see (backend error mid-turn, gateway restart, stop) as the tests assume, since member grants run it unattended.

[DESIGN-REVIEWED] d0d28e0

Description read

[DESCRIPTION-READ] ed1611bd25e6c54aa36c9daffdc11d22e32bc39627adcee7de144a5d7d94ab82

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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of d0d28e0b23b8d6a25465610768d4e920a7a8398d via the fork AI-review pipeline — 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: crew-member DM sessions get session_retry with no approval prompt, which lets an unattended member start turns in its workers.

What this change ships

Inventory (6 items) — 6 justified

Intent: an agent restarts a failed turn in a session it created the way Resume does, without sending the prompt a second time (Fixes #15431). This is an ADDITION.

  1. A new agent tool session_retry and its route re-run a failed last turn through Resume's existing path. No agent-facing equivalent exists: grepping for continue_slot|_MANUAL_RESUME_MSG|"retry" finds only the dashboard Continue endpoint — justified
  2. Retrying a turn that finished or was stopped is refused with turn_not_failed — justified
  3. Crew-member DM sessions run session_retry without an approval prompt, while conductors still get one — justified
  4. Channel agents cannot call session_retry. test_session_control_doc requires this for every session-control tool — justified
  5. The Resume button no longer returns 500 and leaves its queue entry stuck when the audit write fails. This rides along, but it comes with a test that fails on base — justified
  6. The target's access check runs again under the slot lock, and a new target_replaced refusal is added. Without it, the target could change during the waits that come before dispatch — justified

[FIRST-PRINCIPLES-REVIEWED] d0d28e0

Description read

[DESCRIPTION-READ] d85d82a4ca178b527517f1a03e16dbd97ec2b11e6aa6680736fd8b6632e9543c

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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed d0d28e0b23b8d6a25465610768d4e920a7a8398d via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] d0d28e0

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed d0d28e0b23b8d6a25465610768d4e920a7a8398d via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] d0d28e0

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Fixed: reuse remote_bound_refusal's predicate for the crew-bound refusal (span=ddafaec057b0)

Outcome: fixed in c32fb19, the first of the two options offered.
retry_target now refuses a crew-bound target when remote_bound_refusal(slot) is not None, the same call api_chat_slot_continue makes, instead of re-spelling slot.executor == "remote". The button and the verb now read one predicate. The refusal code stays remote_target_unsupported, matching session_send and session_set_model. Folding the check into continue_slot_turn was not taken, because Continue has to keep answering its anti-enumeration 404 before the remote 409.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Item 9: directive_user_origin=False on a retried turn, undeclared (span=43f27df5dbfc)

Outcome: declared in the description; no code change.
The behaviour stays: an agent asked for the retry, not the person at the keyboard, so the resumed turn must not carry the authenticated-human flag a Resume press sets. The "What changed" section now says this in its own sentence, next to the send_origin_slot stamp that names which session asked.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in files this PR imports or sits beside (aec8141 -> 2b91a6b) since this head went green. The new head c32fb195f1 also carries the Design suggestion (the crew-bound refusal now calls remote_bound_refusal). CI is re-running. The two reds on the previous head were Build Windows Installer (x64) hitting its install-time ceiling and test_session_export::test_a_sent_export_streams_its_staged_file_and_removes_it in Backend Tests (3.12, 3), which passes locally. Coverage Gate and PR Readiness failed closed on that backend red.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 30, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

CI note on c32fb195f1: every review lane is clean (Design and First Principles PASS with no items, GPT and Opus with no findings). The two red shards are single-test failures in code this PR does not touch, and both are already listed in #15412:

  • Backend Tests (3.12, 3): test/test_session_export.py::test_a_sent_export_streams_its_staged_file_and_removes_it (assert not staged.exists() right after the client closes; it passes locally on this branch).
  • Backend Tests (Windows) (1): test/test_session_transfer.py::test_concurrent_expansions_are_bounded_and_the_excess_is_refused.

Coverage Gate and PR Readiness fail closed on the backend red. I'll push the same tree once in the next quarter-hour slot to re-run them; no code change.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 30, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in files this PR imports or sits beside (2b91a6b -> 1fda18a). The new head ae2be5d94b has no code change from c32fb195f1. It also re-runs the two shards that failed on the #15412 flakes. CI re-running.

@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
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 2, 2026
@iamwhatever
iamwhatever force-pushed the feat/mcp-session-retry branch from 7219353 to e25b408 Compare October 4, 2026 07:11
@iamwhatever

Copy link
Copy Markdown
Contributor

Rebased onto main (d8d052f -> efd0181) to clear the merge conflict in docs/architecture/mcp.md, docs/feature-map/README.md, src/kiro_crew/docs/index.md, test/test_pending_boundary_consumer_semantics.py. CI re-running.

@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 4, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased: 221fa6936f is on current main. It ports session_retry to the #17098 Tool(...) table, with the route in server_runtime/mcp_routes.py, and keeps main's replaced-slot check in Continue. Main added chat_folder_update, so the documented dashboard tool count is now 31. session_retry behaves the same as before. 680 targeted tests and docs-lint pass locally.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Fixed the SAST (Semgrep) finding kirocrew.test-autouse-shared-monkeypatch on test/test_session_control_retry.py in 9f1546eec8. The autouse _enabled fixture now patches session_control_enabled through _floor_monkeypatch instead of the shared monkeypatch, so a test calling monkeypatch.undo() can't lift it. Only that test file changed, and its 15 tests pass.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

First Principles item 5 (fail-open audit in continue_slot_turn): 616938dcfd adds test/test_chat_slot_continue.py::test_a_failing_audit_write_does_not_strand_the_queued_continue. It goes through POST /api/chat/slots/{slot}/continue, not session_retry, and makes the dashboard_continue audit write raise. On main it fails with assert 500 == 200. The recovery entry is already in the queue at that point and nothing dispatches it, so every later press is refused with slot_queue_pending. On this branch the turn dispatches. The try/except stays because session_retry is built on the same path and would strand the same entry. The PR description's test list now names this test.

The same head also re-pins test_dashboard_server_composition_contract.py, which main added since the last rebase. The POST /api/session-control/retry route makes the MCP route table 233 rows with a new digest, and its _deferred handler adds one _deferred to both boot traces. All 109 tests in that file pass. The other reds on 9f1546eec8 were test_subagent_continuable (Windows 1) and test_dashboard_reset_sessions (Windows 3). This PR doesn't touch either file, and both pass locally. The source code is unchanged from 9f1546eec8.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Design review watch item ("the stated user is never granted the tool"): 446338dc3a adds session_retry to _MEMBER_DASHBOARD_GRANTS in agent.py, next to session_send and session_stop. A crew member's unattended patrol can now restart a worker whose turn timed out without stopping at an approval prompt. The grant is bounded the same way as the member's other write verbs. retry_target runs authorize_target, whose created_by fence limits a member to worker sessions it opened. It sends no new text, and it refuses any turn that finished or was stopped. Conductors still get an approval prompt, because they have no ownership fence. The WITHHELD list above _CONDUCTOR_DASHBOARD_GRANTS now gives that reason, and test_no_conductor_is_granted_a_fleet_write_or_a_model_switch now covers session_retry. Moving the conductor skills from session_send to session_retry is left for a follow-up PR, so this one stays scoped to the verb.

The same push rebases onto main at acc08092d7 with no other code change. That clears the SAST (Semgrep) red. The flagged time.sleep(0.2) at lines 637 and 669 of test_pr_watchers.py came from main's #16860, which landed after this branch's previous base, so the diff scan counted it as new here. The push also re-runs the three bookkeeping checks that failed on CI infrastructure. 838 targeted tests and docs-lint pass.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main to clear the conflict with #17662, which retired the remote turn relay and deleted remote_relay.py.

The one conflict was the import block in src/kiro_crew/dashboard/session_control.py. With remote_bound_refusal gone, retry_target now refuses with the same is_relay_archive check that main's Continue endpoint and session_set_model use. An old relay chat is refused with relay_archive_read_only instead of remote_target_unsupported, and the session-control.md doc, the retry test and the PR description say so. The rest of session_retry is unchanged.

1009 targeted tests pass locally (session control, retry, Continue, relay archive, composition contract, agent grants), along with flake8, black and docs-lint.

Before pushing I rebased once more onto current main, which had picked up two doc conflicts. In docs/feature-map/README.md main added the session close endpoint and the tag-column tools to the Session control row, and in docs/system-specs/modules/session-control.md it spelled out the conductor grant set. I kept main's text in both and re-added only session_retry's clause and endpoint. The merge also brought back a remote_target_unsupported row in the refusal table of src/kiro_crew/docs/session-control.md, which test_session_control_doc.py caught, so I removed it. No code changed in that second rebase.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main with no behaviour change. Main had moved 19 commits and changed two pinned contracts that this PR also pins: the member dashboard grant tuple in test/test_agent_refactor_contracts.py and the MCP route table, boot sequences and digest in test/test_dashboard_server_composition_contract.py. I took main's values and re-applied only this PR's delta: session_retry in _MEMBER_DASHBOARD_GRANTS, one more route row (242 to 243) and one more _deferred in each boot sequence for POST /api/session-control/retry. The 237 targeted tests (retry, Continue, session-control docs, agent contracts, composition contract) pass.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

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

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

The red Integration (in-process gateway) check on ad6d16cf84 is test/integration/test_owner_only_boot.py::test_a_fresh_boot_leaves_nothing_readable_by_others. It found six group/world-readable paths in the fresh home: autonudge.json, three files under crew-log/members/default-*/, crew-log/members and inbound-spool. This PR doesn't write any of them.

The same test failed with the same six paths on feat/ask-question-blocking-answers (run 37725254724, 03:58Z), a PR unrelated to this one. On this branch it passes 6 of 6 runs locally with KIROCREW_INTEGRATION=1, and main's CI at 65e13d6b24 passed the job. It looks like an intermittent failure in the #17629 permissions test rather than something this PR causes, so I'm not pushing a change for it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main with no behaviour change. Main's change to the Work ledger row in docs/feature-map/README.md conflicted with this PR's Session control row next to it. I took main's text for both rows and added back only this PR's retry clause and the .../retry endpoint; the range-diff shows the PR's own delta is unchanged. The 237 targeted tests, the feature-map gate and docs-lint pass.

The push also re-runs the two reds on ad6d16cf84, neither caused by this PR. Integration (in-process gateway) failed in test_owner_only_boot the same way as on the unrelated feat/ask-question-blocking-answers run. E2E (stub ACP backend, offline) tripped its zero-retry ceiling because two specs passed only on retry, and this PR changes no frontend files.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main with no code change; the range-diff shows the patch is identical. This clears the SAST (Semgrep) red on 166e105ebb, which flagged time.sleep(0.05) at test/test_favorite_projects.py:121 (rule test-sleep-as-barrier). This PR doesn't touch that file. It came in with main's #16611 after this branch's previous base, and the diff-only scan reports findings that are new since the merge base, so main's line counted as new here. The targeted session-control, Continue, agent-contract and composition-contract tests pass.

@iamwhatever

Copy link
Copy Markdown
Contributor

This adds a session_retry MCP tool so an agent can restart a session it created whose last turn failed, through the same Continue logic as the dashboard's Resume button, instead of re-sending the prompt. The design is sound. Continue's body moves into a shared continue_slot_turn. The verb requires is_turn_interrupted (turn_not_failed otherwise), re-runs authorize_target under the slot lock just before the queue insert, and queues with directive_user_origin=False so an agent's retry never carries the authenticated-human flag. I checked the authorization path. A channel agent is blocked via CHANNEL_AGENT_BLOCKED_TOOLS, relay archives are refused, and members are fenced by created_by. The only behaviour change to the existing Continue endpoint is that an audit failure now logs and still dispatches instead of a 500 with a stranded entry. I am holding because this is a new agent-facing capability that changes permissions: session_retry joins _MEMBER_DASHBOARD_GRANTS, so a crew member can call it without an approval prompt. Fail-open audit on the Continue endpoint is also a maintainer call. Checks are green and every lane passes. — crew-pr-reviewer

…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.
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main with no behaviour change; the range-diff shows this PR's own delta is unchanged. This head replaces ba12f95b16 after two rebases that conflicted in four files between them.

test/test_slot_running_readers.py conflicted at about 19:20Z: main replaced api_chat_slot_agent with switch_slot_agent next to the api_chat_slot_continue entry this PR removes. I kept main's lines and removed only api_chat_slot_continue, whose reader now lives in continue_slot_turn.

The other three conflicts came from main's reasoning-effort change to session_set_model, which sits next to this PR's session_retry lines. In docs/feature-map/README.md and docs/system-specs/modules/session-control.md I took main's set-model text and added back only the retry clause, the .../retry endpoint and the session_retry table row. In src/kiro_crew/validation.py I kept main's _validate_session_set_model and added back SESSION_RETRY_SCHEMA above it.

5,499 tests pass locally across the session-control, Continue, validation, MCP dashboard, agent-contract and composition-contract files.

@buluoray buluoray 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.

Approving, which also answers the hold for a maintainer call on the permission grant. session_retry reuses Resume's own path through continue_slot_turn, so every Continue refusal still applies, and it adds its one refusal of its own: turn_not_failed.

Checked against this head:

  • Removing the require_interrupted check reddens test_a_turn_that_succeeded_is_refused and test_a_turn_the_user_stopped_is_refused. Removing the before_dispatch() re-check reddens test_a_target_linked_while_the_lock_was_awaited_is_refused.
  • The Continue endpoint keeps its codes and bodies, including slot_subagents_running. The only behaviour change is the best-effort audit, which fixes the stuck-queue-entry case.
  • The member grant sits under the same created_by fence as session_send/session_stop and does less than session_send, so no approval prompt is fine. Conductors stay withheld.

Follow-up, non-blocking: Design's note about confirming _is_interrupted covers every failure tail a patrol loop sees (backend error mid-turn, gateway restart) is worth a test case later.

#16434 duplicates this PR and is closed in favour of this one; #15459 stacks on it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

todo (non-blocking): add the _is_interrupted failure-tail test in a follow-up PR

Thanks for the review. I'll leave this head as it is so the approval and readiness stay intact. After this merges I'll open a follow-up PR with test cases showing that session_retry accepts the two failure tails a patrol loop sees: a backend error mid-turn and a gateway restart during the turn. If either one isn't recognised as interrupted, that PR fixes _is_interrupted too.

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session_retry: let an agent re-run a session's failed turn the way Resume does

4 participants