Home › Studies › AI-103 › Generative AI & Agents › Building Agents

Building Agents

Prompt, voice and hosted agents · conversations · function calling · tools & toolboxes · memory · workflows & A2A · approvals · tracing & evaluation

By the tools4free.dev team · Last reviewed November 13, 2026

Practice questions for this topic →

Agent types and runtime components

Agent typeYou provideFoundry managesPick it when
Prompt agentInstructions, a model and tools (configuration only)The runtime, scaling and a stable endpoint; no code, containers or compute for you to runYou want the fastest start, or a production agent without custom orchestration logic
Voice-based prompt agentModel, instructions, audio settings, optional greeting and toolsThe agent lifecycle; Voice Live handles speech recognition, turn taking and synthesisYou need real-time spoken conversations without hosting the voice orchestration
Hosted agentYour own code and framework (for example Agent Framework, LangGraph, OpenAI Agents SDK) as a container image or .zipA managed endpoint, automatic scaling and a dedicated Microsoft Entra identityYou need custom code, orchestration logic, middleware or protocols
Responses API (ephemeral agent)The definition (instructions, tools, model) in your application code on every callNo agent resource in FoundryAgent logic should ship with your app; it can't use the Copilot harness or the prompt-agent optimizer
Runtime componentRoleUse it when
AgentSupplies reusable model, instructions and tools to a responseSeveral requests need the same behavior or tool setup
ConversationSupplies persisted input and output items to responsesLater turns need server-side history
ResponseRuns a model or agent against input and produces output itemsEvery interaction: one unit of execution, with or without an agent or conversation

Tracking the conversation

Use the instructions to describe the agent's role, behavior, boundaries and expected output, and tell the model what each tool is for. If tools overlap, add a decision rule such as using File Search before Web Search for internal content.

Tools, function calling and toolboxes

Function calling flow

  1. Define function tools: name, parameters and purpose of each function.
  2. Create an agent registered with the function definitions.
  3. Send a prompt: the model requests a function call if needed.
  4. Execute and return: your app runs the function and submits the output (a function_call_output item with the call_id) back.
  5. Get the final response: the agent uses your output to finish its answer.
ToolUse it to
Function callingLet the model request your own code; your app runs it
File searchSearch user-provided documents through a vector store
Azure AI SearchGround answers in an index you own, with inline citations
Memory searchRead and write long-term memory for the user
MCPCall tools on a remote Model Context Protocol server
OpenAPICall a REST API described by an OpenAPI spec
Agent-to-agent (A2A)Call another agent through a remote A2A endpoint
Web search, code interpreterBuilt-in tools for current web information and running code

Azure AI Search tool parameters

ParameterRequiredNotes
project_connection_idYesResource ID of the project connection to Azure AI Search
index_nameYesIndex in your search resource
top_kNoDefaults to 5
query_typeNoDefaults to vector_semantic_hybrid; also simple, vector, semantic, vector_simple_hybrid
filterNoApplies to all queries the agent makes to the index

Control tool calling with tool_choice

ValueBehavior
autoThe model decides whether to call tools
requiredThe model must call one or more tools
noneThe model doesn't call tools

Toolbox

Memory

Memory typeHoldsRetrieve
User profile memoryDurable user preferences and personal contextNear the start of each conversation
Chat summary memoryDistilled summaries of prior conversation topics and threadsPer turn, using current messages
Procedural memoryReusable how-to routines inferred from prior interactionsWhen the user asks for a recurring task
NeedUse
What the agent learned about this user over timeMemory
Curated organizational contentA Foundry IQ knowledge base
Documents the user provides during an interactionFile search

Memory is filled from conversations, so protect it against prompt injection and memory corruption: use Azure AI Content Safety prompt injection detection and test the agent adversarially.

Orchestration, approvals and safeguards

Workflow patternWhat it doesTypical use
Human in the loopAsks the user a question and awaits inputApproval requests or collecting information
SequentialPasses the result from one agent to the next in orderPipelines and multi-stage processing
Group chatDynamically passes control between agents based on context or rulesEscalation, fallback or expert handoff

Approval flow and safeguards

Monitoring, evaluation and error analysis

EvaluatorKindAsks
Task CompletionSystemDid the agent fully complete the requested task?
Task AdherenceSystemDid the agent follow the rules and constraints in its instructions?
Intent ResolutionSystemDid the agent correctly identify and address user intentions?
Tool SelectionProcessDid the agent select the correct and necessary tools?
Tool Call AccuracyProcessDid the agent make the right tool calls with correct parameters?
Tool Call SuccessProcessDid the tool calls succeed without technical errors?
Tool Output UtilizationProcessDid the agent correctly use tool results in its reasoning and answer?

