> ## Documentation Index
> Fetch the complete documentation index at: https://docs.duvo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Human-in-the-Loop

> Add human approval steps to Duvo agents. Pause workflows for review, approval, or input before the agent continues.

Human-in-the-Loop lets your agents pause at specific points and wait for your input before continuing. Use it to keep a human decision in the loop wherever your workflow requires review — approving a risky action, answering a follow-up question, or checking a draft before it goes out.

<Note>
  Human-in-the-Loop is a built-in connection. No setup is required — it is available for every agent automatically.
</Note>

## How it works

```mermaid theme={"dark"}
flowchart TD
    A[Agent reaches a checkpoint in the AOP] --> B{Request type}
    B -->|Approval| C[Proposes an action]
    B -->|Question| D[Asks you to choose an option]
    B -->|Login| E[Requests a login]
    C --> F[Delivered to Requests, live run, Slack, or Teams]
    D --> F
    E --> F
    F --> G{Your response}
    G -->|Approve / Answer| H[Agent continues]
    G -->|Deny| I[Agent follows the fallback in your AOP]
```

## When to Use It

Human-in-the-Loop is the right tool when:

* **The action is irreversible** — sending an email, deleting records, submitting a form, making a payment
* **The decision requires judgment** — exception handling, ambiguous requests, policy edge cases
* **Compliance requires sign-off** — expenses over a threshold, contract changes, PII-related actions
* **You want to review a draft first** — see what the agent will send or publish before it does

<Tip>
  If a step is routine and low-risk, let the agent handle it on its own. Reserve Human-in-the-Loop for steps where a wrong decision would be costly or embarrassing.
</Tip>

## Request Types

Agents can send three types of requests:

<AccordionGroup>
  <Accordion title="Approval" icon="circle-check">
    The agent presents a proposed action and waits for you to confirm or reject before proceeding.

    **What you see:** A request with a title summarizing the action and a description providing the context you need to decide.

    * **Approve** — the agent continues with the proposed action.
    * **Deny** — the agent receives your rejection and follows whatever fallback you defined in the AOP (for example: skip this step, try an alternative, or stop).

    **Example AOP instruction:**

    ```
    Before sending any email to a customer, request approval. In the title, include the recipient
    and subject line. In the description, include the full email body. Only send after receiving approval.
    ```
  </Accordion>

  <Accordion title="Question" icon="circle-question-mark">
    The agent asks you to choose from a set of options before it decides how to proceed. Use this when the right next step depends on context only you have.

    **What you see:** A question with selectable options. Pick one and submit — the agent receives your answer and continues down the correct path.

    **Example AOP instruction:**

    ```
    If the customer's request cannot be resolved automatically, ask the user:
    (a) Reply asking for clarification, (b) Escalate to the account manager, or (c) Close the ticket.
    ```
  </Accordion>

  <Accordion title="Login Request" icon="key">
    The agent needs a login to access a system it has not been authorized for. It pauses and directs you to add the login in **Resources > Logins and Secrets**. Once the login is saved, the agent continues.
  </Accordion>
</AccordionGroup>

## Adding Approval Gates to Your AOP

You control exactly where approvals happen by writing them into your AOP. You do not configure Human-in-the-Loop separately — just describe the checkpoint in plain language and the agent will pause there.

**Review before sending:**

```
Draft the reply but do not send it. In the approval title, include the recipient and subject.
In the description, include the full draft body. Only send after I approve.
```

**Threshold-based gate:**

```
Auto-approve refunds under $200. For refunds between $200 and $1,000, request approval with
the customer name, order ID, and reason. For anything over $1,000, ask whether to approve,
deny, or escalate to the finance team.
```

**Content review before publishing:**

```
Generate the post and request approval before publishing. If I deny, ask what to change
and regenerate the content.
```

**Exception routing:**

```
If the issue cannot be categorized automatically, ask whether to route it to tier-1 support,
tier-2 support, or the customer success team.
```

**Batch summary gate:**

```
After processing all line items, show me a summary of the changes and request approval
before committing any updates to the system.
```

### Writing good approval request titles

The title is the first thing you see when a request arrives. Write your AOP so the title includes the specific details, not just "Requesting approval." For example:

* "Send invoice to Acme Corp — \$4,200 due 2026-06-01"
* "Delete 47 archived records from the leads table"
* "Publish blog post: 5 Ways to Cut Procurement Costs"

You can instruct the agent explicitly:

```
When requesting approval, set the title to "[action] — [key detail]".
```

## Responding to Requests

You can respond wherever you work. The agent waits and resumes the moment you reply.

