Deploying Your AI Agent › Packaging Your Agent
AI Agent HandbookAll chapters Deploying Your AI Agent › Packaging Your AgentOne section · Sections in this chapter4 / 10 ↓
Before you can deploy anywhere, you need to package your code so it can run reliably in a different environment. This means organizing your files, documenting dependencies, and making sure everything needed to run the agent is included.
Organizing Your Code
Start by structuring your project clearly. A typical layout might look like this:
my-assistant/
├── assistant.py # Main agent logic
├── tools.py # Tool implementations
├── memory.py # Memory management
├── requirements.txt # Python dependencies
├── .env.example # Example environment variables
└── README.md # Setup instructionsThis structure makes it clear what each file does and helps others (or future you) understand the project quickly.
Managing Dependencies
Your agent relies on external libraries like the Anthropic SDK, OpenAI client, or other packages. You need to document these so the agent can be set up correctly on a new machine.
Create a requirements.txt file listing all your dependencies with their versions:
anthropic==0.18.0
openai==1.12.0
python-dotenv==1.0.0Anyone deploying your agent can then install everything with a single command:
pip install -r requirements.txtFor more robust dependency management, you might use tools like uv or poetry, which handle virtual environments and lock files automatically. But for getting started, requirements.txt works well.
Handling Configuration
Your agent probably uses API keys and other configuration values. These should never be hardcoded in your source files or committed to version control. Instead, use environment variables.
Create a .env.example file showing what variables are needed:
ANTHROPIC_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here
DATABASE_URL=sqlite:///assistant.dbWhen deploying, you'll create a real .env file with actual values, or set these variables in your deployment platform's configuration.