What you will have
Three roster agents on three templates. A quarterly re-review alert posted by a bot into#risk-alerts starts the Underwriting Agent. It asks a human for permission, hands the merchant to the Risk Agent, reads the six-line research report back, and decides from the report’s Decision line. On ESCALATE it asks a second human and hands the block to the Engineering Agent, which opens a pull request. Every run of every agent is team-visible, attributed to the right agent, and graded against that agent’s rubric. The Underwriting Agent never researches or acts itself.
The agent spec
Order of work for a multi-agent system
Build from the leaves up. Each subagent is a complete agent in its own right and goes through the six steps alone first. The orchestrator comes last, and the gates come after the orchestrator has proven one full hop without them.- Risk Agent: job, rubric, template, skill, prove on seeded merchants.
- Engineering Agent: same, prove it opens a PR from a prompt that carries an approval id.
- Underwriting Agent: job, rubric, template with the delegate skill and orchestration context, Slack trigger on a test channel.
- Prove one hop end to end with the gate hook absent.
- Add the gate hook and prove the same hop with a human approving.
1. Define the job
Follow Define the job three times.Risk Agent
runtm-api session create, launch or prompt.”Default template risk-agent, coding agent claude-code.Engineering Agent
Cannot block: missing <field> and stop. Do not guess.”Default template hyperswitch (a fork of the payments codebase), coding agent claude-code.Underwriting Agent
#risk-alerts from the Risk Monitor bot. Treat every top-level bot alert as a case. You dispatch and decide; two human gates protect this run, enforced by a hook; treat every gate outcome as final.”Default template underwriting-agent, coding agent claude-code.2. Measure success
Follow Measure success. Each agent is graded on its own runs, because each delegated session is created with that agent’sagent_id.
3. Give it tools
Follow Give it tools. Three templates, one per agent, each carrying only that agent’s skill.Three templates
risk-agent and underwriting-agent are blank environments; they exist to carry skills, context and hooks. hyperswitch clones the payments fork so the Engineering Agent can commit a migration. Templates are not only for coding agents: two of the three clone nothing.Git identity for the actor
Production data
4. Define how it works
Follow Define how it works.Subagent skills
merchant-rereview-research on the Risk template: run one script for the merchant id, return the six-line report verbatim, Decision is CLEAR, ESCALATE - <reason> or MANUAL REVIEW - <reason>. Never soften the report; the orchestrator copies it line by line. Never run runtm-api session create|launch|prompt.block-merchant-migration on the Engineering template: extract MID, REASON, APPROVAL_ID (the uuid after “Runtime approval” that the delegate script appends) and APPROVED_BY from the prompt; missing merchant id or approval id means Cannot block: missing <field> and stop. Generate migrations/<timestamp>_block_merchant_<MID>/{up.sql,down.sql} creating a merchant_blocklist table row with the reason and approval id, open the PR on block/<MID> with runtm-api session git <session_id> create_branch_and_pr, reply with PR: <url> and the two SQL files. Never force-push, never push to main, never merge.The delegate skill on the orchestrator
delegate-to-agent from the recipe to the Underwriting template, with two targets: risk (Risk template, Risk agent, gate research_start) and engineering (Engineering template, Engineering agent, gate merchant_block).The orchestrator context
The Slack trigger
#risk-alerts.Build all three templates once
5. Prove it works
Follow Prove it works and iterate, leaves first.session create then session prompt), and the parent through its Slack test channel. Read each run’s grade and the scorecard per agent.
In the parent’s run the transcript shows a “Delegated work to subagent: Risk Agent” card with Open subagent session. The Sessions page in Team mode lists the child as a Risk Agent run with its own cost.
6. Add guardrails and approvals
Follow Add guardrails and approvals. For a multi-agent system the gates are the guardrail, and they go on the orchestrator’s template.Add the gate hook to the Underwriting template
hil-gates hook from the recipe, with two rows: --target risk opens research_start for the Compliance team, --target engineering opens merchant_block for the Engineering team. Any raw runtm-api session create|launch|prompt or direct call to the sessions API is gated as agent_handoff for org admins, so the orchestrator cannot route around the script. PreToolUse, matcher Bash, timeout 600.Deny writes on the actor
git push --force* and git push*main*, and deny gh pr merge*. The skill already says never; the rules make it impossible.Prove the gated hop
awaiting_approval with kind research_start; a Compliance member approves on the Sessions board. The Risk run completes, the parent reads ESCALATE, and a second approval merchant_block appears for Engineering. Approve it; the Engineering run opens the PR and the parent posts the outline with both approval ids and the PR link. Then reject one gate on a fresh alert and confirm the parent stops with the hook’s reason.Move the trigger to the live channel
#risk-alerts.What stays human
- Both handoffs. Nothing reaches the Risk Agent without Compliance saying yes, nothing reaches the Engineering Agent without Engineering saying yes.
- The merge. The Engineering Agent produces a PR; a person merges and deploys.
- The MANUAL REVIEW branch. The orchestrator posts and stops; a person picks it up.
Gotchas
- Build leaves first. An orchestrator is impossible to debug when its subagents are unproven. Grade each child alone before the first hop.
- Two templates plus one hook, not one template. If the parent and a child shared a template, the child would inherit the gate hook and the delegate skill, and could delegate again. Separate templates keep the hook on the orchestrator only.
- Each hop is its own graded run. The parent’s scorecard says whether it dispatched correctly; the child’s says whether the research or the block was right. Do not try to grade the whole chain from the parent’s rubric.
- Run-as identity comes from
agent_idon create, which is why the script uses the API and not the CLI’ssession create. Without it the child run is attributed to no agent and graded against nothing. - The approval id travels in the prompt. The Engineering Agent refuses without it. The delegate script appends it for action targets; the report from a research target does not need it.
- Bot messages need the bot toggle. A monitoring bot posting into the channel does not start a run unless Auto-launch on bot channel messages is on.
- Slack shows the outline, not the ids. Keep approval and session ids out of the Slack-facing summary when a person reads it; the dashboard shows who approved.