Building Safeguards and Approval Flows for Autonomous Agents
This lesson explains how to build autonomous and semiautonomous workflows that pause, check and escalate at the right points, keeping agent actions within acceptable risk.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish autonomous from semiautonomous workflows.
- Implement MCP tool approval and workflow approval steps.
- Identify the layers of safeguards for agents.
Autonomy levels
Autonomy is the degree to which an agent or workflow completes its work without a person reviewing or approving its actions. More autonomy means faster, cheaper processing; less autonomy means more human control over consequential actions. Workflows are designed at one of two levels.
An autonomous workflow completes without human involvement. It suits low-risk, reversible, high-volume tasks such as tagging documents.
A semiautonomous workflow acts autonomously for routine cases and pauses for approval when a condition is met, such as an amount over a threshold, low model confidence, a policy exception or an action affecting an external party. The thresholds are business decisions, recorded in configuration and enforced in code.
Act or pause?
Approval mechanisms
An approval mechanism is the means by which a semiautonomous agent stops before an action, presents the proposed action to a person, and continues only if that person approves it. Foundry provides two main mechanisms.
With MCP tool approval, a tool is configured to require approval. When the agent wants to call it, the agent's response includes an approval request with the tool name and arguments, and the call proceeds only after the client sends an approval response.
With human-in-the-loop workflow nodes, a Foundry workflow pauses at a node that asks a person for input or approval and resumes with the answer, even after hours or days, because workflow state is persisted.
Function tools can also implement custom approvals by placing requests in a queue and returning a pending status.
r = openai.responses.create(conversation=conv.id, input="Create a case for customer 4471: broken hinge")
for item in r.output:
if item.type == "mcp_approval_request":
approved = ask_operator(item.name, item.arguments) # show tool and arguments to a person
r = openai.responses.create(conversation=conv.id, input=[{
"type": "mcp_approval_response", "approval_request_id": item.id, "approve": approved}])The following sequence shows an MCP tool approval from request to result.

The following screenshot shows an MCP approval request in the agent playground. The run pauses and shows the tool name and arguments, and the user approves or denies the call.

Approving offers three scopes, as the following screenshot shows: this call only, every later call to this tool, or every tool of the server.

Safeguards
Approvals protect specific actions, but an agent needs protection on every step, because any single control can fail. A guardrail can miss a cleverly worded attack, a model can misread its instructions, and a tool can return unexpected data. Safeguards are therefore layered, so that a failure in one layer is caught by another, the same defence-in-depth principle used in network security.
The layers address different failures. Guardrails inspect content at each intervention point and stop harmful input, attacks and unsafe output. Limits on iterations, tool calls, tokens, time and spending stop runaway loops and bound cost. Validation in tool code rejects arguments that break business rules, whatever the model intended. Least-privilege identities ensure that even a mistaken or manipulated call can only reach what the tool's identity is allowed to reach. Compensation steps undo partial work when a multistep workflow fails midway, and escalation hands the case to a person when the agent is uncertain or keeps failing. The following list summarizes the layers.
- Guardrails at user input, tool call, tool response and output.
- Limits on iterations, tool calls, tokens, time and spending per run.
- Validation of tool arguments and outputs against business rules in code.
- Least-privilege identities for tools, so that mistakes have bounded impact.
- Compensation: undo steps or reversing transactions when a workflow fails midway.
- Escalation: hand the case to a person when the agent is uncertain or repeatedly fails.
Layers of safeguards
Semiautonomous refunds
A retailer wants an agent to issue refunds automatically up to 50 EUR, require a supervisor's approval above 50 EUR, and never refund an order older than 90 days.
Implement the refund as a function or MCP tool whose code rejects orders older than 90 days and refunds of more than the order value; route requests above 50 EUR through an approval step (MCP approval or a human-in-the-loop workflow node) and log every decision. Writing the thresholds only in the agent's instructions would let a manipulated or mistaken model exceed them.
How does a client approve an MCP tool call?
Show answer
The response contains an mcp_approval_request, and the client replies with an mcp_approval_response that approves or denies it.
Exam Tips
Remember for the exam
- Enforce thresholds and hard limits in tool code; use approvals for high-impact actions.
- MCP approval: mcp_approval_request in the response, mcp_approval_response from the client.
- Human-in-the-loop workflow nodes persist state and resume when a person responds.