14 Productionizing AI Agents: memory, guardrails, and beyond

 

This chapter covers:

  • Adding short-term memory with LangGraph checkpoints
  • Implementing guardrails at multiple workflow stages
  • Additional considerations for production deployment

Building AI agents that behave reliably in real-world environments is about more than just connecting a language model to some tools. Production systems need to maintain context across turns, respect application boundaries, handle edge cases gracefully, and keep operating even when something unexpected happens. Without these safeguards, even the most capable model will eventually produce errors, off-topic answers, or inconsistent behavior that undermines user trust.

In this chapter, we’ll focus on two of the most important capabilities for making AI agents production-ready: memory and guardrails. Memory allows an agent to “remember” past interactions, enabling it to hold natural conversations, answer follow-up questions, and recover from interruptions. Guardrails keep the agent within its intended scope and policy framework, filtering out irrelevant or unsafe requests before they reach the model—and, if needed, catching inappropriate responses after the model has generated them.

14.1 Memory

14.1.1 Types of Memory

14.1.2 Why Short-Term Memory is Needed

14.1.3 Checkpoints in LangGraph

14.1.4 Adding Short-Term Memory to Our Travel Assistant

14.1.5 Executing the Checkpointer-Enabled Assistant

14.1.6 Rewinding the State to a Past Checkpoint

14.2 Guardrails

14.2.1 Implementing Guardrails to Reject Non-Travel-Related Questions

14.2.2 Implementing More Restrictive Guardrails at Agent Level

14.3 Beyond this chapter

14.3.1 Long-term user and application memory

14.3.2 Human-in-the-loop (HITL)

14.3.3 Post-model guardrails

14.3.4 Evaluation of AI agents and applications

14.3.5 Deployment on LangGraph Platform and Open Agent Platform (OAP)

14.4 Summary