Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

4.2.3. Building a Client Application for an Agent

💡 First Principle: Talking to a deployed agent from code reuses the two-client pattern, with one addition: you hold a conversation (so the agent remembers context across turns) and you reference the agent by name when you send input. The shape is "create clients, create a conversation, send input referencing the agent, read output."

Recognize this current pattern:

from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient

project = AIProjectClient(
    endpoint="https://<resource>.services.ai.azure.com/api/projects/<project>",
    credential=DefaultAzureCredential(),
)
openai_client = project.get_openai_client()

# A conversation keeps multi-turn history
conversation = openai_client.conversations.create()

# Send input, referencing the agent by name
response = openai_client.responses.create(
    conversation=conversation.id,
    extra_body={"agent_reference": {"name": "MyAgent", "type": "agent_reference"}},
    input="What is the size of France in square miles?",
)
print(response.output_text)

The difference from the plain chat client in 4.1.3 is the conversation (for multi-turn memory) and the agent_reference (which routes the request through your agent's instructions and tools instead of calling the raw model). Everything else — project client, OpenAI client, credential — is identical.

⚠️ Exam Trap: A conversation object is what gives an agent multi-turn memory. Without it, each request is independent and the agent "forgets" prior turns. If a scenario describes an agent that can't remember earlier messages, a missing or unreused conversation is a likely cause.

Reflection Question: Comparing the 4.1.3 chat snippet and this agent snippet, what are the two additions that turn "call a model" into "talk to an agent"?

Alvin Varughese
Written byAlvin Varughese
Founder18 professional certifications