Design an Agent: Role, Goals, Threads and Tool Schemas
30-second answer
An agent is a model plus instructions, tools and a conversation. The instructions carry its role, goal and rules, including what to do when information is missing. Each tool has a name, a description and a JSON schema, and a strict schema with required parameters makes the agent ask instead of invent. A conversation keeps the messages for one chat, and every change to the agent creates a new version you can roll back to.
Simulate it » No Azure account neededExam objective: 2.2.1 Define agent roles, goals, conversation-tracking approach and tool schemas. (Skills measured as of April 16, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Build ➜ Agents</strong> and create an agent. Each save becomes a numbered <strong>version</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Build ➜ Agents and create an agent. Each save becomes a numbered version.
- Instructions carry the role, the goal and the rules. Say what to do when information is missing.
- A function tool is a name, a description and a JSON schema. Mark order_id required and the schema strict, so arguments always match.
- Test in the playground. Without a number the agent asks for it. With one, the model requests the function and your app runs it. Each chat is a conversation that stores the messages for you.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Design the agent: role, goal, tool schema
An agent is a model plus instructions (role and goal), tools and a conversation (thread). A strict function schema names each parameter and marks the required ones, so the model asks the user instead of inventing a value.
🤔 What happens if…
Read this tour as text
- Deploy a model, call the deployment. A deployment is a named copy of a model with a version, a deployment type and capacity. Your app calls the deployment name, never the model name. Pick a large model for hard work and a small language model for cheap, fast, simple work.
- RAG: retrieve first, then answer. Retrieval-augmented generation searches your own content (Azure AI Search, hybrid keyword plus vector), puts the best chunks in the prompt and asks the model to answer from them with citations. Without retrieval the model guesses.
- A multistep flow with checks. A workflow breaks one big request into steps you control: classify, extract to a JSON schema, call a tool, draft, then verify. Retries, fallbacks and a final check live in code, so one bad step can’t slip through unseen.
- Evaluate before you ship. Evaluators score each answer on a test set: groundedness (is it supported by the context?), relevance, coherence and safety checks. A fabrication shows up as a low groundedness score on one row, so you fix it before users see it.
- SDK, project endpoint and connections. The Foundry SDK (
azure-ai-projects) opens one door: AIProjectClient with the project endpoint and DefaultAzureCredential. From it your app gets an OpenAI-compatible client, deployments and connections (Azure AI Search, Application Insights) with no secrets in code. - Design the agent: role, goal, tool schema. An agent is a model plus instructions (role and goal), tools and a conversation (thread). A strict function schema names each parameter and marks the required ones, so the model asks the user instead of inventing a value.
- Retrieval, function calling and memory. One agent can use file search for documents, a function for live data and memory for what it learned about a user. The model asks to call a function; your code runs it and returns the result. Memory survives into a new conversation.
- Multi-agent orchestration. Several specialist agents can share a job. Sequential passes work down a line, concurrent fans out and merges, handoff moves control to the right specialist, group chat lets agents take turns in one shared conversation and Magentic lets a manager agent plan and delegate. Microsoft Agent Framework builds all five.
- Autonomy with approvals. Reads are safe, writes are not. A tool marked approval required pauses the run until a person decides. A hard limit in code blocks what no one should approve, whatever the model says.
- Monitor and debug agent runs. Agent evaluators read the whole run: intent resolution, tool call accuracy and task adherence. Error analysis groups the failing rows, such as a made-up tool argument, and points to the fix.
- Tune prompts and parameters. Instructions shape tone and rules, a few-shot example shows the format, temperature and top_p change how adventurous the wording is, and max output tokens caps length. A self-critique loop drafts, checks against a checklist and revises once.
- Trace every call and count tokens. OpenTelemetry spans record each agent run, model call and tool call, with tokens and latency, and Application Insights stores them. Tracing is opt-in, and recording message content is for development only because it captures prompts and answers.
- Route requests to the right model. A hybrid design puts rules first for answers code can decide, a small model for easy language work and a large or reasoning model only when needed. A model router can pick for you. Fewer big-model calls means a lower bill and faster replies.
Priya asks Contoso's order agent where her order is. Create the agent with a strict function schema and file search, see it ask for a missing order number instead of guessing, then give it memory so it remembers a preference next week.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
The support agent invents order numbers and answers questions it should refuse.
😊 THE SOLUTION
Give it a clear role and goal, a strict tool schema and rules for missing information.
- Vague behaviour✓ Role, goal and rules in the instructions
- Made-up arguments✓ Strict schema with required parameters
- Lost context between turns✓ A conversation that stores the messages
Start with a question
What do you tell a new shop assistant on day one?
You say who they are (“you’re the order desk”), what they’re there for (“tell customers where their parcel is”), what they may use (“the order system”) and what to do when stuck (“if there’s no order number, ask for it, never guess”).
That’s exactly an agent definition. The instructions give the role, the goal and the rules. The tools are the order system. And the conversation is the notepad of this one customer’s chat.
Explain it like I’m 10
The technical explanation
The parts of an agent
| Part | What it does | Example |
|---|---|---|
| Model | The deployment that does the thinking | support-chat |
| Instructions | Role, goal, rules, tone, escalation | “Always call get_order_status for order questions. If the order number is missing, ask.” |
| Tools | What it can use | A function, file search, Azure AI Search |
| Conversation | Messages of one chat | Created once, referenced by ID on every request |
| Version | A numbered snapshot of the definition | order-agent v3 |
Write a good tool schema
The model decides to call a tool from its name and description, and fills the arguments from the schema. Be exact:
get_order_status = FunctionTool(
name="get_order_status",
description="Look up the delivery status of one Contoso order. Call it whenever the customer gives an order number.",
parameters={"type": "object",
"properties": {"order_id": {"type": "string", "description": "Order number, for example ORD-1042"}},
"required": ["order_id"], "additionalProperties": False},
strict=True)
agent = project.agents.create_version(agent_name="order-agent", definition=PromptAgentDefinition(
model="support-chat",
instructions=("Role: Contoso Retail's order assistant. Goal: tell customers where their order is. "
"Always call get_order_status for order questions and ask for the order number if it's missing. "
"Never promise a date the tool didn't return."),
tools=[get_order_status]))
Mark every parameter the tool really needs as required, set additionalProperties to false and turn strict on. Then a missing order number can’t become a made-up one: the instructions tell the agent to ask, and the schema leaves no room to guess.
Track the conversation
Create a conversation for each chat and pass its ID with every request, so the service keeps the history for you. The other option is to resend the messages yourself on each call, which you control but must store and trim. Long-term facts about a user are not part of the conversation. That’s memory, covered in the next lesson.
openai = project.get_openai_client(agent_name="order-agent")
conversation = openai.conversations.create()
r = openai.responses.create(conversation=conversation.id, input="Where is my order?")
Versions and agent kinds
Each change to instructions, tools or model makes a new version, so you can compare versions on the same evaluation set and roll back. This lesson builds a prompt agent: a model with instructions and tools. Foundry also has workflow agents for multi-step flows and hosted agents that run your own code, both in preview as of 25 November 2026.
Architect level Instructions that work
Short, specific instructions beat long ones. Start with the role and the goal, then list rules as plain sentences, then say what to do on failure: no result, missing input or an unrelated request. Add one example if the format matters. Test with awkward inputs on purpose, such as no order number, two order numbers, or a request the agent shouldn’t handle, and keep those cases in your evaluation set.
Real-world business scenario
Contoso Retail (fictional)
- The problem
- The first support agent answered Where is my order? with an order number it made up, and it happily discussed topics unrelated to orders.
- What they used
- An order-agent prompt agent with role and goal instructions, a strict get_order_status function that requires order_id, and a conversation per customer chat. Each edit is a new version.
- Why that choice
- With no order number the agent asks for it, and with one it calls the function. Versions let the team compare and roll back.
- The result
- Made-up order answers stopped, and when a Friday edit made answers worse, the team pointed back to the previous version in minutes.
When to use it and when not to
✓ Use it when…
- The model needs tools or data to finish the job.
- A conversation has several turns that depend on each other.
- You want to version, test and roll back behaviour.
✕ Think twice when…
- A single question and answer. Call the model directly.
- The steps are fixed and known. A workflow may be simpler.
- You give one agent every tool. Split the work into specialists.
↔ Alternatives to consider
- A direct model call for simple prompts.
- A workflow for fixed steps.
- Multi-agent orchestration when the job needs specialists.
Test yourself with exercises
5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What is the difference between a model and an agent?
Model answer
A model answers a prompt. An agent is a model with instructions, tools and a conversation, so it can look things up, take actions and keep track of the chat.
Intermediate How do you stop an agent inventing an order number?
Model answer
I define the function with order_id as a required, strict parameter, and the instructions say to ask the customer if the number is missing. The model then asks instead of filling in a made-up value.
Experienced developer What goes in instructions and what goes in the tool description?
Model answer
Instructions hold the role, goal, tone, rules and escalation. The tool description tells the model when and why to call that tool, and parameter descriptions explain each argument. The model reads both, so I keep each focused.
Scenario An agent change made answers worse. How do you recover?
Model answer
Each save is a version, so I point the application back to the previous version while I investigate, and I run the evaluation set against both to see what changed.
Quick revision
Key points
- Instructions define role, goal and rules, including behaviour on missing data.
- Tool name, description and schema decide when and how it is called.
- Strict schemas with required parameters stop invented arguments.
- A conversation stores one chat; memory is a separate feature.
- Versions make changes reversible.
Important terminology
- Agent
- A model with instructions, tools and a conversation that can decide which tool to use to reach a goal.
- Instructions
- The text that sets the agent's role, goal, rules and what to do when something is missing.
- Function tool
- A tool defined by a name, a description and a JSON schema. The model asks for it and your code runs it.
- Strict schema
- A tool schema where arguments must match exactly, with required parameters and no extra fields.
- Conversation
- A stored list of messages for one chat, referenced by ID on each request.
- Agent version
- A numbered snapshot created each time the agent definition changes.
Common mistakes
- Vague instructions with no rule for missing information.
- Optional parameters that the tool really needs.
- Cramming many unrelated tools into one agent.
Exam tips
- "Agent invents arguments" = strict schema with required parameters and an instruction to ask.
- "Remember the earlier messages in this chat" = conversation.
- "Roll back a bad change" = agent versions.
Five quick revision questions
-
1.Where are role and goal defined?Show
In the agent instructions.
-
2.What does a function tool need?Show
A name, a description and a JSON schema.
-
3.What stores messages of one chat?Show
A conversation.
-
4.What is created on each agent change?Show
A new version.
-
5.What does strict do?Show
It makes arguments match the schema exactly.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Agents with Retrieval, Function Calling and Memory
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.