Make “ask a human” a structured output like any other tool, and the agent stops being something a person sits in front of. This is factor 7 of 12-Factor Agents, and it’s the one idea in that document with no prior equivalent in this vault.

The mechanic
By default an LLM API forces a high-stakes choice on the first token of every turn: plain text to the user, or structured data for a tool. Horthy’s suggestion is to remove the choice — have the model always emit JSON, and let it declare intent in natural language:
class RequestHumanInput:
intent: "request_human_input"
question: str
context: str
options: Options # urgency: low|medium|high, format: free_text|yes_no|multiple_choice, choices: [...]In the loop, this intent breaks execution rather than executing anything:
if next_step.intent == 'request_human_input':
thread.events.append({type: 'human_input_requested', data: next_step})
thread_id = await save_state(thread)
await notify_human(next_step, thread_id)
return # break the loop; a webhook resumes us laterThe human answers through Slack, email, or SMS. A webhook loads the thread by id, appends a response_from_human event, and the loop continues from exactly where it stopped. done_for_now is the same shape: even “I’m finished, here’s the answer” is a tool call.
The thread then reads as one continuous record:
<slack_message> From: @alex Text: Can you deploy backend v1.2.3 to production? </slack_message>
<request_human_input> question: "Proceed with deploying v1.2.3 to production?" urgency: high format: yes_no </request_human_input>
<human_response> response: "yes please proceed" approved: true user: alex@company.com timestamp: ... </human_response>
<deploy_backend> tag: v1.2.3 environment: production </deploy_backend>
<deploy_backend_result> status: success </deploy_backend_result>Note what that log is: an audit trail with the approver, the question asked, and the action taken, in causal order. You did not build it. It’s a side effect of treating the thread as the state.
Why it isn’t just ergonomics: inner loop vs outer loop
The real consequence is a reversal of who initiates.
| Inner loop | Outer loop | |
|---|---|---|
| Control flow starts | Human → Agent | Agent → Human |
| Trigger | Someone typing in a chat window | Cron, webhook, alert, event, another agent |
| Human’s role | Driver | Approver, unblocker, escalation target |
| Human’s attention | Held for the whole run | Requested at specific moments |
ChatGPT-shaped products are all inner loop. The agent can only act while a person is watching it. Once “contact a human” is a durable tool call, the agent can be started by an outage at 3am, work for ninety minutes, hit a decision it shouldn’t make alone, page someone, and sit patiently until an answer arrives.
This is the missing half of Loop Engineering. Osmani’s loops answer “who prompts the agent when I’m not there.” Factor 7 answers “what does the agent do when it needs me and I’m not there.” A loop without it must either restrict itself to safe operations or run unsupervised on unsafe ones.
The precondition
This only works if you can pause between tool selection and tool invocation and persist. Approval that happens after deploy_backend already ran is not approval. See the “gap that actually matters” section of Agent State and Resumability.
Concretely, it requires:
- Factor 5 — state is a serializable thread, so pausing is just saving.
- Factor 6 — a resume API a webhook can call without knowing your orchestrator.
- Factor 8 — you own the control flow, so certain intents can break the loop instead of dispatching.
- Factor 11 — a channel the human already lives in, otherwise the request waits in a dashboard nobody opens.
Miss any one and this degrades into a blocking prompt in a terminal.
The safety trade this buys
The usual framing is that human-in-the-loop limits what an agent can do. Horthy’s is the opposite: being able to loop in a human quickly is what lets you widen the agent’s permissions. If a high-stakes action reliably routes to an approver in Slack within seconds, you can give the agent external email, production data writes, and deployments — things you would never grant an agent that can only ask by stopping and waiting for someone to notice.
That’s the same trade as the tiering in Agentic Code Review (blast radius decides the gate) and the delegated-approval pattern in Five Patterns for Long-Running Agents in Production, but pushed down into the agent’s own tool schema rather than sitting in the surrounding process.
What the vault already had, and where it fell short
- Agentic Code Review — human on the loop, a human owns the merge. Correct, but it’s a review gate at the end, not an interrupt in the middle.
- Five Patterns for Long-Running Agents in Production — delegated approval as a named pattern. Closest prior art; this page supplies the mechanism.
- Agent Security and Threat Model — the Agents Rule of Two and the lethal trifecta say when a human must be involved. Factor 7 says how without killing the run.
- Claude Code Automation Stack — permission prompts are the inner-loop version: they block on a person being at the keyboard.
The gap was consistent: the vault treated human involvement as a process wrapped around the agent. Factor 7 makes it a capability inside the agent.
Multi-agent extension
The same abstraction covers Agent → Agent. A subagent that needs a decision from an orchestrator emits the same event type and pauses; the orchestrator answers on the same channel. Nothing about the mechanism assumes the responder is human — which is why Multi-Agent Systems and this page share a shape.
Related
- 12-Factor Agents — the parent document
- Agent State and Resumability — the precondition
- Dex Horthy — author; HumanLayer is the product built around this factor
- Agent Security and Threat Model — when a human must be in the path at all
- Personal Agent Operating Rules — an autonomy ladder (L0 read to L4 financial) calibrated on reversibility, with mobile-source autonomy capped at L2
- Goal-First Agent Automation — a popular non-technical automation guide with no approval or permission story; the gap this page fills
- Agent Platform Blueprint: John Suh extends the idea to all user-facing output (the agent posts to a “conversation” via a tool call, the raw session is only for debugging) and predicts users will work from an inbox of approvals and questions