Skip to content

Playbooks: cancelling stops the step holder, and archiving a Crew keeps the run #789

Open

Description

@bryantderosier

Item 4 of 9 in the Playbooks v2: one owner, flexible staffing milestone. It needs #788.

The problem

Once steps can be handed to other agents (#788), cancelling a run has to stop whoever is doing the current step. Today it just flips the run's status, and the holder keeps working on a step nobody needs anymore. Archive behaves backwards, too. Archiving a Crew cancels the run, even though the owner could carry on without it. Archiving my own conversation leaves the run active, even though that's the run's owner going away.

Where this sits

This is section 9 of the Playbooks proposal (26 October), "Interruption, cancellation, and archive":

  • Cancel runs upstream's Stop (thread.stop) on the holder's thread when the holder isn't the owner. That's the same path Stop crew uses.
  • The owner's own turn is never interrupted, because it's the turn doing the cancelling and it still has to reply.
  • If Stop can't interrupt the holder, the cancel still succeeds, and the owner says the worker didn't stop. There's no retry.
  • Archiving or deleting the owner's thread cancels its run. Archiving a Crew doesn't.

What we already have

  • Cancel. mcp.ts:121-127,229-231; its description says it "does not interrupt or archive your agent". The relay handles cancel outside the Crew lock and returns delivery: null (PlaybookCrewRelay.ts:318-319), and the store sets the status (PlaybookStore.ts:691). The response has nowhere to say the worker didn't stop (playbook.ts:131).
  • Crew archive cancels the run. cancelForCrew is at PlaybookStore.ts:859-885, and its only caller is ArchiveCrewService.ts:378-380, used at :386 and :466. It's pinned by PlaybookCrewRelay.test.ts:633 and ArchiveCrewService.test.ts:151,252,274.
  • Captain archive goes from CrewCaptainArchiveCascade.ts:251-259 to retire (:87-102), then ArchiveCrewService.archive, then cancelForCrew. Removing cancelForCrew drops this path, so owner archive needs its own hook. The cascade's event handler plus boot sweep (:26-37) is the pattern to follow.
  • Owner archive doesn't cancel today. cancelOrphans (PlaybookStore.ts:223-233) only checks deleted_at, and only lazily, on reads, start, movement, and delete. That's pinned by PlaybookStore.test.ts:899 ("…while archived owners remain active").
  • Stopping a thread. stopThread (apps/server/src/j5/a2a/stopThread.ts:13-32) dispatches thread.stop, then stopDelegatedTasks, with an optional DispatchModeLimit.
    • CrewStopService.ts:167-176 calls it and wraps failures as CrewStopOperationError{phase:"stopping a seat"}.
    • Results are already_idle or interrupt_requested, read through latestActiveRun (:178-182), and archived seats are skipped (:159-164).
  • j5_stop_agent (handlers.ts:834-921) uses a deterministic lifecycleCommandId (:906-911) and applies mode limits unless the caller is the Captain (:893-903).
  • What J5 calls. J5 goes through ThreadManagementService.dispatch (:323, :672) and stopDelegatedTasks (:423, :1093), never the Orchestrator directly. The relay already depends on ThreadManagementService (PlaybookCrewRelay.ts:92).
  • Who holds the step. latestLanding (PlaybookStore.ts:813-821) plus deliveryOf (PlaybookCrewRelay.ts:67-77) until Playbooks: the owner hands each step to someone #788 changes it.

Acceptance criteria

  • Cancelling a run ends it first. Then, when the current step's holder isn't the owner, the platform runs stopThread on the holder's thread with a deterministic command id. It uses the same mode limits j5_stop_agent would apply for this owner.
  • The owner's own turn is never interrupted by cancelling, including when the owner holds the step.
  • The cancel result says what happened to the holder: no holder or held by the owner, stop requested, already idle, or couldn't stop, with the reason. If Stop fails, the cancel still succeeds, and there's no retry.
  • Completed work, artifacts, the conversation, the Crew, and workspaces remain after a cancel.
  • Archiving or deleting the owner's thread cancels its active run right away, with a cancel reason, including when the server was down at the time (a boot sweep). Unarchiving doesn't reopen it.
  • Archiving a Crew no longer cancels the owner's run. cancelForCrew is gone. If a member of that Crew held the current step, j5_playbook_current says the holder is archived, and the owner reassigns the step or takes it back (Playbooks: the owner hands each step to someone #788).
  • Archiving a Captain cancels its run because it's the owner's thread, not because of the Crew.
  • "Continue" after an interruption recovers the run, its current step, its holder, and its copy, and repeats no completed work.
  • The j5_playbook_cancel description no longer says it never interrupts anyone. It says it stops the current holder but not the caller.
  • Focused tests cover:
    • cancel with an owner-held step, where nothing is stopped;
    • cancel with a member-held step, where Stop is issued once, also on retry;
    • cancel when Stop fails;
    • owner archive and owner delete cancelling;
    • the boot sweep;
    • Crew archive leaving the run active.
  • docs/j5/product/features/playbooks.md AC11 and AC12, and the matching lines in crews.md, are rewritten.

Surfaces

Codex, Claude, and Cursor as the holder being stopped. Turn interruption is part of every adapter's contract, so no per-provider work is expected, but each should be checked once.

Out of scope

Activity

  1. added
    enhancement
    on Oct 29, 2026
  2. changed the title [-]Playbooks: the owner hands each step to someone[/-] [+]Playbooks: cancelling stops the step holder, and archiving a Crew keeps the run[/+] on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions