Govern Agent Behavior: Oversight, Constraints and Tool Access
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 neededExam 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.
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
- 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.
- 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.
- 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.
- Least privilege for callers too: the web app only needs Foundry Agent Consumer, scoped to this agent. Developers get Foundry User on the project.
- 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.
🖱️ Drag to rotate · scroll or pinch to zoom
Govern what the agent may do
Give the agent only the tools it needs (allowed tools), make risky tools require approval from a human, let the tool call guardrail check what it sends, and limit where a hosted agent can connect with network egress controls.
🤔 What happens if…
Read this tour as text
- Pick the right model or tool. A router in your app sends each job to the cheapest thing that does it well: a reasoning model for multistep problems, a small language model for high-volume labelling, a multimodal model for photos, and a Foundry Tool such as Content Understanding for invoices.
- Where an agent gets its facts. Curated company content lives in a Foundry IQ knowledge base on Azure AI Search. Files a user drops into the chat go to file search. What the agent learns about the user across sessions goes to memory (user profile, chat summary).
- Resource, projects and deployment types. One Foundry resource holds deployments, networking and keys. Projects inside it isolate teams. Global deployments may process anywhere, Data Zone stays in the EU or US zone, Standard stays in one region. The standard agent setup keeps threads, files and vectors in your own Cosmos DB, Storage and AI Search.
- Configure deployments and agent versions. A deployment pins a model, a model version, a deployment type, capacity (TPM) and a guardrail. An agent gets a new version every time you change it; the endpoint serves the version you choose, so you can roll back.
- CI/CD with an evaluation gate. The agent definition, prompts and Bicep live in Git. The pipeline signs in with workload identity federation (no secret), runs an evaluation on a test set, and only then promotes from dev to test to prod projects.
- Quotas, 429s, spillover and budgets. Quota is tokens per minute per model, per region, per deployment type. Each deployment gets a slice; RPM comes with it. Go over and you get HTTP 429 with a retry-after header. Provisioned throughput can spill over to a standard deployment, and a cost control can stop a project at its token budget.
- Monitor models, agents and search. Azure Monitor metrics show requests, tokens, latency and errors. Application Insights holds traces, and continuous evaluation scores a sample of live answers for groundedness and safety. For Azure AI Search, watch indexer runs, document counts, search latency and throttled queries.
- Keyless and private. The app uses a managed identity and Microsoft Entra ID tokens, with the Foundry User role on the resource. Local (key) auth is turned off. Public network access is disabled and a private endpoint in your VNet is the only way in.
- Guardrails at four intervention points. A guardrail is a set of controls: a risk (hate, violence, prompt attacks, indirect attacks, protected material, PII), the intervention point (user input, tool call, tool response, output) and the action (annotate, or annotate and block).
- Evaluate, red team and trace. Evaluators score answers: groundedness, relevance, coherence, safety, and agent ones like tool call accuracy and task adherence. The AI red teaming agent attacks before launch. Traces in Application Insights record every model call, tool call and approval for audit.
- Govern what the agent may do. Give the agent only the tools it needs (allowed tools), make risky tools require approval from a human, let the tool call guardrail check what it sends, and limit where a hosted agent can connect with network egress controls.
Before launch, Contoso needs a guardrail that stops jailbreaks and hidden instructions, evidence that quality and safety hold up, and limits on what the agent may do. Build each, then test a refund through a human approval.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 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
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
| Layer | Control | Stops |
|---|---|---|
| Tools | Allowed tools list, narrow tools instead of general ones | Calling anything it wasn’t given |
| Decisions | Require approval on risky tools | Irreversible or costly actions without a human |
| Content | Guardrail controls at tool call and tool response | Bad arguments going out, hidden instructions coming in |
| Identity | A dedicated agent identity with RBAC | Using more data than the job needs |
| Network | Egress controls, private networking | Sending data to unknown hosts |
| Limits | Max steps, token budget, timeouts | Runaway loops and spend |
| Evidence | Traces with approvals | Not knowing what happened |
Oversight modes
- Supervised: a person approves every action. Use for a new agent or high-risk domain.
- Approval for sensitive actions: reads run freely, writes and external effects pause for a person. The common choice.
- 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
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.
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 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.What does an allowed tools list enforce?Show
The agent can call only the listed tools.
-
2.Which kinds of action should require approval?Show
Irreversible, costly or external actions such as refunds and deletions.
-
3.Why give an agent its own identity?Show
So its access can be granted, audited and revoked on its own.
-
4.What do egress controls limit?Show
Which hosts a hosted agent can connect to.
-
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
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.