liveBook · Manning

Chapter 8: Deploying agents and agentic systems

What you will learn in chapter 8 of AI Agents in Action, Second Edition

The introduction frames deployment as a choice among ways to make an agent available, from embedding it in an application to using containers.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction frames deployment as a choice among ways to make an agent available, from embedding it in an application to using containers.

Key terms: deploy, productize, embedding, containers

8.1 Strategies for consuming agents

This section introduces ways to consume agents, explains when browser embedding is appropriate, and connects backend deployment to containerized microservices.

Key terms: embedded, microservice, API, MCP, A2A, browser-side agent deployment, API keys, CORS, rate limits, embed pattern

8.1.1 Embedding real-time voice agents into web applications

This section shows how a real-time voice agent can run in a browser, walks through a minimal demo, and explains how to evaluate its AI-generated deployment code.

Key terms: real-time voice agents, client-side JavaScript, latency, OpenAI Agents SDK Realtime package, ephemeral key, Connect mic, MCP servers, vibe coding, deployment scaffolds, engineering judgment

8.1.2 Hosting agents through an API

This section shows how to expose an existing image-generation agent through a FastAPI endpoint, explains its request and response choices, and describes how to run and check the service.

Key terms: FastAPI, POST endpoint, agent web service, POST, GET, generate endpoint, array of bytes, base64, uvicorn, VS Code

8.1.3 Consuming an agent web service in a web application

Shows how a browser-based voice agent delegates image generation to a backend agent while remaining interactive, and distinguishes the example from a production deployment.

Key terms: RealTimeAgent, generateImageTool, proxy, image agent, ephemeral key, backend API agent, queue, worker pool, temporary storage, notification mechanism

8.2 Dockerizing agent systems

This section explains why containerized microservices suit agent systems, how a frontend agent can use them, and where the containers can be hosted.

Key terms: microservices architecture, agent API applications, subgoal, frontend agent, API interface, MCP server, multi-agent workflows, Docker Desktop, Kubernetes, web/API application

8.2.1 Containerizing an agent microservice

This section walks through generating, building, running, testing, and locally managing a containerized agent microservice.

Key terms: Dockerfile, Docker Desktop, image, container, OpenAI API key, curl, --name image-gen, logs, CI/CD

8.2.2 Orchestrating agentic systems with Docker Compose

This section shows how Docker Compose defines and runs a local multi-container agent system, then notes a limit of using Compose for cloud deployment.

Key terms: Docker Compose, multi-agent stack, microservices, YAML, Compose version, service definitions, realtime-voice-web, realtime-web-agent, realtime-image-agent, Docker Desktop

8.2.3 Externalizing local agent microservices

Explains how a tunnel can briefly expose local agent services for testing or demos, how to access them with localtunnel, and why production use calls for cloud deployment.

Key terms: tunneling services, external endpoints, ngrok, localtunnel, authentication, rate limiting, cloud deployment, security boundaries, access control, Node.js

8.3 Considering advanced deployment strategies

Introduces the deployment decisions that become important when moving from a proof of concept to a dependable multi-agent system.

8.3.1 Choosing a runtime: Edge, API, or event-driven

This section explains how latency and workload shape the choice between edge, synchronous API, and event-driven worker runtimes for agents.

Key terms: latency, user experience, real-time deployment, Edge (browser/mobile), Synchronous API microservice, Event-driven worker agents, queue, simplest runtime, latency target, tool requirements

8.3.2 The three “wires” of communication

Compares three communication channels for agents and tools and explains how latency and deployment needs guide the choice.

Key terms: WebRTC/WebSocket (Realtime), HTTP + SSE (MCP), message bus, barge-in, wire, latency, deployment requirements, STDIO, HTTP+SSE

8.3.3 Practical multi-agent topologies that adapt well

The section presents a front-door multi-agent topology that accommodates different communication and latency needs while keeping most work and control inside worker agents.

Key terms: front-door agent pattern, orchestrator pattern, backend worker agent, latency, worker agent, flow, orchestrator, collaboration, front-door agent

