# How to ask a person before your AI agent acts

> Hold an agent's risky action until a person says yes. Your app carries out the agent's tool calls, so it asks first, then sends back the outcome in the next wake. The agent picks up where it stopped, and nothing is spent while it waits.

Source: https://getargentic.com/docs/guides/ask-a-person-before-your-agent-acts/

Some actions need a person's yes: a refund, an email to a customer, a change to a live system. Your app already carries out the agent's tool calls, so it can hold one until the person answers. The agent stops, and a later wake picks it up where it left off.

## The agent just stops

You don't need an approval feature in the engine. Argentic never runs your tools. When the agent calls one, the wake returns the call in `actions` and your app carries it out. That is the place to ask. Your app doesn't run the action yet. It asks a person through your own UI, Slack or email, and the agent's wake ends with the question open.

When the person answers, your app runs the action, or doesn't, and sends the outcome in the next wake. The agent has its full memory from the journal, so it continues from the call it was waiting on. While it waits, no model runs and nothing is spent.

## Declare the tool as usual

There is no flag to set. Declare the tool like any other and tell the agent, in the tool's description and in `system`, that the outcome comes later. Without that, a model tends to tell the customer the refund is done before anyone has said yes.

The wake

```
curl -sS "https://api.getargentic.com/v1/agents/support-bot/wake" \
  -H "Authorization: Bearer $ARGENTIC_API_KEY" \
  -H "X-Model-Key: $MODEL_KEY" \
  -H "Idempotency-Key: ticket-77-1" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Customer dana@example.com asks for a refund on order A1182.",
    "system": "Tool calls are requests, not results. The outcome of a tool call arrives in a later message. Some tools need a person to say yes first; when one does, wait for the message that tells you what they decided.",
    "model": {...},
    "tools": [{
      "name": "refund_order",
      "description": "Refund an order. A person must approve every refund, so the result arrives in a later message, not now.",
      "parameters": {
        "type": "object",
        "properties": {
          "order_id": { "type": "string" },
          "amount_usd": { "type": "number" }
        },
        "required": ["order_id", "amount_usd"]
      }
    }]
  }'
```

## Ask the person instead of running it

The wake returns the call. Each entry in `actions` has an `id`, the `tool`, its `args` and a `seq` that never changes:

What comes back (trimmed)

```
{
  "status": "done",
  "reply": "I've asked for the refund. A person has to approve it, so I'll pick this up when they answer.",
  "actions": [
    { "id": 1, "tool": "refund_order", "args": { "order_id": "A1182", "amount_usd": 42 }, "seq": 31 }
  ],
  ...
}
```

Treat `args` as untrusted input, since a model chose the values. Show the person the amount and the order, taken from your own data where you can, and not only what the model wrote.

Hold it in your app

```
// Your app, right after the wake returns.
for (const action of wake.actions ?? []) {
  if (action.tool !== "refund_order") { await runNow(action); continue; }

  // Do not run it. Record the request once per seq, then ask a person
  // in your own UI, a Slack message, an email: whatever your people use.
  await savePending({ agent: "support-bot", seq: action.seq, args: action.args });
  await askPerson({ summary: `Refund ${action.args.amount_usd} USD on ${action.args.order_id}`, seq: action.seq });
}
// The wake is over. Nothing runs and nothing is spent until you send the next one.
```

## Send the answer in the next wake

When the person answers, do what they decided. Then wake the agent with a `message` that says what happened and a `results` entry for that `seq`. A yes carries the real outcome. A no carries a refusal, so the agent knows to stop and what to tell the customer. The agent reads the `message` and the `results` together and carries on.

Wake it with the outcome

```
// Later, when the person answers.
const approved = answer.decision === "yes";
const outcome = approved ? await refundOrder(pending.args) : { denied: true, by: answer.person };

await fetch("https://api.getargentic.com/v1/agents/support-bot/wake", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ARGENTIC_API_KEY}`,
    "X-Model-Key": process.env.MODEL_KEY!,
    "Idempotency-Key": `ticket-77-answer-${pending.seq}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    message: approved
      ? "A person approved the refund and it has been made. The result is attached."
      : "A person refused the refund. Tell the customer, and don't try it again.",
    results: [{ seq: pending.seq, result: outcome }],
    system: "...", model: { /* as before */ },
  }),
});
```

The answer can come from anywhere that can call your code: a button in your dashboard, a Slack reply, a link in an email. For Argentic it is one more wake.

## A spend cap just stops the wake

When a wake reaches a spend cap it ends with `status: spend_cap` or `budget_cap`, and the work so far is kept. There is nothing to approve in the API. If the agent should go on, the owner raises the budget in the dashboard or with the `set_budget` tool, and you wake or resume the agent. See [past a spend cap](https://getargentic.com/docs/#spend-cap).

## Details that bite

- Key your pending request on `seq`. A wake finished after a crash lists its actions again, and you don't want to ask the person twice. See [making tool calls safe to retry](https://getargentic.com/docs/guides/make-agent-tools-safe-to-retry/).
- Check who is answering. Argentic doesn't know who your approvers are. The check that only a manager can approve a refund lives in your app.
- Use a new `Idempotency-Key` for each answer, so a retry of the answer isn't added to the agent's history twice.
- Nothing wakes the agent by itself, so an unanswered question waits for as long as you let it. If you want a nudge, remind the person from your own scheduler. An agent can also set a plan with a `wake_at` time when you send `schedule: true`, and you wake it from `GET /v1/due`.
- Take the amount from your own data when you run the action, as in the [refund example](https://getargentic.com/docs/examples/#refund), so a person approves what actually happens.

## What this doesn't cover

- Argentic holds the agent and resumes it. It doesn't store the request, ask the person or decide who may answer.
- This gates what your tools do. It does not gate the model bill. For that, use a cap.
- The snippets are shapes to adapt. Storage, the question to the person and error handling are yours.
- A person can approve a bad request. Keep a hard ceiling in the tool's own code as well.
