Human in the Loop: Making an Agent Ask Before It Acts

Some tools I’m happy to let an agent call on its own. Others, the ones that post, book, delete or spend money, I want a person to approve first. Solace Agent Mesh calls this human in the loop (HIL), and it’s a per-tool setting rather than something you write into the prompt.

To try it, I gated the freight quote tool in my Northwind demo, but only for air shipments. The block goes in the toolset’s config under the reserved hil key, keyed by tool name:

kind: toolset
name: freight-rates
spec:
  config:
    hil:
      quote_freight_rate:
        require_approval_when:
          - arg: mode
            eq: air
        approval_message: "Quote {{.weight_kg}} kg by {{.mode}} from {{.origin}} to {{.destination}}?"
        timeout: "10m"

require_approval: true gates every call. require_approval_when gates only when an argument matches, which is handy for one tool that does both reads and writes (gate method in POST, PUT, DELETE and let GET through). The message is a Go template over the call’s arguments. Connectors take the same block under values.hil.

I applied it with sam config apply and asked the Supply Chain Analyst to quote 340 kg Shanghai to Rotterdam by air and by ocean. The ocean quote ran straight through. The air one stopped and waited for me:

Approve ran the tool and the answer came back as normal. Deny and get the following:

The agent didn’t say “you declined that”. It guessed: maybe the tariff needs more authorization, maybe I should supply a volume. None of that was true. If you gate tools, add a line to the system prompt telling the agent that a denied tool call means the user said no, and that it should say so and not invent a reason.

A few other things worth knowing:

  • The default timeout is 45 minutes, after which the call is denied. Set timeout on the entry to change it.
  • The gate applies to agent tool calls. A workflow type: tool node dispatches the tool without asking, and logs a warning.
  • For a question rather than a yes or no, add the hil_tools toolset. Its ask_user_question tool renders a short multiple-choice form in chat.

Docs:

If you want to see the approval card yourself, download the Solace Agent Mesh desktop app and gate one tool on a test agent.

Which of your agent’s tools would you put behind an approval first?