8.3.4 State, memory, and idempotency

This section distinguishes short-term conversational state from long-term knowledge and explains why idempotent, cacheable tool calls matter when agents retry or replay work.

Key terms: conversational memory, long-term facts, semantic search indexes, vector stores, idempotent, idempotent key, caching, replay, duplicate side effects

8.3.5 Release engineering for agents (prompts, tools, models)

Treat agents as software by versioning their components, releasing changes through gates, and recording the exact model and tool endpoints used for each turn.

Key terms: version everything, prompts, tool schemas, tool servers, safety switches, model selections, promote with gates, offline tests, shadow traffic, miniature canary

8.3.6 Observability matters

This section explains how traces, metrics, and logs make a production agent observable so its behavior and outcomes can be diagnosed.

Key terms: trace spans, correlation IDs, session_id, turn_id, tool_call_id, Phoenix, operational metrics, quality metrics, product metrics, structured JSON logs

8.3.7 Reliability patterns: Timeouts, fallbacks, and budgets

This section explains how time budgets, fallbacks, and circuit breakers help agents handle failures without disrupting users.

Key terms: critical path, time budget, SLA, fallback, fallbacks, circuit breakers, shed load, graceful degradation, operational confidence

8.3.8 Cost control and model routing

This section explains how to control production agent costs through value-based measurement, model routing, context trimming, and deliberate caching without sacrificing output quality.

Key terms: cost-to-value ratio, cost per session, cost per resolved task, cost per user, routing by intent, frontier model, routing accuracy, downstream model or agent, context trimming, compressed history

8.4 Security, safety, and governance in production

The section explains why agents’ ability to act autonomously makes security and safety essential production concerns.

Key terms: agents, autonomously, security, safety, first-class concerns

8.4.1 A quick threat model for agentic systems

This section shows how to map production-agent assets to exposed surfaces and risks, then explains prompt injection and the layered defenses it requires.

Key terms: assets, attack surfaces, threat model, client, gateway/API, agent runtime, tool servers, model provider, storage, prompt injection

8.4.2 Identity and access for people, services, and agents

This section explains how to limit agent access to a user’s permissions, protect browser credentials, and record who uses agents.

Key terms: user authentication, user authorization, tools, MCP servers, RAG systems, ephemeral client secrets, provider API keys, TTL, user objects, tracing

8.4.3 Secrets and configuration management

The section gives production practices for handling secrets and limiting access to tools and resources.

Key terms: container images, runtime, environment variables, secret manager, rotate secrets, scope, least privilege, tools, resources

8.4.4 Tool safety: Sandboxing and egress control

This section explains why agent tools need restricted access and how to secure tools exposed through MCP servers.

Key terms: abusive tool use, hallucinatory agent/LLM, Sandbox, Filesystem, ephemeral, outbound allowlist, internet egress, Resource limits, MCP servers, HTTPS

8.4.5 Prompt-injection and data-exfiltration defenses

This section explains how to reduce prompt-injection risk for user-facing agents through instruction, tool, and execution safeguards while recognizing the limits of prompt rules.

Key terms: untrusted, instruction hierarchy, system prompts, injection, jailbreak attacks, schema-first tools, JSON Schemas, input/output sanitation, allowlists, user authorization

8.4.6 Safety and policy enforcement

This section explains how to enforce production-agent safety and organizational policies through controls that can be checked independently of the agent.

Key terms: policy enforcement, external enforcement, prompt injection, content safety, data privacy and compliance, content filters, data residency, audit and traceability, rate limiting and abuse prevention, access control and authorization

8.5 Exercises

Five hands-on exercises walk the reader from a browser-only voice agent to an API-backed, containerized multi-agent stack.

8.6 Summary

The summary connects deployment choices, agent architecture, and production safeguards to moving agents from demos to dependable systems.

Where this is used later

Concepts explained in this chapter

← Chapter 7: Building robust agents with evaluation and feedback Chapter 9: Understanding the agentic loop →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.