---
title: "Human in the Loop Automation for AI Agents"
description: "Human in the loop automation for unattended agents: allow, deny or ask, how headless Claude Code and Codex handle prompts, and what to do when nobody answers."
url: "https://notifexapp.com/blog/human-in-the-loop-automation-for-ai-agents"
published: "2026-11-19"
updated: "2026-11-19"
author: "Alaa Jawhar"
---

# Human in the Loop Automation for Agents That Run Unattended

Human in the loop automation means an unattended agent still gets a person's decision at the few steps that need one. You sort every action into three groups: allowed, denied, and ask a person. Then you send the "ask" group somewhere a person will see it, and you decide what happens if nobody answers.

This post covers agents that run from cron, CI or a background job, with nobody at the terminal. For where to put the checkpoints, see [8 examples of when an agent should ask](https://notifexapp.com/blog/human-in-the-loop-ai-agents-examples), and for the term itself, the [glossary definition of human in the loop](https://notifexapp.com/glossary/human-in-the-loop). We make Notifex, which carries the questions to a phone in the example below. Tool facts were checked in each vendor's docs on 2026-11-19.

## What happens to a permission prompt when nobody is watching?

It cannot be answered, so the tool decides for you. Two common coding agents handle it like this:

- **Claude Code.** In a `claude -p` run with nothing to answer a prompt, Claude Code denies the call, as its [permissions docs](https://code.claude.com/docs/en/permissions) explain. The [headless docs](https://code.claude.com/docs/en/headless) show `--allowedTools` to pre-approve tools, and `--permission-mode dontAsk` to deny everything not pre-approved.
- **Codex.** The [codex exec docs](https://developers.openai.com/codex/noninteractive) say it runs in a read-only sandbox by default. You widen access only as far as the job needs.

Both defaults are safe. They also mean a risky step does not happen at all, even when you would have said yes. The job fails or skips, and you find out in the morning.

## How do you sort an agent's actions for automation?

Write three lists before the first run.

1. **Allow.** Cheap, reversible steps inside the job's own scope: reading files, editing in a branch, running tests.
2. **Deny.** Steps this job should never take: force pushes, production deploys, deleting data.
3. **Ask.** Steps that are fine sometimes and wrong other times: a major version bump, a failing test the agent cannot fix, a change outside the expected files.

The allow list goes into the tool's permission settings. The deny list goes there too, or stays out of reach because the tool is never allowed. The ask list is the part that needs a person, and it should be short. If it grows past a handful of items, the job is too broad to run alone.

## How does an unattended agent ask a person?

Give it a question tool that reaches a phone. Notifex is a remote MCP server: the agent calls **ask_question** with options, your phone gets a push, and the answer returns to the agent as the tool result. In a headless Claude Code run, you allow the Notifex tools by name, the same way as any other tool.

The example below runs a nightly dependency update. The script allows npm, git, opening a pull request and three Notifex tools, and denies everything else with dontAsk. `CLAUDE.md` names the steps that need a question.

![A terminal shows nightly-deps.sh, which runs claude -p in dontAsk mode with an allowed tools list that includes the Notifex tools, and a CLAUDE.md section on unattended runs.](https://d29bihfk9mha1v.cloudfront.net/notifex/blog-human-in-the-loop-automation-for-ai-agents-auto-1-v1.webp)

_A cron script and CLAUDE.md in a demo project, shown in a terminal on a Mac, 2026-11-19._

Two settings decide how long the agent may wait. In Claude Code, `MCP_TOOL_TIMEOUT` sets how long an MCP tool call may run, per the [environment variable docs](https://code.claude.com/docs/en/env-vars). For an HTTP server, each request also times out after 60 seconds unless you raise this value above 60000. In Codex, `tool_timeout_sec` in the server's config does the same job. If the agent cannot wait at all, call ask_question with `wait=false` and pick up the answer later with check_answer.

Setup for the MCP entry is on the Claude Code page and, for other agents, [the setup page for each client](https://notifexapp.com/connect-your-agent).

## What should happen when nobody answers?

Decide this in advance and write it into the instructions. A safe fallback has three parts:

- **No answer is never yes.** If the question times out, the risky step does not run.
- **Finish what is safe.** The agent completes the allowed work and leaves the risky step undone.
- **Leave a record.** The pull request or log says what the agent would have done and why it stopped.

CI systems use the same idea for deploys. In [GitHub environments](https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments), a job with required reviewers waits for one of them to approve before it runs. A wait timer can delay a job by up to 30 days. The job does nothing on its own while it waits.

## How do agent frameworks pause for a person?

If you build the agent yourself, the framework usually has a pause built in. Your code then delivers the question and resumes the run with the answer.

- **LangGraph.** [Interrupts](https://docs.langchain.com/oss/python/langgraph/interrupts) pause a graph inside a node with `interrupt()`. A checkpointer saves the state, and `Command(resume=...)` passes the answer back in, even much later.
- **OpenAI Agents SDK.** The [human-in-the-loop guide](https://openai.github.io/openai-agents-python/human_in_the_loop/) marks tools with `needs_approval`. A paused run returns interruptions, and `RunState` can be saved and resumed after a person approves or rejects.

![The OpenAI Agents SDK human-in-the-loop guide next to the LangGraph interrupts docs.](https://d29bihfk9mha1v.cloudfront.net/notifex/blog-human-in-the-loop-automation-for-ai-agents-auto-2-v1.webp)

_openai.github.io/openai-agents-python and docs.langchain.com, captured 2026-11-19. Apps and logos belong to their owners._

Both frameworks leave delivery to you. The question still has to reach a person who is not at a screen. That is where a push to a phone fits, from your own code or through an MCP tool the agent calls. For hosted services that do this, see [HumanLayer alternatives for asking a human](https://notifexapp.com/alternatives/humanlayer).

## What does a night of human in the loop automation look like?

Here is the dependency job from above, step by step.

1. At 02:00, cron starts the script. Claude reads the repo and updates minor versions.
2. Tests pass for all but one package. One update is a major version, which `CLAUDE.md` puts on the ask list.
3. Claude creates a Notifex thread and asks: "Upgrade the date library from v3 to v4? 12 call sites change." with _Update_ and _Skip_.
4. Your phone gets the push at night. You are asleep, so the question waits in your inbox.
5. The tool times out at the limit you set. Claude skips the major bump, opens the pull request with the safe updates, and lists the skipped item.
6. In the morning you answer, or you take it from the pull request.

![Two iPhone screens: the Notifex inbox with a waiting agent thread, and a thread where the question was answered and locked.](https://d29bihfk9mha1v.cloudfront.net/notifex/blog-human-in-the-loop-automation-for-ai-agents-auto-3-v1.webp)

_Notifex on an iPhone 17 Pro simulator with demo fixture data, captured October 2026._

If you answer within the window, the run continues with your choice instead. In a team project every member gets the push, and the first answer wins. So the person on call can answer while you sleep.

## Checklist for human in the loop automation

- The job has one clear goal, and its allow list matches that goal.
- Dangerous tools are denied, not only left out of the instructions.
- The ask list names steps, such as "major version bump", rather than "anything risky".
- Questions offer options, so the answer is a clean choice.
- The wait has a limit, and "no answer" leads to a safe skip.
- The output records what was asked, what was answered and what was skipped.

A `CLAUDE.md` section like this one covers the last four points:

`## Unattended runs` `- Ask with Notifex (create_thread, then ask_question) and wait before a major version bump.` `- Offer options, for example "Update" and "Skip".` `- If the question fails or times out, skip the step and explain it in the pull request.`

Notifex is free on the App Store and Google Play: [the Notifex iPhone app](https://notifexapp.com/iphone-app) and [the Notifex Android app](https://notifexapp.com/android-app). For a person watching instead of answering, read [how human on the loop differs](https://notifexapp.com/blog/human-in-the-loop-vs-human-on-the-loop).

## Quick answers

### What is human in the loop automation?

Automation where an unattended agent or workflow stops at named steps, asks a person, and continues with the answer. Everything else runs on its own.

### What does Claude Code do with a permission prompt in a headless run?

In a claude -p run with nothing to answer a prompt, Claude Code denies the call. Pre-approve the tools the job needs with --allowedTools.

### How long can an agent wait for a human answer?

As long as its tool timeout allows. In Claude Code, raise MCP_TOOL_TIMEOUT; in Codex, set tool_timeout_sec. With Notifex, wait=false and check_answer avoid a long wait.

### What should an agent do if nobody answers?

Skip the risky step, finish the safe work, and record what it would have done. No answer should never count as approval.