<Tabs>
  <Tab title="Requests">
    [Requests](/user-guide/assignment-features/requests) is your central queue for all pending requests. A badge in the left sidebar shows the count of pending items. Requests appear the moment an agent pauses.

    To respond:

    1. Open Requests from the left sidebar.
    2. Click the request to open the detail panel.
    3. For approvals: click **Approve** or **Deny**.
    4. For questions: select your answer and submit.

    The agent resumes immediately after you respond.
  </Tab>

  <Tab title="During a live run">
    When you are watching an agent run in real time, approval requests appear directly in the session window. You can approve or answer without leaving the run view — the agent is waiting and will continue as soon as you respond.
  </Tab>

  <Tab title="Slack">
    If you have connected Slack and enabled notifications, pending requests are delivered as direct messages from the Duvo bot. Each message includes the request title, description, and interactive buttons.

    * Tap **Approve** or **Deny** directly in Slack — no need to open Duvo.
    * For questions, select your answer from the options in the message.
    * Once you respond, the message updates to confirm the outcome and the agent resumes.

    To enable Slack notifications, go to **Settings > Notifications** and connect your Slack account.
  </Tab>

  <Tab title="Microsoft Teams">
    Pending requests arrive as Adaptive Cards in Microsoft Teams. Select your response directly from the card.

    To enable Teams notifications, connect Teams at the team level, link your personal Teams account, then enable **Requests in Microsoft Teams** under **Settings > Notifications**.
  </Tab>
</Tabs>

## Managing High Volumes

When an agent generates many requests — for example, a batch job that reviews dozens of items — use the bulk actions in Requests to keep up:

* **Mark all as responded** — dismisses all pending requests at once. Use this when a backlog of requests no longer needs individual review.
* **Delete all responded** — removes answered requests to keep the inbox clean.
* **Delete all** — clears everything, both pending and answered.

You can also filter by **status** (Pending / Answered) and **type** (Approval / Question) to focus on what matters most before taking a bulk action.

## Practical Examples

<AccordionGroup>
  <Accordion title="Reviewing outbound communications" icon="mail">
    Add this to any agent that sends messages on your behalf:

    ```
    Draft the message but do not send it. In the approval title, include the recipient and subject.
    In the description, include the full body. Only send after I approve. If I deny, ask what to change and revise.
    ```
  </Accordion>

  <Accordion title="Expense threshold enforcement" icon="badge-dollar-sign">
    Add this to an expense-processing AOP:

    ```
    Auto-approve expenses under $200. For $200 to $1,000, request approval with the employee name,
    amount, and justification. For over $1,000, ask: approve, deny, or escalate to the finance director?
    ```
  </Accordion>

  <Accordion title="Data modification gate" icon="database">
    Add this before writing to a live system:

    ```
    Before updating any records, summarize the changes you are about to make and the number of
    rows affected. Request approval before committing. If denied, stop and report what was skipped.
    ```
  </Accordion>

  <Accordion title="Exception routing" icon="git-branch">
    Add this to a support or operations agent:

    ```
    If the case does not match any standard category, ask: should I route this to tier-1 support,
    tier-2 support, or the customer success team?
    ```
  </Accordion>
</AccordionGroup>

## Tips

<Tip>
  **Define the rejection behavior.** Tell the agent what to do if denied. Without a fallback, it may stop entirely or retry the same action.
</Tip>

<Tip>
  **Use questions for branching.** When the right path depends on context you have but the agent does not, use a question rather than a yes/no approval.
</Tip>

<Warning>
  **Do not overuse approvals.** Every approval gate adds wait time. Use them only for decisions that genuinely require human judgment, and let the agent handle routine steps on its own.
</Warning>

<Tip>
  **Test the pause behavior.** Run the agent once and verify it pauses where you expect, and that the approval title and description give you enough context to decide without opening other systems.
</Tip>

## Related

<CardGroup cols={2}>
  <Card title="Designing Human-in-the-Loop Workflows" icon="compass" href="/user-guide/assignment-features/hitl-design">
    When to add approval gates, how to choose request types, escalation patterns, and ramping toward safe autonomy.
  </Card>

  <Card title="Requests" icon="inbox" href="/user-guide/assignment-features/requests">
    Where you manage and respond to all pending requests.
  </Card>

  <Card title="Scheduling Agents" icon="calendar-clock" href="/user-guide/assignment-features/scheduling-assignments">
    Run agents automatically so requests appear in your inbox.
  </Card>

  <Card title="Expense Report Approval" icon="receipt" href="/user-guide/examples/expense-report-approval">
    A full tutorial showing Human-in-the-Loop in a finance workflow.
  </Card>
</CardGroup>
