Repository navigation
Description
Summary
Playbooks provide live, ordered prompts and visible progress. Agents retain lifecycle and execution control.
This issue records the agreed Agent-led Playbooks v1 design and implementation acceptance criteria. The current phase prepares the isolated workspace and records this design; it does not implement the feature.
Workspace and tracking
- Create branch
codex/agent-led-playbooksin/Users/bastian.huppertz/Projects/j5code-worktrees/agent-led-playbooksfrom freshly fetchedorigin/j5/main. - Install dependencies with
vp iand run the existing dependency-cache warmup,node apps/web/scripts/warm-dep-cache.ts. - Preserve the existing PR stack, branch tips, and uncommitted changes.
- Verify the new checkout's base and cleanliness and confirm that existing branch tips and working changes remain unchanged.
- This phase delivers the prepared workspace and this issue, without feature implementation. Commits, pushes, PR changes, dev servers, and browser sessions remain outside this setup phase.
Related: #170 — feat(agents): run Playbooks inside a Crew. Its current design assumes the older deterministic playbook engine and both the Crew and Playbook stacks merging. This issue establishes the agent-led v1 model independently; shared progression and captain authority remain future integration work.
Ownership and live definitions
- Give every run its own
runId, withownerThreadIdtaken fromMcpInvocationContext.threadId. - Enforce one active run per owner thread. Retain separate records for sequential runs.
- Store the definition path, current step ID, and run status. Read YAML live; do not snapshot definitions.
- Definitions live in the thread's workspace under
.j5/playbooks/*.yaml, with a title, description, and ordered steps containing stable IDs, titles, and prompts. - Agents author and refine YAML through ordinary file tools. No editor UI.
- Resolve progress by step ID, so edits and reordering preserve the current step. Movement follows the latest file order.
- If the current ID disappears, return an actionable error and available step IDs. Provide explicit step reselection for recovery.
- Missing files or invalid YAML leave progress unchanged; cancellation remains available.
- Completion and cancellation leave the agent usable. Provider restart or context compaction does not end the playbook.
Squadron management, joining, and the A2A ledger already exist on main. Defer only shared playbook progression and captain authority. Independent run identity lets that later work change ownership policy without replacing the run model.
Tools and user experience
- Extend the existing
J5Toolkit; introduce no MCP server. - Provide discovery, start, current-step retrieval, next, back, recovery reselection, complete, and cancel operations.
- Make advancement explicit:
next(runId, expectedStepId). Atomically reject a mismatched current step; apply the same guard to back and completion. - Retain the existing
client_request_idconvention for mutation retries. This also prevents replay after back navigation returns to an earlier step ID. - Current-step and movement responses return the live prompt, playbook purpose, and progress.
- Append retrieval guidance through the existing
T3_CODE_ORCHESTRATION_INSTRUCTIONSmechanism, including re-fetching after context loss. - Implement
/playbook <name>as an ordinary built-in composer text expansion toStart playbook <name>. The agent then invokes MCP. Add no command-item category or server slash-command handler. - Show title, current step, position, and terminal status in the thread across web, desktop, and mobile, using shared contracts and environment-scoped access.
- Keep back navigation as a convenience.
Scope boundaries
Exclude executable code steps, transition graphs, scheduling, and agent spawning. No migration of old definitions or runs is included.
Setup acceptance criteria
- The isolated branch and worktree exist at freshly fetched
origin/j5/main. - Dependencies are installed and the existing dependency-cache warmup succeeds.
- The new checkout is clean, and existing branch tips and working changes remain unchanged.
- This dedicated issue records the design and acceptance criteria and links feat(agents): run Playbooks inside a Crew #170 as related work.
Implementation acceptance criteria
These scenarios are for the subsequent feature implementation and are not claimed by the setup phase.
- One agent completes A and starts B with separate run records; one active run per owner thread is enforced. Cancelling a run leaves the agent usable.
- Editing the current prompt is reflected on the next retrieval.
- Reordering preserves the current step ID and movement follows the latest order; deleting the current ID returns an actionable error and available step IDs and requires explicit recovery reselection.
- Invalid YAML or missing files preserve state and allow cancellation.
- Concurrent advancement and retried requests cannot double-advance, including after back navigation. Next, back, and completion atomically reject mismatched expected step IDs; mutation retries retain the
client_request_idconvention. - Context compaction and provider restart preserve retrievable progress, with orchestration guidance directing the agent to re-fetch it.
- Non-owner threads cannot mutate a run.
- Discovery, start, current-step retrieval, next, back, recovery reselection, complete, and cancel are available through the existing
J5Toolkit; current-step and movement responses include the live prompt, purpose, and progress. - Slash expansion reaches the ordinary agent-message path. Connected web, desktop, and mobile clients show consistent title, current step, position, and terminal status with environment-scoped access.
Verified setup result
Prepared from freshly fetched origin/j5/main at 42a17bfdc3f22c45247295695b9d94c4f62783e8.
codex/agent-led-playbookspoints to that exact commit; the new checkout is clean.vp icompleted successfully.node apps/web/scripts/warm-dep-cache.tscompleted successfully and populated the web dependency cache.- Before/after verification found no changes to the 60 pre-existing local branch tips or the heads, branches, staged/unstaged diffs, status, and modified/untracked file contents across all 39 existing worktrees.
- No feature code, commits, pushes, PR changes, dev servers, or browser sessions were created in this phase.
Activity
bryantderosier commentedon Dec 1, 2026
All four parts merged: #248, #249, #250 and #251. The
j5_playbook_*tools are in (list, start, current, next, back, reselect, complete, cancel),/playbookworks in the composer on web and mobile, and the mobile boards came with #251. The follow-on work is tracked under Playbooks v2 (#787–#795). Closing.