[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3
Creating Your First Agent
Building an Agent in 5 Minutes
Via the Foundry Portal
- Navigate to Agents in your project sidebar
- Click + New Agent
- Select a deployed model (e.g., gpt-4o)
- Write system instructions defining the agent's role
- Add tools (code interpreter, file search, custom functions)
- Test in the Agent Playground
Via the SDK (Python)
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
project = AIProjectClient(
endpoint="<endpoint>",
credential=DefaultAzureCredential()
)
agent = project.agents.create_agent(
model="gpt-4o",
name="Research Assistant",
instructions="You are a research assistant. Search the web and summarize findings clearly.",
tools=[{"type": "code_interpreter"}]
)
# v2 SDK: Threads replaced by Conversations
conversation = project.agents.create_conversation()
project.agents.create_message(
conversation_id=conversation.id,
role="user",
content="Analyze the latest trends in renewable energy"
)
run = project.agents.create_and_process_run(
conversation_id=conversation.id,
agent_id=agent.id
)
messages = project.agents.list_messages(conversation_id=conversation.id)
print(messages.data[0].content[0].text.value)
🎯 Pro Tip: Write agent instructions as if briefing a new employee. Be specific about what the agent should and should NOT do, what tone to use, and how to handle edge cases.
FOUNDRY VERIFICATION
QUERY 1 // 1
What is the recommended approach for writing agent instructions?
Keep them as short as possible
Write them like briefing a new employee - specific about role, boundaries, and edge cases
Copy from documentation
Leave them empty and rely on the model