Pydantic AI 2.77 Python 3.11+ 137-page PDF

Leave the agent running overnight.

Engineering discipline for agents you can leave running overnight

137-page PDF for senior Python engineers. Build a GitHub issue triage agent with Pydantic AI 2.77.0 — typed outputs, tools, evals, observability, cost, canaries, and a kill switch.

14-day refund if the book isn't useful for you. Team use inside your org is fine — please don't resell the PDF.

Production AI Agents with Pydantic AI cover by Nuno Bispo

01 · build


# One issue in → a typed triage decision out
class IssueClassification(BaseModel):
label: Label
confidence: float = Field(ge=0.0, le=1.0)
rationale: str = Field(max_length=400)
duplicate_of: int | None = None

You build a GitHub issue triage agent on triage-lab fixtures: classify, retrieve similar issues, comment when confident, escalate when not, and ask before closing anything. Companion code: ai-agents-pydantic-ai.

What you'll learn

Ship a maintainer triage bot against triage-lab fixtures, then harden it chapter by chapter.
Typed IssueClassification output with retries — no free-form JSON hand-waving.
Tools with dependency injection and explicit error contracts.
Retrieval that logs scores and fails closed when neighbors are weak.
Versioned prompts and output contracts you can roll back.
Prompt-injection defenses for untrusted issue bodies.
An offline pytest suite that needs no API keys.
An eval suite that gates merges before quality slips into production.
Logfire / OpenTelemetry spans with cost on every run.
Human-in-the-loop approvals, kill switch, canary rollout, and a real runbook.

02 · readers


Who it's for

Senior Python engineers

You already ship APIs with tests, SLOs, and on-call. This book applies that discipline to agents — without pretending models are magic.

Teams past the demo

The PoC works on a laptop. Stakeholders want production. You need rollback, evals, cost caps, and a kill switch before the next incident.

Pydantic AI builders

Typed outputs and DI are already in the framework. Learn the operating model that makes those seams earn their keep overnight.

Maintainers & platform folks

You will build a GitHub issue triage agent on triage-lab fixtures — then harden comments, labels, and escalations safely.

03 · contents


Inside the book

14 chapters and 2 appendices — from the first agent to the runbook.

Start here
  1. 1. Your PoC Is Not in Production
  2. 2. The First Agent
  3. 3. Shipping the Bad Version
Make it reliable
  1. 4. Tools With Dependency Injection
  2. 5. Retrieval That Does Not Lie
  3. 6. The Versioned Output Contract
  4. 7. Untrusted Input
Prove it
  1. 8. A Test Suite That Runs Without Keys
  2. 9. An Eval Suite That Gates Merges
  3. 10. Observability You Can Debug From
  4. 11. Cost Engineering
Operate it
  1. 12. Human-in-the-Loop and the Kill Switch
  2. 13. Canary Rollout and Quality SLOs
  3. 14. The Runbook
Appendices
  1. A. What This Book Does Not Cover
  2. B. Upgrading Pydantic AI

04 · pages


Sample pages

Ten pages from the PDF — click any page to view it larger. Or download the free sample PDF.

p. 1

Cover

Engineering discipline for agents you can leave running overnight.

p. iii

Contents

Fourteen chapters and two appendices, with real page numbers.

p. 1

Chapter 1

Three production failure modes — and why agents are still software.

p. 7

The first agent

Classify triage-lab issues with a typed Pydantic AI contract.

p. 25

Tools + DI

Dependency injection and tool contracts the agent can trust.

p. 39

Retrieval

Hybrid search that refuses to lie about missing neighbors.

p. 68

Offline tests

A test suite that runs without API keys — in a few seconds.

p. 77

Eval gate

The eval suite that gates merges before confidence goes live.

p. 100

HITL + kill switch

Human approval for writes, and a kill switch you can flip at 3am.

p. 119

The runbook

Operate the agent after deploy: alerts, rollback, on-call.

05 · author


Nuno Bispo

Nuno Bispo

Senior software engineer and integration architect with 15+ years across insurance, banking, and airlines. Writes about Python, AI, and MicroPython at Developer Service. Author of Practical Pydantic.

Also by Nuno Bispo

Get launch notes and Python deep-dives

Free essays on developer-service.blog — join the list for new posts and book updates.

Subscribe via Ghost

06 · faq


FAQ

A DRM-free PDF download link by email and on the success page. The file is production-ai-agents-with-pydantic-ai.pdf.

Pydantic AI 2.77.0 on Python 3.11 or newer (the companion project pins 3.12). Companion code: github.com/nunombispo/ai-agents-pydantic-ai.

Yes — the public GitHub repo linked from the book includes the finished triage bot, the Chapter 2–3 checkpoint, tests, and evals. Fixtures live in nunombispo/triage-lab.

Signed download links stay valid for 14 days. Reply to your receipt email if you need a refresh.

If the PDF is not what you expected, contact support@developer-service.io within 14 days of purchase for a refund.

Chapter 2’s live classify run needs an API key. The test suite and most later chapters are designed to run offline with fakes — no keys required.

Ship an agent you would trust on-call.

137-page PDF — $19.99

Instant download after payment · Email with a signed link · 14-day refund