Why Grounding Is Not a Simple Switch
Two employees ask the same HR agent a few minutes apart. The first asks how many hours of vacation they accrue per month. The second looks for where to find the official code of conduct. These two questions seem identical. They are not. One needs a synthesized and reliable answer. The other wants a direct link to the right document, without interpretation.
Designing for one of the two scenarios makes the other unsatisfying. This is precisely where documentary agent projects become complex. In practice, grounding is a spectrum: from classic search without agent code, to a forced-anchor agent that synthesizes answers when the situation requires it.
This article describes five operational retrieval patterns for an "Ask HR" agent built on Copilot Studio, Azure AI Search, and Foundry IQ. Each pattern comes with its code in the demonstration repository foundry-copilot-hr-policy-knowledge. The five patterns share the same underlying index: no reindexing is necessary to move from one to another.
Repository Scope
This repository is a learning and experimentation support tool. It is not designed for production deployment. Consult the Azure Well-Architected Framework before any production rollout (reliability, security, costs, operations).
One Index, Five Entry Points
The demonstration corpus groups internal HR policy documents: vacation accrual, recruitment rules, code of conduct, health procedures, and more. The common foundation is an Azure AI Search index named hr-policy-index, fed by an indexer and skillset that chunk and vectorize documents.
Patterns A, C, and the Hosted Agent query this index directly. Patterns A2 and B add a Foundry IQ knowledge base named hr-knowledge-base on top of the same index. This layering is the key to architecture: retrieval assets remain decoupled from the orchestration layer. It is thus possible to start with the simplest pattern, validate business value, then progress to a more elaborate pattern without touching the indexing pipeline.

