Autonomous Agents with Safeguards and Approvals
30-second answer
Let an agent read freely, but mark write tools that change data or move money as approval required, so the run pauses until a person approves or rejects. Put hard limits in code for what nobody should approve, give the agent least-privilege tools and limits on steps and cost, and keep traces so an auditor can see who decided. The more autonomy you give, the more these safeguards matter.
Simulate it » No Azure account neededExam objective: 2.2.5 Build autonomous or semiautonomous workflows with safeguards and approval flow controls. (Skills measured as of April 16, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Reads can run freely. <strong>issue_refund</strong> moves money, so set it to <strong>always require approval</strong>. The run stops at that call and waits.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Reads can run freely. issue_refund moves money, so set it to always require approval. The run stops at that call and waits.
- A paused run appears as a pending request with the exact arguments. The reviewer sees what would happen before it does.
- Approve or reject. The run resumes either way, and the decision is recorded.
- Put hard limits in code for what no one should approve, and keep a trace so an auditor can see who decided and when.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Autonomy with approvals
Reads are safe, writes are not. A tool marked approval required pauses the run until a person decides. A hard limit in code blocks what no one should approve, whatever the model says.
🤔 What happens if…
Read this tour as text
- Deploy a model, call the deployment. A deployment is a named copy of a model with a version, a deployment type and capacity. Your app calls the deployment name, never the model name. Pick a large model for hard work and a small language model for cheap, fast, simple work.
- RAG: retrieve first, then answer. Retrieval-augmented generation searches your own content (Azure AI Search, hybrid keyword plus vector), puts the best chunks in the prompt and asks the model to answer from them with citations. Without retrieval the model guesses.
- A multistep flow with checks. A workflow breaks one big request into steps you control: classify, extract to a JSON schema, call a tool, draft, then verify. Retries, fallbacks and a final check live in code, so one bad step can’t slip through unseen.
- Evaluate before you ship. Evaluators score each answer on a test set: groundedness (is it supported by the context?), relevance, coherence and safety checks. A fabrication shows up as a low groundedness score on one row, so you fix it before users see it.
- SDK, project endpoint and connections. The Foundry SDK (
azure-ai-projects) opens one door: AIProjectClient with the project endpoint and DefaultAzureCredential. From it your app gets an OpenAI-compatible client, deployments and connections (Azure AI Search, Application Insights) with no secrets in code. - Design the agent: role, goal, tool schema. An agent is a model plus instructions (role and goal), tools and a conversation (thread). A strict function schema names each parameter and marks the required ones, so the model asks the user instead of inventing a value.
- Retrieval, function calling and memory. One agent can use file search for documents, a function for live data and memory for what it learned about a user. The model asks to call a function; your code runs it and returns the result. Memory survives into a new conversation.
- Multi-agent orchestration. Several specialist agents can share a job. Sequential passes work down a line, concurrent fans out and merges, handoff moves control to the right specialist, group chat lets agents take turns in one shared conversation and Magentic lets a manager agent plan and delegate. Microsoft Agent Framework builds all five.
- Autonomy with approvals. Reads are safe, writes are not. A tool marked approval required pauses the run until a person decides. A hard limit in code blocks what no one should approve, whatever the model says.
- Monitor and debug agent runs. Agent evaluators read the whole run: intent resolution, tool call accuracy and task adherence. Error analysis groups the failing rows, such as a made-up tool argument, and points to the fix.
- Tune prompts and parameters. Instructions shape tone and rules, a few-shot example shows the format, temperature and top_p change how adventurous the wording is, and max output tokens caps length. A self-critique loop drafts, checks against a checklist and revises once.
- Trace every call and count tokens. OpenTelemetry spans record each agent run, model call and tool call, with tokens and latency, and Application Insights stores them. Tracing is opt-in, and recording message content is for development only because it captures prompts and answers.
- Route requests to the right model. A hybrid design puts rules first for answers code can decide, a small model for easy language work and a large or reasoning model only when needed. A model router can pick for you. Fewer big-model calls means a lower bill and faster replies.
A customer was charged twice and hasn't received the order. Run specialist agents in three patterns, then let a refund agent act with a person approving every refund and a hard limit in code.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
A helpful agent refunded ₹64,990 from a vague message, and nobody was asked.
😊 THE SOLUTION
Require approval for write actions and enforce hard limits in code.
- Money moves unchecked✓ Approval required on the tool
- Amounts nobody should approve✓ A hard limit inside the tool
- Who said yes?✓ The trace records the decision
Start with a question
Would you let a new hire send refunds without asking anyone?
Not on day one. They can look up orders freely. For a refund they check with a manager, and there’s a company rule that no one can refund more than a set amount without finance, however polite the customer is.
That’s how to run an autonomous agent. Reads are free, risky writes need a person’s approval, and some limits are rules in code that nobody can talk their way around.
Explain it like I’m 10
The technical explanation
Levels of autonomy
| Tool kind | Example | Control |
|---|---|---|
| Read-only | lookup_order | Runs freely, logged |
| Low-impact write | Add a note to a ticket | Allowed with limits and logging |
| High-impact write | issue_refund | Approval required |
| Beyond policy | Refund over ₹20,000 | Blocked in code |
Approval in code
In Microsoft Agent Framework a tool opts in to approval with approval_mode:
@tool
def lookup_order(order_id: Annotated[str, "Order number"]) -> str:
'''Read-only: order total, items and delivery status.'''
@tool(approval_mode="always_require") # pauses the run until a person decides
def issue_refund(order_id: Annotated[str, "Order number"], amount_inr: Annotated[int, "Amount in rupees"]) -> str:
'''Write action: send money back to the customer.'''
if amount_inr > 20000: # hard limit in code, whatever the model says
raise ValueError("Refunds over ₹20,000 go to the finance team")
When the agent decides to call issue_refund, the run pauses and returns a pending approval request with the exact arguments. Your app shows it to a reviewer and sends back an approval response, either approve or reject, and the run continues. A rejected call never runs. Foundry Agent Service has the same idea for remote MCP tools through a require_approval setting, so the model’s request waits for your decision.
Safeguards around the approval
- Least privilege. Give the agent only the tools the job needs, and limit what each tool can do.
- Hard limits in code. Maximum amounts, allowed recipients and allowed fields are checked inside the tool.
- Run limits. Cap the number of steps, the time and the tokens per run so a loop can’t run away.
- Guardrails. A guardrail can check what the agent sends to a tool and what comes back.
- Traces. Log the tool call, arguments, approver and decision. That’s the audit trail.
An approval is a judgement call by a person. It isn’t a substitute for a limit, because a tired reviewer can click yes.
Architect level Autonomous is a spectrum
Human in the loop means a person approves before each risky action. Human on the loop means the agent acts and a person monitors and can step in. Full autonomy means neither. Move along the spectrum only as far as your evaluation results and risk tolerance allow: start with approval on every write, measure how often reviewers change the outcome, and relax the rule for tools that prove safe, never for tools whose mistakes can’t be undone.
Real-world business scenario
Contoso Retail (fictional)
- The problem
- A helpful refund agent processed ₹64,990 from a vague message, because the only protection was a sentence in its instructions.
- What they used
- A refund agent on Microsoft Agent Framework: lookup_order runs freely, issue_refund is approval required with a hard limit of ₹20,000 in code, run limits on steps and tokens, and traces for every tool call and decision.
- Why that choice
- Small refunds get a quick human check, large ones go to finance automatically, and each decision is recorded with the approver.
- The result
- Wrongly processed refunds stopped, and the finance audit took minutes because the traces showed every approval.
When to use it and when not to
✓ Use it when…
- The agent can change data or move money.
- A mistake would be costly or hard to undo.
- You need to show an auditor who decided.
✕ Think twice when…
- Approval on every read, which slows people for no benefit.
- Using approvals instead of limits for absolute rules.
- Full autonomy before you have evaluation results.
↔ Alternatives to consider
- Hard limits in code for rules with no exceptions.
- Guardrails to check tool calls and responses.
- A fixed workflow when no model judgement is needed.
Test yourself with exercises
5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner Why not let the agent do everything itself?
Model answer
Reading an order is harmless, but sending money isn't. A model can misunderstand a message, so for actions with real impact I want a person to say yes first.
Intermediate What is the difference between an approval and a hard limit?
Model answer
An approval asks a person to decide a judgement call, and the person can say yes. A hard limit is code that refuses outright, such as a refund over ₹20,000 going to finance, so nobody can approve it by mistake.
Experienced developer How do you design the levels of autonomy?
Model answer
I classify tools by impact. Read-only tools run freely. Reversible, low-value writes can run with limits and logging. High-impact or irreversible writes require approval. Anything beyond policy is blocked in code. I also cap steps, time and cost per run.
Scenario An auditor asks who approved a refund last Tuesday. How do you answer?
Model answer
From the trace. It records the tool call, the arguments, the approval request and the decision with the approver and time. That's why I log approvals, not just the final result.
Quick revision
Key points
- Reads can run freely; writes with impact need approval.
- Approval pauses the run until a decision is returned.
- Hard limits in code hold even if an approver errs.
- Limit tools, steps and cost for autonomous runs.
- Traces record who decided what.
Important terminology
- Approval flow
- A pause in an agent run until a person approves or rejects a pending tool call.
- Approval required
- A tool setting such as approval_mode="always_require" that stops the run at that tool.
- Hard limit
- A rule in code, such as a maximum refund, that applies whatever the model or reviewer decides.
- Least privilege
- Giving the agent only the tools and access it needs for its job.
- Human in the loop
- A person approves each risky action before it runs.
- Audit trail
- A record of tool calls, arguments and decisions that can be reviewed later.
Common mistakes
- Relying on the prompt to enforce a business limit.
- Approving every read, which adds friction with little risk reduction.
- No record of approvals.
Exam tips
- "Pause before money moves" = approval required on the tool.
- "Never above a legal limit" = enforce in code.
- "Show who approved" = trace and audit log.
Five quick revision questions
-
1.What pauses a run for a person?Show
A tool marked approval required.
-
2.Where do absolute limits belong?Show
In the tool code.
-
3.What resumes a paused run?Show
An approval response (approve or reject).
-
4.Which tools usually need approval?Show
Write tools with real impact.
-
5.What gives an audit record?Show
Traces of tool calls and decisions.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Monitor, Evaluate and Debug Agents
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.