Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 20 of 39
❮Prev Next❯

Autonomous Agents with Safeguards and Approvals

Module 2: GenAI & Agents ⏱ 12 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: Require approval for a risky tool Mark a tool as approval required and review a pending request.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    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
    1. Reads can run freely. issue_refund moves money, so set it to always require approval. The run stops at that call and waits.
    2. A paused run appears as a pending request with the exact arguments. The reviewer sees what would happen before it does.
    3. Approve or reject. The run resumes either way, and the decision is recorded.
    4. 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.

    😟 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
    🛠️ Solved with: Approval flows and guardrail code

    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 kindExampleControl
    Read-onlylookup_orderRuns freely, logged
    Low-impact writeAdd a note to a ticketAllowed with limits and logging
    High-impact writeissue_refundApproval required
    Beyond policyRefund over ₹20,000Blocked 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

    1. Least privilege. Give the agent only the tools the job needs, and limit what each tool can do.
    2. Hard limits in code. Maximum amounts, allowed recipients and allowed fields are checked inside the tool.
    3. Run limits. Cap the number of steps, the time and the tokens per run so a loop can’t run away.
    4. Guardrails. A guardrail can check what the agent sends to a tool and what comes back.
    5. 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

    Retail

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    An agent can issue refunds. A person must decide before any refund is sent.

    What should you configure?

    Question 2

    Question 2 of 5

    Policy states a refund above ₹20,000 must never be issued by the agent, whatever a reviewer says.

    Where should you enforce the limit?

    Question 3

    Question 3 of 5

    An auditor asks who approved a refund and when.

    What should have been captured?

    Question 4

    Question 4 of 5

    An agent has two tools: lookup_order, which reads data, and issue_refund, which moves money.

    Which tools should normally require approval?

    Question 5

    Question 5 of 5

    A run is paused with a pending approval request.

    What must the application do to continue the run?

    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. 1.What pauses a run for a person?Show

      A tool marked approval required.

    2. 2.Where do absolute limits belong?Show

      In the tool code.

    3. 3.What resumes a paused run?Show

      An approval response (approve or reject).

    4. 4.Which tools usually need approval?Show

      Write tools with real impact.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.