feat: playbooks for the agent
Summary
One markdown playbook per workspace and type: "this is how we run stuff". People write them under Agents > Playbooks; the agent reads them when asked and before it drafts public text. Nothing is enforced.
| Type | Holds |
|---|---|
incident_response | severities, roles, steps, cadence, escalation |
status_page | tone, what to say and never say, public names |
maintenance_windows | what a window means, when to schedule, notice period |
postmortem | sections and what goes in each |
packages/db/src/schema/playbooks/ # table, types, {{name}} variable helpers
packages/services/src/playbook/ # savePlaybook, clearPlaybook, listPlaybooks, getPlaybook
packages/services/src/agent-tools/
├── playbook.ts # list_playbooks, get_playbook, update_playbook
└── playbook-hint.ts # one sentence on the tools that write public text
packages/api/src/router/playbook.ts # tRPC: list, get, save, clear
apps/dashboard/.../agents/playbooks # list + editor with Properties and Variables
How a playbook reaches the agent:
Slack / dashboard chat
loadPlaybookSection(ctx) # prompt names the filled types, no content
get_playbook({ type }) # content with variables filled in
MCP
server instructions + tool descriptions point at list_playbooks / get_playbook
generatePostmortemDraft
postmortem playbook filled -> its structure replaces the default sections
empty -> prompt identical to before
Writes:
dashboard save / clear (delete from the row menu, with confirm)
agent update_playbook (creates or replaces, approval card) ; no delete tool
variables {{name}} in the text, values in playbook.variables (flat JSON map)
saved on blur per value ; unset ones stay as {{name}} for the agent
Empty slots change nothing: no prompt section, default postmortem prompt.
Also in here: PropertyInput shows a tooltip with the full value when it is clipped, and QuickActions computes its visible items once.
Evidence
- Before: no
playbooktable, tools or tab.
After:pnpm verifygreen. Suites on an isolated libSQL:
packages/services 148 files, 1941 tests passed
apps/dashboard 50 files, 459 tests passed
packages/api 42 files, 518 tests passed
- Postmortem prompt:
postmortem-draft.test.tsasserts the system prompt equals the previous one without a playbook, and carries the playbook's sections plus the unchanged rules with one. - Variables round trip:
packages/api/src/router/playbook.test.tssaves a value, changes only the value, reads it back.
Not shown or not done:
apps/serversuite: green earlier on this branch; the last three full runs failed 4 to 7 tests, a different set each time, inslack/handler.test.tsand monitor/heartbeat RPC tests. Each file passes alone. The machine was under heavy load; needs one clean CI run.pnpm eval:mcp: not run. Two cases added;select.declare_incidentmay now picklist_playbooksfirst.- Real model check: no run against Slack, dashboard chat or MCP yet, so how often the agent reads before drafting is unmeasured.
- Screenshots: taken locally, not attached.
Merge Danger
Door: two-way
Two additive migrations (0099 creates playbook, 0100 adds variables). No existing table or column changes.
Blast Radius: agent
Ten write tools gain one sentence in their description, and both agent prompts gain a line listing the playbook tools, for every workspace. With a filled slot the prompt also gains a short section. Tool selection can shift: a model may call list_playbooks before drafting. update_playbook lets the agent rewrite the rules it follows, behind the same approval card as other writes.