Prerequisites
- Agent Stack installed (Quickstart)
- uv package manager (should be already installed if you followed the quickstart)
Start From Template
You should see: “Ciao Alice!” 🎉
With your first agent running, you can now modify it to do anything you want.
Implement Your Agent Logic
Navigate to src/agentstack_agents/agent.py and replace the example with your agent logic. The starter example is minimal and intended for demonstration purposes only:Start a server
An agent is essentially an HTTP server. Create a
Server instance and run it using run().Mark your agent function
Add the
@server.agent decorator to your function so the platform recognizes it as an agent.Describe your agent
Write a docstring for the function; it will be extracted and shown as the agent’s description in the platform.
Understand the function arguments
- First argument: an A2A
Message. - Second argument: a
RunContextobject with run details (e.g.,task_id,context_id).
Extract text from Message
Use
get_message_text() to quickly extract the text content from a Message.Make it an async generator
The agent function should be asynchronous and yield results as they’re ready.
Starting from Scratch
If you prefer not to use the starter repo:- Create an empty Python project
- Install
agentstack-sdk - Copy the example code above
Next Steps
After building your agent, you can enhance it and learn more:Agent Details
Customize your agent’s name, description, and how it appears in the UI
Working with Messages
Learn how agents and clients communicate through structured messaging
Multi-Turn Conversations
Understand how to handle multi-turn conversations and maintain context
Working with Files
Work with files to provide inputs or store outputs for your agent