# How Python Dependencies Are Managed in the AI-Agent-Book Repository

> Discover how Python dependencies are managed in the ai agent book repo. Learn about chapter specific requirements, lock files, and runtime code isolation.

- Repository: [Bojie Li/ai-agent-book](https://github.com/bojieli/ai-agent-book)
- Tags: how-to-guide
- Published: 2026-08-22

---

**The bojieli/ai-agent-book repository manages Python dependencies through a decentralized, chapter-specific structure that isolates documentation build tools from runtime code examples using multiple requirements files alongside modern lock-file tools.**

Unlike monolithic Python projects that rely on a single [`requirements.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements.txt), this repository organizes **Python dependencies** by functional scope. The approach separates core documentation generators from per-chapter execution environments, allowing contributors to install only the packages necessary for their specific task.

## Core Documentation Dependencies

The root-level [`requirements-docs.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements-docs.txt) file declares all packages required to build and render the book itself. According to the repository structure, this file includes tooling such as **MkDocs**, **Pandoc**, and **Mermaid** for documentation generation and diagram rendering.

To install these core build dependencies:

```bash
pip install -r requirements-docs.txt

```

This command installs the exact versions used by the original authors, ensuring that documentation builds remain reproducible across different machines.

## Chapter-Specific Runtime Dependencies

Each chapter maintains its own isolated environment through dedicated [`requirements.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements.txt) files located within chapter subdirectories. For example, [`chapter1/web-search-agent/requirements.txt`](https://github.com/bojieli/ai-agent-book/blob/main/chapter1/web-search-agent/requirements.txt) contains only the libraries needed to run the web search agent examples from that specific chapter.

This granular approach prevents dependency conflicts between chapters that might use incompatible versions of the same library. To set up an environment for a specific chapter:

```bash
cd chapter1/web-search-agent
pip install -r requirements.txt

```

The repository structure indicates that every chapter with executable code follows this pattern, keeping the runtime footprint minimal and targeted.

## Lightweight Variants for Rapid Testing

Some chapters provide alternative [`requirements-lite.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements-lite.txt) files for scenarios requiring minimal installations. The file [`chapter9/gaia-experience/requirements-lite.txt`](https://github.com/bojieli/ai-agent-book/blob/main/chapter9/gaia-experience/requirements-lite.txt) demonstrates this pattern, offering a reduced dependency set optimized for continuous integration pipelines or quick experiments.

Use the lightweight variant when you need faster installation times or want to verify code logic without pulling heavy machine learning frameworks:

```bash
cd chapter9/gaia-experience
pip install -r requirements-lite.txt

```

## Lock-File Reproducibility with uv and Poetry

For deterministic environment reconstruction, the repository includes a `uv.lock` file at the root compatible with the **uv** package manager. After installing uv (`pip install uv`), you can recreate the exact dependency tree with a single command:

```bash
uv sync

```

The lock file guarantees that every contributor uses identical package versions, eliminating "works on my machine" issues.

Additionally, the root [`pyproject.toml`](https://github.com/bojieli/ai-agent-book/blob/main/pyproject.toml) file supports **Poetry** workflows. Contributors preferring Poetry can run:

```bash
poetry install

```

This reads the TOML configuration and installs the same dependencies declared in [`requirements-docs.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements-docs.txt), allowing flexibility in package management tooling.

## Practical Installation Workflows

The following patterns demonstrate the typical workflows for different contribution types:

**For documentation editing:**

```bash
pip install -r requirements-docs.txt

```

**For chapter-specific development:**

```bash
cd chapter5/coding-agent
pip install -r requirements.txt

```

**For reproducible research environments:**

```bash
pip install uv
uv sync

```

## Summary

- The repository uses [`requirements-docs.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements-docs.txt) at the root for documentation build tools like MkDocs and Pandoc.
- Each chapter contains its own [`requirements.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements.txt) to isolate runtime dependencies (e.g., [`chapter1/web-search-agent/requirements.txt`](https://github.com/bojieli/ai-agent-book/blob/main/chapter1/web-search-agent/requirements.txt)).
- Optional [`requirements-lite.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements-lite.txt) files provide minimal dependency sets for faster testing.
- The `uv.lock` file enables deterministic installations via the uv package manager using `uv sync`.
- The [`pyproject.toml`](https://github.com/bojieli/ai-agent-book/blob/main/pyproject.toml) supports Poetry as an alternative to pip-based workflows.

## Frequently Asked Questions

### Where are the main Python dependencies defined in the AI-Agent-Book repository?

The main Python dependencies are split between the root-level [`requirements-docs.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements-docs.txt) for documentation tooling and individual [`requirements.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements.txt) files within each chapter directory for runtime code examples. There is no single global requirements file; instead, dependencies are scoped to their specific use case.

### How do I install dependencies for a specific chapter?

Navigate to the chapter directory and install its local requirements file. For example, run `cd chapter1/web-search-agent && pip install -r requirements.txt` to install only the packages needed for Chapter 1's web search agent examples, keeping your environment isolated from other chapters.

### What is the difference between requirements.txt and requirements-lite.txt?

The standard [`requirements.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements.txt) contains the full set of libraries needed to run all examples in a chapter, while [`requirements-lite.txt`](https://github.com/bojieli/ai-agent-book/blob/main/requirements-lite.txt) provides a minimal subset for quick tests or CI environments. For instance, [`chapter9/gaia-experience/requirements-lite.txt`](https://github.com/bojieli/ai-agent-book/blob/main/chapter9/gaia-experience/requirements-lite.txt) omits heavy dependencies that are not essential for basic validation.

### Can I use Poetry or uv instead of pip to manage dependencies?

Yes. The repository supports multiple workflows: use `pip install -r` for traditional requirements files, `uv sync` to leverage the `uv.lock` file for exact reproducibility, or `poetry install` to read from the root [`pyproject.toml`](https://github.com/bojieli/ai-agent-book/blob/main/pyproject.toml). All three methods install the same underlying package versions.