SaveMyCert
Log in
2 of 2 free questions left today·for 5 a day
Implement generative AI and agentic solutions

AI-103: Build Foundry Agents — Tools, Memory, Multi-Agent Workflows and Evaluation

25 min readAI-103 · Implement generative AI and agentic solutionsUpdated

Building an agent with Microsoft Foundry means writing an agent definition — a model deployment, instructions and tools — in Foundry Agent Service, then deciding how it tracks conversations and memory, which tools it calls (function tools, OpenAPI and MCP servers, Azure AI Search, file search, shared toolboxes), how several agents work together, where a person must approve its actions, and how you evaluate and debug what it does. This lesson covers AI-103 task 2.2 at the implementation level: the schemas, settings, SDK calls and failure modes behind each of those decisions.

What you’ll learn

  • Write agent instructions with a role, boundaries, tool decision rules and failure guidance, and use tool_choice when a tool call must be deterministic.
  • Define function tool schemas with descriptions, required, enum and strict mode, and implement the function_call / function_call_output loop correctly.
  • Choose between conversations, previous_response_id chaining and store=false, and add memory scoped per user with x-memory-user-id and TTL.
  • Configure the Azure AI Search, file search, OpenAPI and MCP tools and a shared Foundry toolbox, including authentication and their limits.
  • Build multi-agent solutions with the A2A tool and Microsoft Agent Framework orchestrations, hosted in Foundry now that the portal workflows are retired.
  • Add safeguards: MCP require_approval, approval_mode always_require, request_info and checkpoints, and background mode for long work.
  • Pick the agent evaluator that matches a failure and use trace content recording, @trace_function and agent_reference for error analysis.

The 10 parts · about 19 min of reading

  1. How do you define an agent's role, goals and boundaries?Start hereInstructions set the agent's scope, tool precedence and failure behaviour, while tool_choice on the request is what forces a tool call.2 min
  2. How do you write tool schemas for function tools?Descriptions say when a tool applies; required, enum and additionalProperties each constrain one thing, and strict mode has its own rules.1 min
  3. How does the function-calling loop work in an agent?The app answers every function_call by call_id in one request; the portal can't run functions, and runs expire after 10 minutes.2 min
  4. How do you choose a conversation-tracking approach?Conversations store every item, previous_response_id chains stored responses, and store=false leaves all history in your app.1 min
  5. How do you add conversation memory to an agent?Memory stores keep facts and summaries across sessions; {{$userId}} scope needs x-memory-user-id when a backend uses one shared identity.2 min
  6. How do you integrate retrieval with Azure AI Search and file search?The search tool targets one index with query_type, top_k and an OData filter; file search uses vector stores that ingest asynchronously.2 min
  7. How do you integrate APIs, MCP servers, content understanding and shared tools?OpenAPI tools need 3.x specs and connection-held keys, MCP tools reject anyOf schemas, and toolboxes share tools across agents.3 min
  8. How do you implement orchestrated multi-agent solutions?The A2A tool lets an agent delegate yet keep the user; Agent Framework patterns such as handoff and magentic orchestrate agents in code.2 min
  9. How do you build semiautonomous workflows with safeguards and approvals?Platform gates guard risky steps: require_approval on MCP tools, approval_mode on functions, request_info for input, checkpoints for waits.2 min
  10. How do you monitor, evaluate and analyze errors in deployed agents?Agent evaluators score intent, adherence and each tool-use step, while traces with content capture and @trace_function show where runs fail.2 min

Mind map

Instructions set scope and declineswith a pointerPrecedence rules for overlapping toolstool_choice=required forces a call,not a choiceMany unrelated tools: split intospecialists1✓Role, goals andboundariesDescriptions say when to use it, withformatsenum limits values; required makesthem mandatoryStrict: all properties required, noextrasOptional strict field: null union type2✓Function tool schemasThe service never runs your functionsMatch outputs on call_id, all in onerequestThe portal playground can't executefunctionsRuns expire after 10 minutes3✓Function-calling loopConversation object stores every itemprevious_response_id chains storedresponsesPersist nothing: store=false, appkeeps historyLong chats are truncated, not trimmed4✓Conversation trackingStores keep facts and summaries acrosssessions{{$userId}} reads x-memory-user-id,else Entra IDsShared backend identity must send eachuser's IDTTL only on stores created after TTLsupport5✓Conversation memoryOne Azure AI Search tool per indexOData filter enforces hardrestrictionsKeyless: Foundry identity needs twosearch rolesFile ingestion is async; poll beforetesting6✓Search and file retrievalOpenAPI 3.0/3.1, simple operationIds,JSON bodiesAPI keys live in project connectionsMCP rejects anyOf, allOf andmulti-type paramsToolboxes can't hold function tools7✓APIs, MCP and toolboxesA2A: caller keeps the user; handofftransfersCallers need Foundry Agent Consumer ontargetSequential, concurrent, group chat,magenticPortal workflows retired 1 Dec 20268✓Multi-agent orchestrationEnforce gates in the platform, not theprompt{"never": [...]} gates every unlistedtoolapproval_mode="always_require" perfunctionCheckpoints make long approval waitsdurable9✓Safeguards and approvalsOutput Utilization: answer misusestool resultsInput Accuracy: parameters break thecontractContent capture env var must be setfirst@trace_function records argumentsalways10✓Monitoring and errorsFoundry agents,tools andmulti-agent
Mind map

AI-103: Build Foundry Agents — Tools, Memory, Multi-Agent Workflows and Evaluation

