Tutorial 3 — Incident Response
What you'll learn
- How the advanced template composes a multi-agent flow (sources → agents → prompt node → retrievers → agent → transformers → exposure), wired entirely through a workflow file under
workflows/, not agent frontmatter - A workflow chain: researcher → responder →
investigate_incident(prompt node) → supervisor, where the supervisor emits structured JSON - Fan-in edges: the
investigate_incidentprompt node has three immediate predecessors (responder,slack_thread,linked_jira) and folds all of their output intosupervisor's turn - Live sources: Slack thread (required) + linked Jira issue (optional), wired as workflow source nodes
- Retrievers (on
supervisor) with prompt transforms (Jira search, Confluence search) - Transformer chain:
json_extract→pii_redact→llm_rewrite→assert - An exposure sink node that posts the final message back to the Slack thread
- Production guardrails: token budgets, timeouts,
abt doctor --deep - CI integration: compile + test + doctor in one step
Time: ~20 minutes. You can compile, render the workflow graph and dry-run the tests without any Slack, Atlassian or Anthropic credentials.
1. Create the project
mkdir incident-bot && cd incident-bot
abt init --template advanced
Edit profiles.yaml — it already has stubs for Slack and Atlassian credentials:
# profiles.yaml (gitignored)
incident-bot:
target: dev
outputs:
dev:
model_id: anthropic:claude-haiku-5-5
max_tokens: 4096
credentials:
anthropic:
api_key: "{{ env_var('ANTHROPIC_API_KEY') }}"
slack:
bot_token: "{{ env_var('SLACK_BOT_TOKEN') }}"
atlassian:
url: "https://your-org.atlassian.net"
username: "your@email.com"
api_token: "{{ env_var('ATLASSIAN_API_TOKEN') }}"
Credentials and secrets
profiles.yaml is in .gitignore. The env_var(...) calls are resolved from environment variables at runtime — export SLACK_BOT_TOKEN and ATLASSIAN_API_TOKEN in your shell (or CI secrets), never hardcode them.
2. Understand the full execution
Order and branching live in one place: a workflow file under workflows/. Sources, prompts, and exposures are workflow nodes in that same file — never agent frontmatter fields. Retrievers and transformers stay on the individual agents that need them.
# workflows/incident_response.yaml
description: Investigate, draft a response, then synthesize the final incident JSON.
edges:
- [START, slack_thread]
- [START, linked_jira]
- [START, researcher]
- [researcher, responder]
- [responder, investigate_incident]
- [slack_thread, investigate_incident]
- [linked_jira, investigate_incident]
- [investigate_incident, supervisor]
- [supervisor, slack_reply]
- [slack_reply, END]
slack_thread/linked_jira are source nodes (from sources/) that fetch in parallel with the researcher → responder agent chain. investigate_incident is a prompt node (stem of prompts/investigate_incident.md) with three immediate predecessors — responder, slack_thread, linked_jira — so it only composes once all three finish; that composed turn is what supervisor sees.
flowchart TB
subgraph src_block [Source nodes]
SlackIn["slack_thread"]
JiraIn["linked_jira (optional)"]
end
subgraph agent_block ["Agent chain"]
direction LR
Researcher["researcher"] --> Responder["responder"]
end
subgraph workflow_block ["workflows/incident_response.yaml"]
direction TB
Prompt["investigate_incident<br/>(prompt node)"] --> RetrieverBlock["retrievers on supervisor<br/>(jira_tickets, confluence_docs)"] --> Supervisor["supervisor<br/>(structured JSON)"]
end
subgraph tx_block [Transformers, on supervisor]
direction LR
JsonExt["json_extract"] --> PiiRed["pii_redact"] --> SlackFmt["llm_rewrite<br/>(slack_format)"] --> Asser["assert"]
end
subgraph out_block [Exposure sink node]
SlackOut["slack_reply"]
end
src_block --> Prompt
agent_block --> Prompt
workflow_block --> tx_block --> out_block
| Node | Kind | Behaviour |
|---|---|---|
slack_thread / linked_jira |
source | Fetch Slack thread text / an optional linked Jira issue before investigate_incident composes. |
researcher |
agent | Reads the user message. Outputs a plain-text list of hypotheses and evidence. |
responder |
agent | Sees researcher's output (immediate predecessor). Drafts a short, customer-facing Slack message. |
investigate_incident |
prompt | Composes the turn from responder, slack_thread, and linked_jira — its three immediate predecessors. |
supervisor |
agent | Sees the composed prompt, runs its own retrievers: (Jira + Confluence search), and emits JSON matching IncidentResponse. Owns transformers:. |
slack_reply |
exposure | Sink node — dispatched once supervisor's own turn succeeds. |
The workflow — not agent frontmatter — is what makes this deterministic: every predecessor of a node always finishes before that node runs, because the edges say so.
3. Tour the generated files
The three agents
agents/researcher.md (plain-text hypotheses, no I/O fields of its own):
---
description: >
Investigates symptoms and correlates Slack thread text with retrieved Jira and Confluence context.
tools: []
middleware:
- run_timeout:
graceful_timeout_seconds: 240
- model_call_limit:
max_model_calls: 12
- token_budget:
max_total_tokens: 120000
tags:
- incident
- research
---
You are the researcher. Read the user message and any retrieved context in the prompt.
Reply with a concise bullet list of hypotheses and evidence (plain text, not JSON).
agents/responder.md (drafts the Slack reply):
---
description: >
Drafts the customer-facing incident message. workflows/incident_response.yaml runs this after `researcher` and
before `supervisor` — this agent has no dependency fields of its own.
tools: []
middleware:
- run_timeout:
graceful_timeout_seconds: 180
- model_call_limit:
max_model_calls: 8
- token_budget:
max_total_tokens: 80000
tags:
- incident
- response
---
Research context (from `researcher`, which workflows/incident_response.yaml runs immediately before this agent).
You are the responder. Produce a short draft reply suitable for Slack (plain text).
Neither agent declares order — that lives entirely in workflows/incident_response.yaml's [researcher, responder] edge. At runtime, researcher's output is folded into the responder's own thread context before the responder runs, so the responder can build on it without a Jinja call.
agents/supervisor.md (owns the retrievers/transformers, structured output):
---
description: >
Incident head: runs last in workflows/incident_response.yaml's workflow, after the `investigate_incident`
prompt node folds in `researcher`, `responder`, and the `slack_thread`/`linked_jira` source nodes — see
workflows/incident_response.yaml for the run order, not this file. Uses severity_classifier; sees every
predecessor's output (topology, not a config setting). Its own output then dispatches through the
`slack_reply` exposure sink node (also declared in that workflow, not on this agent).
tools:
- severity_classifier
output_schema: incident_response.IncidentResponse
retrievers:
- jira_tickets
- confluence_docs
transformers:
- to_canonical_json
- redact_pii
- format_slack
- verify_response
middleware:
- run_timeout:
graceful_timeout_seconds: 480
- model_call_limit:
max_model_calls: 20
- token_budget:
max_total_tokens: 180000
tags:
- incident
- supervisor
---
{{ context.local('incident/playbook') }}
Upstream chain (see workflows/incident_response.yaml): `researcher` then `responder` run before the
`investigate_incident` prompt node, which composes this agent's turn — their output is folded into
this agent's context automatically.
You are the supervisor. Synthesize upstream work into **JSON only** matching your output_schema
(severity, summary, action_items, references). Use severity_classifier once if the user message
is ambiguous about severity.
Key frontmatter fields:
- The three agents declare their own description, tools, and retrievers or transformers. Order, sources, prompts, and the exposure sink live in
workflows/incident_response.yaml(see above). retrievers: [jira_tickets, confluence_docs](onsupervisor) — searched afterinvestigate_incidentcomposes the turn, using the composed task as the query.transformers: [...](onsupervisor) — run on the supervisor's own text after it finishes, in list order.output_schema: incident_response.IncidentResponsebinds the final text to a Pydantic model undercontracts/—abtvalidates the JSON after the model returns, and theto_canonical_jsontransformer normalizes it downstream.tools: [severity_classifier]exposes a local Python tool (seetools/severity_classifier.py).
The structured output contract
contracts/incident_response.py:
from __future__ import annotations
from pydantic import BaseModel
class IncidentResponse(BaseModel):
severity: str
summary: str
action_items: list[str]
references: list[str]
Any agent can point at this model with output_schema: <module>.<ClassName>; abt resolves the dotted path against paths.contracts and validates the final message at runtime.
The prompt node
prompts/investigate_incident.md — a workflow node (not a field on any agent), referenced by name from workflows/incident_response.yaml's edges:
# Incident investigation
Slack thread (from source fetch):
{{ upstream('slack_thread') }}
## Linked Jira issue (optional)
When ``issue_key`` is set (``--vars 'issue_key: PROJ-123'``), the ``linked_jira`` source fetches it;
otherwise this section is empty.
{{ upstream('linked_jira') }}
User instruction: summarize impact, likely cause, and next steps. Jira search and Confluence search
results are appended below by the retrievers after this message is composed.
{{ upstream('name') }} pulls a predecessor node's output by name — here, the two source nodes that are immediate predecessors of investigate_incident. The second one has freshness.on_missing_vars: warn so the workflow still runs when issue_key is not provided — the section will be empty.
Sources and the exposure
sources/slack_thread.yaml (required):
name: slack_thread
type: slack_thread
description: Fetch the Slack thread that triggered this incident run
credentials: slack
tags: [incident, slack]
config:
channel_id: "{{ var('channel_id') }}"
thread_ts: "{{ var('thread_ts') }}"
max_messages: 50
freshness:
on_missing_vars: error
on_missing_credentials: error
sources/linked_jira.yaml (optional, on_missing_vars: warn):
name: linked_jira
type: jira_issue
description: Optional primary ticket tied to the thread (skip when issue_key is empty)
credentials: atlassian
tags: [incident, jira]
config:
issue_key: "{{ var('issue_key', '') }}"
include_comments: true
max_comments: 15
freshness:
on_missing_vars: warn
on_missing_credentials: warn
exposures/slack_reply.yaml (the sink node dispatched once supervisor's own turn succeeds):
name: slack_reply
description: Post the investigation summary back to the Slack thread
type: slack
credentials: slack
tags: [incident, slack]
config:
channel_id: "{{ var('channel_id') }}"
thread_ts: "{{ var('thread_ts', '') }}"
freshness:
on_missing_vars: error
on_missing_credentials: error
The retrievers
retrievers/jira_tickets.yaml and retrievers/confluence_docs.yaml both use prompt_transform: [llm_rewrite, multi_query] to compress the composed task into keywords, then generate variants for broader recall:
name: jira_tickets
description: Search Jira for tickets related to the incident (optionally scoped by project keys).
type: jira_search
credentials: atlassian
query: "{{ task() }}"
prompt_transform: [llm_rewrite, multi_query]
prompt_transform_config:
num_variants: 2
include_original: false
config:
max_results: 10
projects: "{{ var('jira_projects', '') }}"
name: confluence_docs
description: Search Confluence for docs related to the incident (optionally scoped by space keys).
type: confluence_search
credentials: atlassian
query: "{{ task() }}"
prompt_transform: [llm_rewrite, multi_query]
prompt_transform_config:
num_variants: 2
include_original: false
config:
max_results: 8
spaces: "{{ var('confluence_spaces', '') }}"
include_body: true
The transformer chain
Referenced from agents/supervisor.md's own transformers: list, executed in that order:
# transformers/to_canonical_json.yaml
name: to_canonical_json
description: Extract canonical JSON from the supervisor's output.
type: json_extract
# transformers/redact_pii.yaml
name: redact_pii
description: Redact emails, IPs, and phone numbers before formatting for Slack.
type: pii_redact
config:
types: [email, ip, phone]
strategy: redact
# transformers/format_slack.yaml
name: format_slack
description: Rewrite canonical JSON into Slack mrkdwn using the slack_format prompt.
type: llm_rewrite
prompt: slack_format
# transformers/verify_response.yaml
name: verify_response
description: Sanity check — warns (does not block) if the formatted reply drops the severity field.
type: assert
config:
checks:
contains: [severity]
on_fail: warn
json_extract runs first so the rest of the chain sees canonical JSON; then PII redaction on the JSON string; then an LLM rewrite into Slack mrkdwn using prompts/slack_format.md; finally an assert check that warns (does not fail) if the word severity is missing.
4. Run the workflow
Inspect the plan (no credentials needed)
abt graph incident_response
abt graph renders the resolved topology — workflow order, source nodes, the prompt node, and the exposure — without calling any LLM or external APIs, and without any environment variables set. It prints the flow as a tree (↓ points to a node with several parents, drawn once below), and does not label node kinds:
incident_response
Investigate, draft a response, then synthesize the final incident JSON.
slack_thread → ↓ investigate_incident
linked_jira → ↓ investigate_incident
researcher → responder → ↓ investigate_incident
investigate_incident → supervisor → slack_reply → END
Inspect a workflow's topology with abt graph <workflow>; it runs nothing.
abt compile needs none of the tokens in profiles.yaml; it resolves credentials: only for agents that use them:
abt compile
Compiled 3 agent(s).
Manifest written to: /path/to/incident-bot/target/manifest.json
Compiled 5 file(s) to: /path/to/incident-bot/target/compiled/incident-bot (agents: 3, prompts: 2)
Real run
The abt dispatch commands in this section call the model, so they need a real ANTHROPIC_API_KEY. The real run below also needs a real Slack bot token, ATLASSIAN_API_TOKEN and an existing Slack thread to read and reply to. None of this is part of the no-credentials path above.
abt dispatch -s incident_response \
--vars '{channel_id: C01234567, thread_ts: "1234567890.123456"}'
abt dispatch -s incident_response runs the whole workflow: researcher runs first, then responder, then the investigate_incident prompt node composes the turn from responder plus both source nodes, supervisor synthesizes it (running its own retrievers), runs its transformer chain, and then the slack_reply exposure sink node is dispatched.
Optional template variables (see abt.yaml → vars:):
issue_key— when set, fetches that Jira issue via thelinked_jirasource.jira_projects— comma-separated project keys to scope the Jira search retriever.confluence_spaces— comma-separated space keys to scope the Confluence search retriever.
Local iteration without delivery
abt dispatch -s incident_response --skip-exposures \
--mock-sources '{slack_thread: "Pod crashed with OOM at 3am, user checkout failing"}'
--skip-exposures runs the agents and transformers but does not post to Slack or fire lifecycle handlers (on_success / on_failure). --mock-sources stubs only the named source keys; other sources fetch normally (--skip-sources disables fetching). The retrievers on supervisor still run; --skip-retrievers skips them. This call needs a real ANTHROPIC_API_KEY.
Ad-hoc agent run
abt run -s <agent> runs one agent alone, plus its own subagents: tree (none here) — never a workflow neighbor, since workflow isolation is structural. A bare agent always needs an explicit -p. Add --dry-run to see the plan without a model call:
abt run -s supervisor -p "User checkout failing with 500s since 09:15 UTC" --dry-run
● Run target selector='supervisor'
Execution order: supervisor
✓ supervisor model=(profile default) tools=1 skills=0 sys_prompt_chars=609
output_schema: incident_response.IncidentResponse
Prompt stem/raw='User checkout failing with 500s since 09:15 UTC' resolved_chars=47
────────────────────────────────────────────────────────
No LLM calls or test execution performed.
Drop --dry-run to run supervisor by itself (this calls the model), with no upstream chain to synthesize — useful for rehearsing its own JSON-output behavior in isolation. To run the full workflow, use abt dispatch -s incident_response above.
5. Tests and guardrails
The template generates tests/researcher.yaml and tests/supervisor.yaml:
# tests/supervisor.yaml
agents:
- agent: supervisor
tests:
- name: structured_incident_json
prompt: "User reports elevated 5xx on checkout. Thread is empty. Summarize as incident JSON."
contains: [severity]
says: ["is JSON with severity, summary, and action-related fields"]
supervisor is the template's name for the workflow's last agent. It declares no subagents:, so there's nothing to wire here — the test exercises it in isolation with a plain prompt, standing in for what it would otherwise synthesize from the workflow's upstream chain.
Run them. abt test --dry-run needs no model call; the other two abt test forms call the model, so they need a real ANTHROPIC_API_KEY:
abt test --dry-run # print which cases would run
abt test # all suites
abt test -s supervisor # just the supervisor suite
abt test --dry-run prints:
● Test suites
✓ researcher cases=1
· lists_hypotheses checks: 1x contains, 1x matches prompt_chars=53
preview: Symptoms: timeouts on /api/cart. What might be wrong?
✓ supervisor cases=1
· structured_incident_json checks: 1x contains, 1x says prompt_chars=83
preview: User reports elevated 5xx on checkout. Thread is empty. Summarize as incident JSON.
────────────────────────────────────────────────────────
No LLM calls or test execution performed.
abt doctor runs static health checks on every agent's prompt and wiring, with no model call:
abt doctor
abt doctor --deep # adds an LLM prompt review (API cost)
On the fresh project, abt doctor reports every agent OK (exit code 0) and starts with:
✓ 3 agents checked: no findings.
Set config.testing.judge_model_id in abt.yaml to pin a dedicated judge model for both says checks and --deep reviews.
6. CI integration
A typical CI job:
abt compile # validate wiring (no external calls unless --live)
abt test --fail-fast # run YAML test suites
abt doctor # static health checks (add --deep for nightly)
--live also runs live MCP tool discovery and makes a failed fetch of compile-time context such as Confluence or S3 content fail the compile; a default compile only warns. Use it for a deploy-time validation gate. Compile still resolves env_var(...) references in profiles.yaml, so CI must export the variables its env: block reads (placeholder values are enough for compile-only jobs); an unset one in mcps/*.json only warns without --live. --fail-fast stops after the first failing case. Pair with ABT_MOCK_EXTERNAL_CONTEXT=1 if you want every compile in CI to stub external context.
See also
- Agents — the full frontmatter field reference
- Sources — all source types and
freshnessconfig - Retrievers — RAG-style enrichment with prompt transforms
- Transformers —
json_extract,pii_redact,llm_rewrite,assert,llm_guard - Exposures — post-run destinations and the exposure-timing rule
- Workflows — workflow file schema, diamond/conditional edges, prompt/source/exposure nodes
- Subagents — tool delegation via
subagents: - Testing — YAML test suites,
abt test,abt doctor