Deploying Your AI Agent › Packaging Your Agent

Michael BrenndoerferAugust 18, 20252 min read
AI Agent HandbookAll chapters
Part 14 of 15Deployment and Operations - From Prototype to Production
Chapter 39Deploying Your AI Agent › Packaging Your Agent
Reading section 4 of 10 · Packaging Your Agent · 2 minSection 4 of 10 · 2 min

Book contents

Section 4 of 10 · 2 min read

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 instructions

This 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.0

Anyone deploying your agent can then install everything with a single command:

In[2]:
Code
pip install -r requirements.txt

For 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.db

When deploying, you'll create a real .env file with actual values, or set these variables in your deployment platform's configuration.