Prerequisites
- Agent Stack installed (Quickstart) and the platform running with
agentstack platform start - uv package manager (should be already installed if you followed the quickstart)
1. Start From Template
You should see: “Ciao Alice!” 🎉
With your first agent running, you can now modify it to do anything you want.
2. Implement Your Agent Logic
In the starter repo, 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 and Configure the Server
An agent is essentially an HTTP server. Use
server.run() to define how your agent listens for requests:- Host: Defaults to
127.0.0.1(localhost). - Port: Defaults to
8000. If you run multiple agents on the same machine, ensure each has a unique port.
Mark Your Agent Function
Add the
@server.agent decorator to your function so the platform recognizes it as an agent.Name and Describe Your Agent
- Identity: The function name (e.g., example_agent) becomes the agent’s unique identifier.
- Metadata: Write a clear docstring. The SDK extracts this text to serve as the agent’s description in UIs and registries, helping understand what your agent does.
Understand the Function Arguments
- First argument: An A2A
Message. Useget_message_text(input)to pull the raw string from the user. This is where you would typically pass data into your LLM or custom processing logic. - Second argument: A
RunContextobject with run details provides metadata about the current execution (e.g.,task_id,context_id). Use this if your agent logic needs to track session state or reference specific task parameters.
Stream Responses via Async Generator
Agents should be async and use
yield. This allows the server to stream responses back to the client in real time. Yield an AgentMessage (a handy wrapper around A2A Message) for convenience or a plain str, which will be automatically converted into an A2A Message.Manual Project Configuration
Manual Project Configuration
If you prefer not to use our starter template, you must ensure your project includes these core components to integrate correctly with the Agent Stack platform.
- The SDK Inegration
- Add agentstack-sdk to your project dependencies.
- Your code must initialize a Server() instance from the SDK.
- You need a designated function that calls server.run(host, port). This is what allows the platform (and Docker) to start your agent.
- Agent logic remains the same as in the Implement Your Agent Logic section
- Containerization Requirements
- If you plan to deploy your agent to the platform (rather than just running it locally), your repository must contain a
Dockerfile
- If you plan to deploy your agent to the platform (rather than just running it locally), your repository must contain a
- Git and Platform Metadata
- The repository must be accessible to the Agent Stack orchestrator if you are using the
agentstack addcommand via URL. - Use Git tags (e.g., v1.0.0) if you want to manage stable releases of your agent.
- The repository must be accessible to the Agent Stack orchestrator if you are using the
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