TechExplainedTechExplained
|
Best PracticeLevel: Intermediate

Building grounded agents with Microsoft Foundry: model choice, permissions and evaluations

Why an agent without groundedness evaluation and access control hallucinates and leaks data, and how model choice, content safety, identity and tracing prevent it.

TechExplained 3 min readPublished: 26 juli 2026Last updated: 26 juli 2026
#foundry#grounding#evaluations#agents#content safety
01

Grounding is only as safe as the permissions behind it

A RAG agent that answers from a knowledge base is only safe once the retrieval layer enforces the same access restrictions as the source itself. An index that makes every document searchable without regard for who has which rights gives every user access, through a simple question, to information they would never have seen through the original source. Permission trimming in retrieval is therefore not an add-on applied afterward, it is a condition before the first index is ever built.

02

Choose the model per task, not one model for everything

Not every step in an agent flow needs the heaviest, most expensive model. Simple classification or extraction tasks run perfectly well on a smaller, faster model, while complex reasoning with multiple trade-offs deserves a stronger model. Using one model for every step is the simplest choice to build, but unnecessarily drives up cost and latency for the majority of interactions that never needed a heavy model in the first place.

03

Measure groundedness before production, not afterward

An answer that sounds convincing but is not based on the retrieved context is not a minor mistake in an enterprise context, it is a hallucination that undermines trust in the entire solution. Groundedness evaluation therefore belongs as a mandatory gate in the CI/CD flow, alongside relevance, coherence and safety evaluations, with a defined quality threshold before a new version reaches production.

04

Turn on content safety against prompt injection and sensitive content

User input, and certainly input from external parties such as customers, is an untrusted source. Prompt shields detect and block attempts to reason an agent outside its instructions through carefully crafted input, groundedness detection flags ungrounded output, and PII filters prevent sensitive personal data from ending up unfiltered in an answer. These guardrails should be on before the first user reaches the agent, not as a reaction to the first incident.

05

Give agents their own identity and least-privilege access

An agent without its own identity is not auditable: nobody can later determine which action was performed by which agent, in which context. An Entra Agent ID gives every agent a traceable identity, and least-privilege tool permissions ensure an agent only has access to exactly the actions its task requires, nothing more.

06

Choose a deployment type deliberately for predictable cost and latency

Serverless capacity fits variable volume and keeps costs low during quiet periods, but offers no guarantees during unexpected spikes. Provisioned Throughput reserves throughput for predictable latency under constant load, at a fixed cost base. The wrong choice results in throttling where predictability was needed, or unnecessary cost where variability is the norm.

07

Build in tracing from day one

A problem in a multi-step agent run is only reproducible with end-to-end tracing of prompts, tool calls and runs. Without that visibility, an incident remains an anecdote instead of a diagnosable problem. Online evaluation on production traffic adds to this by continuously monitoring quality, safety and cost instead of only at release time.

08

The most common mistake: rolling out without a groundedness gate

The most common and most damaging mistake is bringing an agent to production without groundedness evaluation, assuming a well-written system instruction is enough to prevent hallucination. In practice, organizations only discover this once a user passes on a convincing but incorrect answer to a customer or colleague. Groundedness evaluation as a mandatory gate, with an instruction to refuse below the retrieval threshold, prevents this scenario from playing out in production instead of in a test environment.

The process at a glance

Click a step for its key decision

Summary

Grounding is only as safe as the permissions behind it

A RAG agent that answers from a knowledge base is only safe once the retrieval layer enforces the same access restrictions as the source itself. An index that makes every document searchable without regard for who has which rights gives every user access, through a simple question, to information they would never have seen through the original source. Permission trimming in retrieval is therefore not an add-on applied afterward, it is a condition before the first index is ever built.

Production Readiness Checklist

Before you go live, verify these production recommendations.

  • Retrieval enforces source permissions, no answers beyond what the user is already allowed to see
  • Model choice per task instead of one heavy model for every step
  • Groundedness and safety evaluation as a mandatory gate before production
  • Content safety (prompt shields, PII filters) active against prompt injection
  • Every agent has an Entra Agent ID and least-privilege tool permissions
  • Tracing and online evaluation set up before broad rollout, not afterward
Building grounded agents with Microsoft Foundry: model choice, permissions and evaluations | TechExplained