Instructions set scope and declineswith a pointerPrecedence rules for overlapping toolstool_choice=required forces a call,not a choiceMany unrelated tools: split intospecialists1✓Role, goals andboundariesDescriptions say when to use it, withformatsenum limits values; required makesthem mandatoryStrict: all properties required, noextrasOptional strict field: null union type2✓Function tool schemasThe service never runs your functionsMatch outputs on call_id, all in onerequestThe portal playground can't executefunctionsRuns expire after 10 minutes3✓Function-calling loopConversation object stores every itemprevious_response_id chains storedresponsesPersist nothing: store=false, appkeeps historyLong chats are truncated, not trimmed4✓Conversation trackingStores keep facts and summaries acrosssessions{{$userId}} reads x-memory-user-id,else Entra IDsShared backend identity must send eachuser's IDTTL only on stores created after TTLsupport5✓Conversation memoryOne Azure AI Search tool per indexOData filter enforces hardrestrictionsKeyless: Foundry identity needs twosearch rolesFile ingestion is async; poll beforetesting6✓Search and file retrievalOpenAPI 3.0/3.1, simple operationIds,JSON bodiesAPI keys live in project connectionsMCP rejects anyOf, allOf andmulti-type paramsToolboxes can't hold function tools7✓APIs, MCP and toolboxesA2A: caller keeps the user; handofftransfersCallers need Foundry Agent Consumer ontargetSequential, concurrent, group chat,magenticPortal workflows retired 1 Dec 20268✓Multi-agent orchestrationEnforce gates in the platform, not theprompt{"never": [...]} gates every unlistedtoolapproval_mode="always_require" perfunctionCheckpoints make long approval waitsdurable9✓Safeguards and approvalsOutput Utilization: answer misusestool resultsInput Accuracy: parameters break thecontractContent capture env var must be setfirst@trace_function records argumentsalways10✓Monitoring and errorsFoundry agents,tools andmulti-agent

How the exam tests this

Expect Microsoft-style scenarios: a company, a Foundry agent with some tools, a symptom (a function call that never produces an answer, a 401 or 403, an "Invalid tool schema" error, memories leaking between users, a run that expires, an early detail the agent forgets) and a constraint such as least privilege, no stored history, least custom code, no redeployment, or enforcement by the platform rather than the model. Some items show a short Python snippet with a blank and ask which line or value completes it, so read SDK field names precisely rather than recognising them loosely. Others describe a failure and ask for the evaluator, orchestration pattern or tool setting that fits, and some are select-TWO items where a complete fix needs two separate changes — judge each option on whether it is necessary on its own.

Key takeaways

  1. Instructions carry the agent's role, scope, tool decision rules and what to do on empty results; tool_choice=required (set by the app) is the deterministic way to force a tool call.
  2. Strict function schemas list every property in required and set additionalProperties to false; optional fields allow null. enum restricts values, required makes a field mandatory.
  3. The app runs functions: return a function_call_output per call with the matching call_id, all outputs in one request. Runs expire after 10 minutes, so slow work returns a job status.
  4. Conversations store every item but truncate the model input past the context window; store=false with app-held history is the only option when nothing may be persisted.
  5. Memory scope {{$userId}} uses x-memory-user-id if sent, else the caller's Entra identity — a backend serving many users must send the header. TTL only applies to stores created after TTL support.
  6. Azure AI Search tool: filter applies to every query; keyless access needs Search Index Data Contributor + Search Service Contributor on the Foundry account's managed identity. File search allows one vector store per agent and per conversation.
  7. OpenAPI tools need OpenAPI 3.0/3.1, letter/-/_ operationIds and JSON bodies; API keys live in a project connection plus securitySchemes. Toolboxes share tools through one MCP endpoint but can't hold function tools.
  8. The A2A tool keeps the calling agent in charge (incoming A2A on the target, Foundry Agent Consumer for the caller); handoff transfers the user. Connected Agents isn't in the new Agent Service, and portal workflows were retired on 1 December 2026.
  9. Enforce approvals in the platform: require_approval {"never": [...]} gates everything unlisted; approval_mode="always_require" gates a function; request_info asks for input; checkpoints make waits survive restarts.
  10. Match evaluators to the failing step (Task Adherence, Tool Input Accuracy, Tool Output Utilization, Task Navigation Efficiency with matching_mode) and keep content recording to development.
0/10
Ready to start

Part 1: How do you define an agent's role, goals and boundaries?

Instructions set the agent's scope, tool precedence and failure behaviour, while tool_choice on the request is what forces a tool call.

2 min read · 10 parts, about 19 min in allStart lesson

Frequently asked questions

Does Foundry Agent Service run my function tools?

No. When the model calls a function tool, Foundry Agent Service returns a function_call item with the function name, JSON arguments and a call_id, and stops. Your application runs the function and sends a function_call_output item with the same call_id back to the agent, returning every output from one response in a single request. The Foundry portal doesn't execute function tools either, so test function calling from code.

What is the difference between a conversation and previous_response_id in Foundry agents?

A conversation is a server-side object that stores every item of a chat — messages, tool calls and tool outputs — until you delete it, and you pass its ID on each request. previous_response_id instead chains a new response to an earlier stored response. Both keep history on the service; if policy forbids that, set store to false and resend the earlier output items from your application.

How do I keep each user's agent memories separate in Foundry?

Set the memory search tool's scope to {{$userId}}. Foundry then uses the x-memory-user-id header when a request carries it and otherwise falls back to the caller's Microsoft Entra tenant and object IDs. Users who call with their own Entra tokens are separated automatically, but a backend that calls on behalf of many users with one identity must send each user's ID in x-memory-user-id.

Sign up free to mark lessons complete, bookmark topics and track your exam readiness.

Spotted a mistake in this lesson?