An agent in the Foundry sense is a long-lived configuration of a large language model, a tool catalog, a memory store, and a set of safety policies, exposed as a server-side object that owns its own conversation state. The runtime accepts a user message, plans tool calls, executes them, reads results, drafts intermediate reasoning, and returns a final answer, all without the client having to write the orchestration loop. A chat completion call, by contrast, returns one assistant turn per request: the client owns the loop, the tool routing, and the memory. A prompt flow, covered in Chapter 2, is a designer-authored DAG of typed nodes that runs once per request and exits. RAG is one specific tool inside that DAG, retrieving grounding chunks and feeding them to a single completion. None of those primitives carry forward an internal scratch pad across iterations the way an agent does.
The execution model an agent follows is sometimes shown as the ReAct cycle: reason, act, observe, repeat. In the Foundry Agent Service this cycle is materialized as a run, with run steps that record either a tool call or a message creation. The run sits on a thread, which owns the ordered messages and any thread-scoped memory. The agent itself is a stateless template, so the same agent object can host thousands of concurrent threads for thousands of concurrent users. The thread is where multi-turn memory lives, the run is where the planner spends compute, and the agent is where instructions and tool wiring are defined.
When an agent beats a chat completion call
Picking an agent over a plain chat completion call is a function of three signals. First, does the workload need more than one tool invocation to answer a single user request, with the tool choice depending on the previous tool's output? If yes, an agent saves you the loop. Second, does the workload need persistent memory across many turns spanning many sessions, with citations back to enterprise data? If yes, the Foundry Agent Service ships threads, file search, and vector stores you would otherwise have to operate yourself. Third, does the workload need built-in safety policies and tracing applied to every step of every tool call? If yes, the agent runtime applies the project content safety configuration to every model call and emits OpenTelemetry traces per run step without extra wiring.
If the workload is a single-shot generation, a single-pass RAG, or a deterministic prompt template, the chat completion path covered in Chapter 2 is cheaper, faster, and easier to evaluate. Putting a single-shot task behind an agent adds a planner round trip and a server-side thread store you do not need. The exam routinely tests this discrimination by describing an analyst that summarizes a fixed PDF on demand: that is a prompt template plus file search, not an agent.
💡 Exam Trap: A long retrieval pipeline does not by itself justify an agent. If the planner only ever calls one tool, in one fixed order, with one fixed model, the right primitive is a prompt flow or an Azure OpenAI on your data deployment, not an agent. Agents earn their cost when the planner chooses which tool to call.
Autonomy levels
Agents sit on a spectrum from copilot to autonomous. A copilot agent waits for an explicit user message before each run, surfaces its plan, and asks for confirmation before any side-effecting tool runs. An autonomous agent runs on its own schedule, triggered by an event such as a queue message, executes a goal until a halting condition fires, and reports a result asynchronously. The Foundry Agent Service supports both shapes through the same API: copilot agents drive runs interactively, autonomous agents drive runs from a worker that watches the run status field. Picking the autonomy level early is important because it determines which safety controls you need. An autonomous agent always needs an outer halting condition, a maximum step count, a budget cap, and a human review step for any irreversible action. A copilot agent inherits much of that from the user-in-the-loop pattern.
Single-agent versus multi-agent decomposition
A single agent with a rich tool catalog can solve many workloads but suffers when the instructions grow past a few hundred lines, when the tool catalog grows past about twenty entries, or when the planner has to switch between very different domains in one thread. At those scale points the Foundry recommendation is to decompose into a primary orchestrator agent and a fleet of specialized connected agents. Each connected agent has a narrow tool catalog and a focused system prompt. The orchestrator selects a connected agent the same way a single-agent planner selects a tool. The trade-off is latency: every connected agent invocation is a separate planning round, so a decomposed system pays more wall-clock time per request than a monolithic agent that ends up making the same tool calls.
Representative use cases
The most common production shapes the certification frames look like this. A customer-service triage agent reads a ticket, calls a CRM through an OpenAPI tool, retrieves account context with Azure AI Search, drafts a reply, and routes the thread to a human if confidence is below a threshold. A finance research agent grounds itself in Microsoft Fabric data through the Fabric data agent tool, generates a Python notebook through Code Interpreter, and produces a chart, with a Bing grounding call for the latest published commentary. A code reviewer agent reads a pull request through an Azure Function tool, runs static analysis through Code Interpreter, and posts review comments through an Azure DevOps OpenAPI tool. A document-intake agent uses file search over a vector store of supplier contracts to answer compliance questions and cite specific clauses. These four shapes cover most of the question variations the exam draws from.
🎯 Scenario: A retail bank wants a virtual analyst that reads the customer's portfolio from Fabric, checks the public news from Bing, and produces a one-page brief with a downloadable PDF. The planner has to pick between two data sources, run Code Interpreter for the PDF, and apply citation requirements. This is a multi-tool, multi-turn workload with a regulated output, so a single Foundry agent with Fabric, Bing grounding, and Code Interpreter tools, plus a groundedness evaluator on every run, is the right shape. Putting this behind a one-shot chat completion would force the client to write the planning loop, the citation extraction, and the tracing.
Choosing the Foundry Agent Service or the Microsoft Agent Framework
The two are not alternatives, they layer. The Foundry Agent Service is the managed runtime that hosts the agent, the threads, the vector stores, the tool integrations, and the tracing. The Microsoft Agent Framework is the open-source library you write code against. The decision tree has two clear branches. If the workload is a single agent that needs Microsoft-managed tools, managed vector store, and managed thread storage, write code against the Foundry Agent Service SDK directly. If the workload is a multi-agent system with custom orchestration logic, custom middleware, or a need to run portably across providers, use the Microsoft Agent Framework with a Foundry Agent Service backend. The Framework can also run with a plain Azure OpenAI in Foundry Models chat backend without the Agent Service, which is cheaper for purely client-side orchestration but loses managed threads, file search, and code interpreter.
⚠️ Anti-Pattern: Wrapping every chat completion call in an agent because the team standardized on the agent SDK. Agents charge the same model token rate plus a per-thread and per-run overhead, and they add a planner round trip even when the tool catalog is empty. For a stateless one-shot generation, call the chat completions client directly.
💡 Exam Trap: Items routinely present a workload that is described as agentic but in fact has one fixed tool call. The correct answer is a prompt flow or Azure OpenAI on your data, not an agent. The signal phrase is "the same retrieval pattern every time" or "no branching logic". If the planner has no choice to make, the agent runtime adds no value.
Decision Anchor
Choose the Foundry Agent Service when the workload needs managed threads, managed tool execution, server-side memory, and built-in safety on a single agent or a connected-agent fleet. Choose the Microsoft Agent Framework on top of the Agent Service when the workload needs custom multi-agent orchestration, middleware, or a portable client. Choose a plain chat completion client when there is one model call and no tool dispatch decision to make.
Comparison of Foundry agentic primitives
| Primitive | State ownership | Tool execution | Safety policies | When to choose |
|---|---|---|---|---|
| Chat completion call | Client | Client | Applied per call only | Single-shot generation |
| Prompt flow | Flow runtime | Flow runtime | Applied per node | Deterministic DAG |
| Azure OpenAI on your data | Server | Server (search only) | Applied per call | Single-shot grounded RAG |
| Foundry Agent Service agent | Server (threads) | Server (managed tools) | Applied per run step | Multi-tool, multi-turn, multi-user |
| Microsoft Agent Framework | Client or server | Client routed, server executed | Inherited from backend | Custom orchestration over agents |
📊 Limit: A Foundry Agent Service run defaults to a maximum of around 128 tool calls per run before the planner is halted, with the exact ceiling exposed as the
max_completion_tokens,max_prompt_tokens, and tool-iteration caps on the run object. Setting an explicit cap is mandatory for autonomous agents.
The takeaway from this section is that an agent is a server-managed object, not a code pattern. Decide whether the workload needs that object, decide which framework writes against it, and verify the tool catalog has enough branching for the planner to add value before picking the agent path.
