Repository navigation
Description
Item 3 of 9 in the Playbooks v2: one owner, flexible staffing milestone. It needs #795, and it's the biggest one.
The problem
Today a playbook decides staffing up front. When a Captain builds a Crew from a playbook, it proposes one seat per persona the steps name, adds a stand-in for any persona that's missing, and fixes each step to the seat that owns it when the roster is proposed. A run without a Crew gets no delivery at all, so the owner does every step itself. That's backwards. The agent following the playbook knows better than the YAML who should take a step, and a playbook shouldn't need a Crew to hand work out.
Where this sits
This is section 1 ("One owner, staffing chosen at runtime"), section 2 ("The owner hands each step to someone"), and the "no separate announcements" part of section 8 of the Playbooks proposal (26 October).
- The owner of a run is the agent in my conversation. When there's a Crew, the owner is its Captain.
- When it moves to a step, it can name who takes it, and the platform delivers that step's instructions fresh. A step with no one named stays with the owner.
- The required-persona check on a handoff is Playbooks: a step's persona is required #792, and cancelling the holder is Playbooks: cancelling stops the step holder, and archiving a Crew keeps the run #789.
- Crews Crews: members start when there's work for them #745 starts a member's first turn on the first message or playbook step it gets. Whichever of the two lands second wires them together.
What we already have
- Tool inputs. The Movement, Reselection, and Start schemas are at
apps/server/src/j5/playbooks/mcp.ts:23-30, and only start takescrew_instance_id. The handlers are atmcp.ts:193-231. - Delivery records. Only a run started with a Crew gets them (
PlaybookStore.ts:611-613on start,:719-723on a move). A run without a Crew returns no delivery (PlaybookCrewRelay.ts:313-316). - The table.
j5_playbook_step_deliveryandj5_playbook_run.crew_instance_idare in029_CrewPlaybookRuns.ts:13-31. Rows are mapped atPlaybookStore.ts:94-136and read and written at:807-857. - Fixed ownership.
stepOwnerandresolveTargetare atPlaybookCrewRelay.ts:86-110. A step that no live seat owns falls back to the Captain silently, as does a seat whose thread is archived or rejected the delivery (:43-48,:159). - The handoff.
PlaybookCrewRelay.ts:118-201callsthreads.dispatch({type:"message.dispatch", createdBy:"system", dispatchMode:start_immediately})with fixed command and message ids (:50-64,:160-181).- Its states map to
delivered,captain, andpendingat:67-77, and the contract ispackages/contracts/src/j5/playbook.ts:105-114,132. - A pending handoff is only retried on the owner's next call (
drainLocked,:207-216).
- Its states map to
- The step notice.
crewStepNotice.ts:14-37wraps the prompt in a<j5_playbook_step>header and a<step_prompt>block and ends with "report back to your Captain". - The lock. The relay serializes on
crews.serialize(crewInstanceId)(:218-219), so a run without a Crew needs its own lock. - Retry keys.
encodeRequest(PlaybookStore.ts:577-581,:655-660) has no assignee, so today a retry with a different assignee wouldn't conflict. - Ownership checks. The owner check is
readRun'snot_owner(PlaybookStore.ts:251-255). Starting with a Crew requires the caller to be its Captain and the Crew to follow the same playbook (PlaybookCrewRelay.ts:285-295). - The roster derived from step personas:
apps/server/src/j5/a2a/crewPlaybookPlan.ts:53-110, used atCrewProposalService.ts:188-209,688j5_propose_crew's description and playbook parameters (a2a/mcp/tools.ts:384-394,:454-470,:563), andj5_request_crew_member's steps (:566)- its handler (
a2a/mcp/handlers.ts:731-752) - the per-seat
playbook_step_ids(028_CrewPlaybooks.ts), read and written atAgentCrewInstanceService.ts:24,208-225,238,298-309and set atCrewLaunchService.ts:799,840
- Crew text about playbooks:
- the launch report tells the Captain to start the playbook (
crewGateNotice.ts:180-182,203-206) - a seat's first turn carries a
<seat_playbook>block saying "wait for that hand-off" (spawnIds.ts:137-148, fed fromCrewLaunchService.ts:656-662) - the relay itself posts nothing to the owner's thread (
PlaybookCrewRelay.ts:153-155)
- the launch report tells the Captain to start the playbook (
- How participants are identified:
- Crew members are
AgentCrewMember {seatName, participantId, threadId}(AgentCrewInstanceService.ts:14-25). The Captain iscaptainThreadIdandcaptainParticipantId(:45-46). - Peer Agents have participant ids, resolved through
A2ASendService.listParticipants, asj5_stop_agentdoes (handlers.ts:834-868). delegate_taskchildren have only ataskId, achildThreadId, and lineage withrelationshipToParent:"subagent".ThreadRegistration.ts:67keeps them out of A2A, so they have no participant id, can't usej5_send_message, andj5_stop_agentcan't reach them.
- Crew members are
- UI showing ownership:
- the Fleet header "Step N of M: title · holder" (
apps/web/src/j5/fleet/fleet.logic.ts:34-54, rendered atFleetPage.tsx:474-477) - seat step badges (
FleetPage.tsx:91-98,520,fleet.logic.ts:116-121) - the proposal card's seat steps and "Unowned steps, done by the Captain" (
CrewProposalCard.tsx:89-95,142-252,apps/web/src/j5/crew/crewPlaybookPlan.ts) - on the server,
fleetRun(PlaybookCrewRelay.ts:345-372) is read infleetRead.ts:244-246. Only live Crews get a run there, and the contract nests it underFleetCrew.playbookRun.seat(packages/contracts/src/j5.ts:342-362), so a run without a Crew never shows in Fleet.
- the Fleet header "Step N of M: title · holder" (
Proposal
j5_playbook_start,j5_playbook_next, andj5_playbook_backtake an optionalassignee, a participant id. Start no longer takescrew_instance_id.- The assignee is checked, and the holder recorded, in the same transaction as the move. A refusal leaves the run where it was.
- Delivery keeps today's
message.dispatchpath with stable ids. The step notice carries the prompt unchanged, plus a line naming the owner to report back to, instead of "your Captain". - The holder is chosen at runtime instead of looked up from seat ownership. Reuse the delivery table with a runtime target, or add a column; the PR decides.
- A run is serialized per run, whether or not it has a Crew.
- Everything that derives seats from step personas goes away.
Acceptance criteria
Handing off
-
j5_playbook_start,j5_playbook_next, andj5_playbook_backtake an optional assignee. - With an assignee, the platform delivers that step's prompt, unchanged, to the assignee as a fresh turn. Without one, the step stays with the owner, whose tool result carries the instructions as it does today.
- The owner can hand the current step to someone else, or take it back, without moving. This is how it recovers from a holder that's stuck or archived.
- An assignee the owner can't hand work to is refused with a clear error, and the run doesn't move. That covers a kind of participant that can't be named (see the open question below), a participant that isn't the owner's, and an archived one. Nothing falls back to the owner silently.
- The holder is recorded on the run and attributed to the owner who named it.
j5_playbook_currentreturns it. - The holder's notice says it holds the step, and who to report back to. Only the owner can move the run; the holder's movement calls are refused with
not_owner. - A retry with the same
client_request_idand the same assignee delivers once. The same id with a different assignee is arequest_conflict. - A handoff whose dispatch fails stays pending and is retried on the owner's next call, as today.
j5_playbook_currentshows it as pending. - Runs without a Crew can hand off steps. They're serialized per run.
No Crew required
- Starting a playbook doesn't take or need a Crew. The owner can start a Crew later, or hand steps to a Crew it already captains, without restarting the run.
- Playbooks no longer derive a roster from step personas or create stand-in seats:
crewPlaybookPlan.tsis removed;j5_propose_crewandj5_request_crew_memberlose their playbook step parameters;- the proposal card no longer shows seat steps or "Unowned steps";
- the launch report no longer tells the Captain to start a playbook;
- a seat's first turn has no
<seat_playbook>block.
- Fixed seat ownership in
j5_playbook_step_delivery, and the per-seat columns from 028, stop being read and written. Old proposals and Crews that have them still decode.
What I see
- Fleet shows who holds the current step for every run, including runs without a Crew.
- A handoff adds no launch, handoff, or completion announcements to the owner's chat. Worker activity stays in lineage.
Tests and docs
- Focused tests cover:
- delivery to a Crew member and to a Peer Agent;
- no assignee, which keeps the step with the owner;
- reassigning the current step without moving;
- each kind of refused assignee, with the run unmoved;
- a retry with the same assignee and with a different one;
- a handoff in a run without a Crew.
-
docs/j5/product/features/playbooks.mdis rewritten: the Definition's step-owner paragraphs, AC2, AC5, and the "A release Playbook" and "A Crew from a playbook" scenarios.crews.mdandagent-tools.mddrop the Crew-from-playbook wording. The shipped tool descriptions change with their quoted copies.
Surfaces
Agents through MCP and scheduled tasks; Fleet on web and desktop (Crews have no mobile surface); and Codex, Claude, and Cursor as both owner and holder.
Out of scope
- The required-persona check on a handoff (Playbooks: a step's persona is required #792).
- Stopping the holder on cancel (Playbooks: cancelling stops the step holder, and archiving a Crew keeps the run #789).
- The composer progress bar (Playbooks: progress shows the current step #791).
- The owner's guidance on choosing an arrangement (Playbooks: owner guidance for starting, working, and finishing #793).
Open question
Which participants can be named to take a step? I'd allow Crew members of a Crew the owner captains, and Peer Agents the owner spawned: anything with a participant id the owner can message and stop. I wouldn't allow delegate_task children. They have no participant id, can't message anyone, and j5_stop_agent can't reach them, so neither the report-back nor cancelling would work. The owner can still use delegate_task inside a step it holds. Provider-native subagents work under whoever holds the step. The AC above is written that way.
Activity
[-]Playbooks: revise an active run's procedure[/-][+]Playbooks: the owner hands each step to someone[/+]