Interrupts & Listeners - Human-in-the-Loop
Pause for human input with |! yield(...), wait with ~>
halo
// ============================================================
// STEP 7: Interrupts & Listeners - Human-in-the-Loop
// Learn: Pause for human input with `|! yield(...)`, wait with `~>`
// ============================================================
policy NoProfanity : Block(Profanity)
tool SlackApprovals : POST("hooks.slack.com/services/hello-approvals")
agent Greeter [gemini-3-1-pro, temp: 0.7]
requires NoProfanity
pipeline ApprovedHello(name: String) -> Result:
name
|> Greeter.prompt("Write a warm, 1-sentence greeting for {{name}}.") as greeting
// Interrupt: Pause for human approval
|! yield(context.data.greeting)
// Listen for approval response (the event is stored at context.data.reaction)
~> listen(SlackApprovals.Reaction) as reaction
// Gate: Only print if approved
|? (context.data.reaction.approved == true)
|> System.Print()