The Decision Tree in Three Questions
Before choosing a pattern, it is worth clarifying two retrieval concepts used throughout this article:
- Classic search (index-first): a hybrid query (keywords + vectors) against the Azure AI Search index, ranked and returned. Fast and predictable.
- Agentic retrieval: the knowledge base plans multiple sub-queries in parallel from the user's question, reorders results, and merges them before the agent composes its answer. Superior quality on complex, multi-part questions.
Once these definitions are established, choosing a pattern comes down to three practical questions:
Q1 — Is the user looking for an answer or a document? If they need the document, route to a locator. If they need the policy to be explained or summarized, opt for synthesis.
Q2 — Is an LLM agent really necessary? If not, stick with classic search (Pattern A) or agentic retrieval via the knowledge base (Pattern A2). If yes, move to the agent layer.
Q3 — Should the agent run in Foundry or in your own infrastructure? Foundry manages the runtime → Pattern B. You manage the runtime → Hosted Agent.
Reading the Tree
Q1 determines the type of experience (location vs. synthesis). Q2 decides whether an LLM agent is justified. Q3 concerns only runtime hosting, not the user interface: Copilot Studio can remain the entry point in both cases.
Pattern A — Direct Classic Search, Without Agent Code
This is the recommended starting point. Copilot Studio queries hr-policy-index directly via its native Knowledge action. No agent code runs in the response path. The project has only the index, the skillset, and the indexing pipeline.
To populate the index, run the following script (the server-side indexer handles chunking and vectorization):
1uv run python scripts/index_knowledge_base_integrated_vectorization.py2# Builds hr-policy-index; a client-side alternative exists for development/testAdvantages: very low latency (approximately 1-2 seconds in the demonstration repository), no LLM cost in the retrieval path, and native citation cards. When source documents carry a blob_url or metadata_storage_path field, Copilot Studio can display a clickable card to the document. For many "where is the policy?" type questions, this is sufficient.
Limitation to know: Pattern A remains classic search. It does not force synthesis. If Copilot Studio paraphrases a policy from retrieved fragments, the result may be close but not precise enough. For HR policies, the exact wording can have legal implications. If wording precision is critical, move to Pattern B.
Pattern A2 — Copilot Studio Connected to Foundry IQ (Agentic Retrieval, Without Prompt Agent)
This pattern is for teams who want better retrieval quality without assuming the operational burden of a full prompt agent. In the preview of the new Copilot Studio agent experience, an agent connects directly to a Foundry IQ knowledge base via Microsoft IQ, without an intermediary Foundry prompt agent.
The same hr-knowledge-base is reused on top of hr-policy-index (a single command: python -m src.agents.create_foundry_agent). Retrieval becomes agentic: the knowledge base plans sub-queries, retrieves in parallel, re-ranks, and passes merged results to the agent.
The connection in Copilot Studio is done in a few clicks (detailed procedure on Microsoft Learn):
Open the Foundry IQ Connection
In Copilot Studio, go to Build → Microsoft IQ → Foundry IQ → Create new connection.
Configure Authentication
Choose Microsoft Entra ID Integrated as the authentication method. This choice enables result filtering by ACL: each user only sees content they have access to.
Select the Knowledge Base
Select hr-knowledge-base from the list of available sources.
Add to Agent
Click Add to agent to finalize the connection.
Why move from A to A2? First, agentic quality is obtained without deploying or maintaining a prompt agent. The knowledge base becomes the reusable asset you improve in Microsoft Foundry, independent of each Copilot Studio agent. Next, with Microsoft Entra ID Integrated authentication, results are filtered by ACL per user.
Enterprise-Readiness
Foundry IQ knowledge bases can inherit enterprise controls: customer-managed keys, network isolation, and Microsoft Entra ID. A single knowledge base can federate multiple data sources in parallel.
Pattern B — Foundry Agent Service with Forced Anchoring
When answers must be synthesized and anchored, publish a prompt agent in Microsoft Foundry via Foundry Agent Service. In the demonstration repository, the agent uses an MCPTool pointing to the knowledge base endpoint, with tool_choice="required" to force the model to retrieve policy fragments before answering.
1# src/agents/hr_policy_agent.py (excerpt)2agent = PromptAgentDefinition(3 model=model_deployment_name, # e.g. gpt-5-mini4 instructions=HR_POLICY_INSTRUCTIONS,5 tools=[mcp_tool], # MCP endpoint of the KB6 tool_choice="required", # mandatory retrieval before response7)Invocation is performed via the OpenAI client provided by the project:
1client = project.get_openai_client()2response = client.responses.create(3 input="How does PTO accrue for a new hire?",4 extra_body={"agent_reference": {"name": agent_name}},5)What you get: synthesized answers with anchoring and inline citations in the format [Policy XXXX - Title], all from a single SDK call on a managed runtime.
The tradeoff to accept: synthesis takes longer. In the demonstration repository, responses take approximately 10-14 seconds versus 1-2 seconds for classic search. For policy explanations, this delay can be justified: the user receives a composed and anchored answer rather than a list of fragments.
Pattern C — Dual-Tool Routing for Deterministic Locators
Some questions do not require synthesis: they simply need the right URL, quickly. Pattern C allows Copilot Studio to route each request based on its intent:
- "Where is the vacation policy?" →
POST /api/lookup, a deterministic endpoint without LLM (approximately 1-2 seconds), which returns the document URL verbatim in the response body. - "How many hours of vacation do I accrue?" → delegation to Pattern A or B for a synthesized answer.
1POST /api/lookup2{ "query": "PTO policy" }3→ 200 OK4{ "policy_id": "12345", "title": "Types of Leave: Paid Time Off (PTO)",5 "blob_url": "https://.../12345-pto.pdf" }Use Pattern C when Copilot Studio's native citations are insufficient: URL printed directly in the response body, deterministic and auditable output, or document source incompatible with the native citation mechanism. The endpoint is defined in src/backend/main.py:/api/lookup, with its OpenAPI contract in copilot/openapi-lookup-v2.json.
Hosted Agent — The Same Agent on Your Own Runtime
If your organization requires controlling the request processing loop, integrating custom authentication, satellite services, or maintaining infrastructure within your own security perimeter, the Hosted Agent is the answer. It is the self-hosted version of the same concept: a container built on Microsoft Agent Framework with FoundryChatClient.
It supports both retrieval modes via a single environment variable RETRIEVAL_MODE:
| RETRIEVAL_MODE | Strategy | Retrieval Type |
|---|---|---|
| tool (default) | Custom @tool search_hr_policies (hybrid + semantic) | Classic search |
| context-semantic | AzureAISearchContextProvider before each turn | Classic search |
| context-agentic | AzureAISearchContextProvider on hr-knowledge-base | Agentic retrieval |
The context-* modes use the RAG context provider integrated into Agent Framework. Retrieval runs automatically before each model call, with standardized context and citation prompts. The agent does not need to explicitly call a search tool. Copilot Studio can remain the user entry point: Q3 concerns only the location of the request loop, not the interface.
Choose Your Pattern: Summary Table
| Pattern | Orchestrator | Retrieval | Latency (demonstration) | Ideal For |
|---|---|---|---|---|
| A | Copilot Studio | Classic | ~1-2 s | Startup, native citations, without agent code |
| A2 | Copilot Studio → Foundry IQ | Agentic | ~2-4 s | Agentic quality without maintaining an agent |
| B | Foundry Agent Service | Classic/agentic via MCP | ~10-14 s | Synthesis with forced anchoring in Foundry |
| C | Copilot Studio (router) | None for lookup | ~1-2 s | Deterministic locators and verbatim |
| Hosted | Agent Framework Container | Classic + agentic | ~10-14 s | Self-hosted runtime, custom auth |
Reading this table follows a progression logic: start with A, move up to A2 for agentic quality without operating an agent, choose B when every answer must be synthesized and anchored in Foundry, add C for high-volume lookup traffic, and opt for the Hosted Agent if the runtime must stay in your own infrastructure.
Patterns Are Cumulative
A mature agent often routes location requests to C and content questions to A2 or B. These patterns are not mutually exclusive.
References and Resources
Copilot Studio and Foundry IQ
- Connect Foundry IQ to a Copilot Studio Agent
- Foundry IQ FAQ
- What Is Foundry IQ?
- Connect a Foundry IQ Knowledge Base to Foundry Agent Service
Azure AI Search and Retrieval
- Agentic Retrieval Overview
- RAG and Generative AI in Azure AI Search
- Hybrid Search
- Semantic Ranking
- Quickstart: Agentic Retrieval
- Tutorial: End-to-End Agentic Retrieval Pipeline
- Create a Knowledge Base
Foundry Agent Service and Agent Framework
Governance
Demonstration Repository



