Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 17 of 39
❮Prev Next❯

Design an Agent: Role, Goals, Threads and Tool Schemas

Module 2: GenAI & Agents ⏱ 12 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    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 needed

    Exam 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.

    Azure portal: Define a role, a goal and a strict function tool Write instructions and add a function tool with a strict schema.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    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
    1. Open Build ➜ Agents and create an agent. Each save becomes a numbered version.
    2. Instructions carry the role, the goal and the rules. Say what to do when information is missing.
    3. A function tool is a name, a description and a JSON schema. Mark order_id required and the schema strict, so arguments always match.
    4. 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.

    😟 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
    🛠️ Solved with: Foundry Agent Service

    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

    PartWhat it doesExample
    ModelThe deployment that does the thinkingsupport-chat
    InstructionsRole, goal, rules, tone, escalation“Always call get_order_status for order questions. If the order number is missing, ask.”
    ToolsWhat it can useA function, file search, Azure AI Search
    ConversationMessages of one chatCreated once, referenced by ID on every request
    VersionA numbered snapshot of the definitionorder-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

    Retail

    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.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    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.

    Question 1

    Question 1 of 5

    An order agent invents order numbers when customers ask where their parcel is.

    Which change reduces this behaviour most directly?

    Question 2

    Question 2 of 5

    You are creating a prompt agent in Foundry Agent Service.

    Where do you define its role and goal?

    Question 3

    Question 3 of 5

    A support agent must remember what was said earlier in the same chat.

    What should the application use?

    Question 4

    Question 4 of 5

    The model should call get_order_status only when a customer gives an order number.

    Which part of the tool definition most directly tells the model when to call it?

    Question 5

    Question 5 of 5

    A change to an agent made things worse and the team must return to the previous behaviour quickly.

    Which feature supports this?

    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. 1.Where are role and goal defined?Show

      In the agent instructions.

    2. 2.What does a function tool need?Show

      A name, a description and a JSON schema.

    3. 3.What stores messages of one chat?Show

      A conversation.

    4. 4.What is created on each agent change?Show

      A new version.

    5. 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

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.