System evaluation checks end-to-end outcomes. Process evaluation checks each step, mainly tool calls. Evaluators work like unit tests and return Pass/Fail scores, so you can set an acceptance threshold before release.

SymptomCheck
Agent doesn't call a toolTool attached? Model supports the tool? Set tool_choice to required for deterministic behavior; review the trace
Tool returns empty or irrelevant resultsImprove tool descriptions and instructions; for retrieval tools make sure the data is ingested and searchable
Tool call failsVerify tool configuration and authentication; for MCP and OpenAPI confirm the endpoint is reachable
"Tool not supported" although tables show supportTool needs support from both the model and the region

CLI and PowerShell

TaskAzure CLIPowerShell
Create a conversation for multi-turn use (Python)conversation = openai.conversations.create()-
Respond inside a conversation (Python)response = openai.responses.create( conversation=conversation.id, input="What is the size of France in square miles?", )-
Follow up on a stored response (Python)follow_up = openai.responses.create( previous_response_id=response.id, input="What is the population of that city?", )-
Create a prompt agent version (Python)agent = project.agents.create_version( agent_name="my-agent", definition=PromptAgentDefinition( model="gpt-5-mini", instructions="You are a helpful assistant.", ), )-

Exam Tips

Tick each tip once you can answer it without looking.

“Foundry should run the agent from a saved definition: instructions, model, tools; no code, containers or compute to maintain” → Prompt agent. Trap: A hosted agent runs your own code in a container; the Responses API ephemeral pattern keeps the definition in your app and creates no agent resource.

“Bring your own framework (LangGraph, Agent Framework) or custom orchestration and protocols” → Hosted agent: container or .zip, managed endpoint, scaling, dedicated Entra identity. Trap: A prompt agent is configuration only; it has no custom runtime code.

“The model asks for a function call: who runs the function?” → Your app runs it and submits the output (function_call_output with the call_id) before the run expires, 10 minutes after creation. Trap: Foundry doesn't execute your function; late outputs miss the expiry.

“Add, remove or update function definitions on an agent” → SDK or REST API. Trap: The portal can run an agent with function tools but can't edit the function definitions.

“Multi-turn context without rebuilding it yourself” → Use a conversation (or previous_response_id); with store false you pass previous output items as input. Trap: Without a stored response or conversation, the service has nothing to continue from.

“Make tool calling deterministic” → tool_choice: required forces a call, none blocks calls, auto lets the model decide. Trap: Better instructions help but don't give the same deterministic control.

“MCP allowed_tools set to an empty list []” → Allows all tools the MCP server exposes. Trap: It doesn't mean zero tools; restrict access with a nonempty list.

“Human must approve high-risk MCP tool calls” → require_approval = always; reply with mcp_approval_response in the same conversation. Trap: Don't switch to previous_response_id for the Copilot harness; it needs a conversation.

“Remember each user's preferences across sessions, isolated per user” → Memory store + memory search tool with scope = {{$userId}}. Trap: Low-level memory APIs don't resolve scope automatically: set scope explicitly.

“Ground on curated organizational content vs. user-provided documents vs. learned user context” → Foundry IQ knowledge base vs. file search vs. memory. Trap: Memory is for what the agent learns from interactions, not for a document library.

“Share one governed set of tools with central auth and versioning across agents” → Toolbox (single MCP-compatible endpoint); add tool search for very large tool sets. Trap: Wiring each tool into each agent duplicates credentials and governance.

“Orchestrate agents with approvals, sequence or expert handoff, visually” → Workflow patterns: human in the loop, sequential, group chat. Trap: Hosted agents aren't supported in the workflow designer; workflows are retiring December 1, 2026 in favor of Microsoft Agent Framework.

“Call another agent from a Foundry agent” → A2A tool (a2a) or a workflow. Trap: The Connected Agents tool from the classic API isn't available in the new service.

“See why an agent behaved badly, with the least effort” → Connect Application Insights to the project (server-side tracing); read traces; Log Analytics Reader to view. Trap: Client-side instrumentation is a second step for your own code; the reader role doesn't turn tracing on.

“Check each step vs. check the final outcome” → Process evaluators (Tool Selection, Tool Call Accuracy, Tool Call Success) vs. system evaluators (Task Completion, Task Adherence, Intent Resolution). Trap: A passing final outcome can hide wrong or redundant tool calls.

Sources

Checked against Microsoft Learn on November 13, 2026.

← Generative Apps & RAGPrompting, Tuning & Observability →