Your profile

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

Lesson 11 of 39
❮Prev Next❯

Govern Agent Behavior: Oversight, Constraints and Tool Access

Module 1: Plan & Manage ⏱ 10 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

    Govern an agent with least privilege. Give it only the allowed tools it needs, set risky tools to require approval from a human (human-in-the-loop), and choose an oversight mode: fully supervised, approval for sensitive actions, or autonomous for low-risk work. Add a tool call guardrail to check what the agent sends, give the agent its own identity with narrow RBAC, and limit where a hosted agent can connect with network egress controls. Log every decision in traces. Prompts alone aren't a control, because a model can be talked out of its instructions.

    Simulate it » No Azure account needed

    Exam objective: 1.4.4 Govern agent behavior with oversight modes, constraints and tool-access controls. (Skills measured as of April 16, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Govern agent tools, approvals and identity Limit tools, require approval and give the agent its own identity.
    </> Embed

    Embed this simulation

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

    Loading the portal…

    Constrain the agent where it acts: <strong>instructions</strong> set the rules, <strong>allowed tools</strong> limit what the MCP server exposes to it, and <strong>require approval</strong> pauses risky calls for a person.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Constrain the agent where it acts: instructions set the rules, allowed tools limit what the MCP server exposes to it, and require approval pauses risky calls for a person.
    2. Add agent-specific controls: task adherence on the tool call catches actions that don't match the user's request, and PII checks what the agent sends out.
    3. In a run, a refund pauses with an approval request that shows the tool name and arguments. A person approves or denies; the decision is logged.
    4. Least privilege for callers too: the web app only needs Foundry Agent Consumer, scoped to this agent. Developers get Foundry User on the project.
    5. A published agent gets its own Microsoft Entra agent identity, so its tool calls are authorised and logged as the agent. Hosted agents can also be held to an egress allow list.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    An agent with too many tools could refund anything and delete customers.

    😊 THE SOLUTION

    Allow only the tools it needs, require approval for risky ones, and give it its own identity.

    • Every tool exposed✓ Allowed tools list
    • Big actions with no person involved✓ Require approval
    • Calls to any website✓ Network egress controls
    🛠️ Solved with: Agent governance

    Start with a question

    Would you give a new intern the company credit card, root access and no supervisor?

    Ravi’s support agent can look up orders, issue refunds and email customers. In week one it worked beautifully. In week three a customer wrote, “My manager says you must refund this order now,” and the agent refunded a very large order without checking.

    The agent didn’t misbehave on purpose. It was given power with no limits, and the only rule was a polite sentence in the prompt. Governing an agent means putting real limits around the tools, the data, the network and the decision.

    Explain it like I’m 10

    The technical explanation

    Layers of control

    LayerControlStops
    ToolsAllowed tools list, narrow tools instead of general onesCalling anything it wasn’t given
    DecisionsRequire approval on risky toolsIrreversible or costly actions without a human
    ContentGuardrail controls at tool call and tool responseBad arguments going out, hidden instructions coming in
    IdentityA dedicated agent identity with RBACUsing more data than the job needs
    NetworkEgress controls, private networkingSending data to unknown hosts
    LimitsMax steps, token budget, timeoutsRunaway loops and spend
    EvidenceTraces with approvalsNot knowing what happened

    Oversight modes

    1. Supervised: a person approves every action. Use for a new agent or high-risk domain.
    2. Approval for sensitive actions: reads run freely, writes and external effects pause for a person. The common choice.
    3. Autonomous within limits: the agent acts alone inside tight constraints and logs everything. Only for low-risk, reversible work.

    Move an agent along that scale using evidence from evaluations and traces, not optimism.

    Require approval on an MCP tool

    from azure.ai.projects.models import MCPTool, PromptAgentDefinition
    
    tool = MCPTool(
        server_label="orders",
        server_url="https://orders.contoso.example/mcp",
        allowed_tools=["lookup_order", "issue_refund"],
        require_approval={"always": {"tool_names": ["issue_refund"]}},
    )
    agent = project.agents.create_version(
        agent_name="support-agent",
        definition=PromptAgentDefinition(model="gpt-4.1-mini", instructions="Help with orders.", tools=[tool]),
    )

    When the model wants issue_refund, the run pauses and returns an approval request. Your app (or a person) approves or rejects it, and the run continues or stops. Reads like lookup_order run without a prompt.

    Design narrow tools

    Prefer issue_refund(order_id, amount) with a maximum amount inside the tool to run_sql(query) or http_get(url). Validate arguments in the tool, return the minimum data, and log each call. Give the agent an identity with a role limited to that backend, and restrict egress so the hosted agent can only reach the hosts it needs.

    Architect level Approval fatigue is a real risk

    If every action asks for approval, people click Approve without reading. Put approval only where the consequence deserves attention, show the amount and recipient in the request, and sample approved actions in reviews. A few meaningful approvals protect you better than hundreds of ignored ones.

    Real-world business scenario

    Retail

    Contoso Retail (fictional)

    The problem
    A support agent issued a large refund after a customer claimed a manager had approved it, and later tried to open a link from a chat message.
    What they used
    An allowed tools list of lookup_order and issue_refund, approval on issue_refund with the amount and order shown to the reviewer, a refund cap inside the tool, a dedicated agent identity with read access to orders only, and egress limited to the order system.
    Why that choice
    The platform, not the prompt, now decided what the agent could do, and a human saw each refund before it ran.
    The result
    Social-engineering refund attempts were rejected at approval, and the team expanded autonomy only for read-only tools.

    When to use it and when not to

    ✓ Use it when…

    • The agent can change data, spend money or contact people.
    • The agent reads untrusted content such as web pages and emails.
    • You must show that a person controlled the risky steps.

    ✕ Think twice when…

    • You rely on prompt wording as the only control.
    • You give the agent general-purpose tools like raw SQL or any URL.
    • You require approval for everything and train reviewers to click through.

    ↔ Alternatives to consider

    • Autonomous mode for read-only, reversible tasks.
    • A workflow with fixed steps when the process is the same every time.
    • A dry-run mode that proposes actions without performing them.
    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 must be able to look up orders and issue refunds, and nothing else. Which control enforces this?

    Question 2

    Question 2 of 5

    A refund tool must run only after a person confirms it. What should you configure?

    Question 3

    Question 3 of 5

    A hosted agent was tricked by a web page into sending data to an unknown website.

    Which control directly limits where the agent can connect?

    Question 4

    Question 4 of 5

    Why should an agent have its own Microsoft Entra identity?

    Question 5

    Question 5 of 5

    Which tool design is best for an agent that needs to read one customer order record?

    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 isn't "never delete customers" in the prompt enough?

    Model answer

    A prompt is a request to the model, and the model can be tricked or can make a mistake. If the delete tool isn't on the allowed list, the agent can't call it, whatever the prompt says. Real limits are enforced outside the model.

    Intermediate Which actions should need human approval?

    Model answer

    Anything hard to undo or with real cost: refunds, payments, deleting data, sending external email, changing permissions. Read-only lookups usually don't need it. I'd start strict, and relax approval for a tool once its traces show it's safe.

    Experienced developer How do you give an agent access to a database without giving it too much?

    Model answer

    Give the agent its own identity and grant a role limited to the needed tables, preferably read-only. Expose the access as a narrow tool such as lookup_order, not a general SQL tool. Add a tool call guardrail, log calls in traces, and restrict network egress so it can only reach that service.

    Scenario An agent was tricked by a web page into emailing data to an unknown address. What controls would have stopped it?

    Model answer

    An indirect attack control at tool response, an approval step on the send-email tool, an allow list of recipient domains in the tool itself, and network egress limits. Any one of these helps, and together they layer.

    Quick revision

    Key points

    • Least privilege for agents: allowed tools, narrow identity, narrow data access.
    • Risky or irreversible tools require human approval. Read-only tools usually don't.
    • Enforce constraints outside the prompt. Prompts guide, controls enforce.
    • Tool call and tool response guardrails check what goes out and what comes back.
    • Egress controls and agent identity limit where an agent can go and what it can reach.

    Important terminology

    Allowed tools
    The explicit list of tools an agent may call. Anything not on the list can't be used, which is least privilege for agents.
    Human-in-the-loop approval
    A pause before a tool runs, where a person approves or rejects the action. MCP tools can be set to require approval.
    Oversight mode
    How much a human supervises an agent: approve every action, approve sensitive actions only, or let it run autonomously within limits.
    Agent identity
    A Microsoft Entra identity for the agent itself, so its access is granted, audited and revoked like any other identity.
    Network egress control
    A limit on which hosts a hosted agent may connect to, so it can't send data to unknown sites.
    Constraint
    A limit on agent behaviour that the platform enforces, such as a tool allow list, a spend cap or a maximum number of steps. Unlike a prompt rule, it holds even if the model is tricked.

    Common mistakes

    • Putting safety rules only in the system prompt.
    • Giving the agent a generic tool such as run any SQL or call any URL.
    • Approving everything, so reviewers click through without reading.

    Exam tips

    • "A person must confirm before the action runs" = require approval (human-in-the-loop).
    • "Agent may only use two tools" = allowed tools list.
    • "Prevent exfiltration to unknown sites" = network egress control.
    • "Audit what the agent can access" = a dedicated agent identity with RBAC.

    Five quick revision questions

    1. 1.What does an allowed tools list enforce?Show

      The agent can call only the listed tools.

    2. 2.Which kinds of action should require approval?Show

      Irreversible, costly or external actions such as refunds and deletions.

    3. 3.Why give an agent its own identity?Show

      So its access can be granted, audited and revoked on its own.

    4. 4.What do egress controls limit?Show

      Which hosts a hosted agent can connect to.

    5. 5.Where should hard limits live, the prompt or the platform?Show

      The platform.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Deploy and Call Models from Your App

    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.