Skip to main content

How should an AI agent store conversation checkpoints, user preferences, tool results, and approval state?

Summary

  • Agent state consists of four layers: conversation checkpoints (session context), user preferences (learned behavior), tool results (execution history), and approval state (workflow status).
  • Lakebase provides a single unified backend for all agent state, scaling automatically and integrating natively with Unity Catalog for governance and access control.
  • Store checkpoints and approval state in structured tables; user preferences in queryable schemas; tool results in either structured logs or unstructured artifact storage depending on size and type.
  • A well-designed state schema allows agents to recover mid-conversation, learn user intent over time, and maintain compliance audit trails for every decision.
  • You can implement this yourself with Lakebase and LangGraph or use Databricks managed agent memory, which automates provisioning and recovery.

How should an AI agent store conversation checkpoints, user preferences, tool results, and approval state?

Agent state is not monolithic; it's four distinct layers that each serve a different purpose. A well-designed agent system stores all four together so the agent can recover from failures, remember what matters to users, know what it tried, and prove what it was authorized to do. Lakebase is the unified backend designed for this.

The four layers of agent state

Conversation checkpoints capture the turn-by-turn state of a single session: the messages exchanged, the model's reasoning, and any intermediate decisions. User preferences are learned patterns: which data sources a user trusts, favorite output formats, communication style, and role-specific workflows. Tool results are the outcomes of every action the agent takes: which APIs succeeded or failed, what data was retrieved, and what errors occurred. Approval state is the workflow layer: whether an action is pending review, who approved it, whether it ran, and any audit trail.

Layer What it stores Why it matters Typical query
Checkpoints Messages, reasoning, decisions, turn history Recovery and continuity within a session "Resume conversation from message ID 42"
Preferences User intent, output style, trusted sources, role Agent personalization and efficiency "What does this user prefer for report format?"
Tool results API responses, execution logs, success/failure codes, data retrieved Debugging, compliance, learning what worked "Did this query execute? What was returned?"
Approval state Action status, reviewer identity, timestamps, authorization level Governance, compliance, audit trail "Who approved this transaction? When?"

How Databricks approaches agent state storage

Lakebase is a serverless, fully managed PostgreSQL backend that stores all four layers in a single workspace. When you create an agent in Databricks, you define state tables registered in Unity Catalog. Lakebase handles provisioning, automatic scaling, and backup.
For conversation checkpoints, use a agent_checkpoints table with columns for session ID, turn number, messages (as JSON), reasoning (model's intermediate steps), and a timestamp. For user preferences, create a user_profiles table keyed by user ID with columns for each learned attribute. Tool results go into an execution_log table with tool ID, parameters, output, and result code. Approval state lives in a workflow_state table with action ID, status (pending/approved/executed/rejected), reviewer, and timestamps.
All four tables are queryable with SQL, so your agent can join across them at runtime. For example, before executing a data export, the agent queries the approval state table to check authorization, the user preferences table to apply output format, and the execution log to see if this export ran recently.

Recovery, learning, and compliance

This architecture enables three critical capabilities. First, recovery: if an agent crashes mid-conversation, it reads the latest checkpoint and resumes from that turn. Second, learning: the agent queries its own execution log and user preferences to improve over time, identifying which tools work best for each user and context. Third, compliance: every action is immutable in the workflow state table, giving auditors a complete record of what ran, who approved it, and why.

Implementation options

You have two paths. Self-managed: define your state schema in Python or SQL, use LangGraph for checkpoint management and recovery logic, and Lakebase for the persistent store. This gives you full control over the schema and retrieval patterns. Managed: use Databricks agent memory, which provisions the state schema automatically and handles checkpoint recovery and user preference tracking for you. Both approaches store data in Lakebase with Unity Catalog governance.

Real-world state management

Financial services: An approval workflow agent stores every loan decision in the workflow state table. Checkpoints allow recovery if processing fails mid-approval. The compliance team queries the execution log to prove every decision was logged and authorized.
Customer support: Checkpoints let the agent pick up a conversation after a restart. User preferences store communication style and resolved issues for this customer. The tool results log shows which knowledge base articles were actually useful, helping the agent refine its recommendations.
Data analysis: Checkpoints store the session's exploration path so the agent can recover analysis after a compute restart. User preferences capture which visualizations and data sources each analyst prefers. Tool results track query performance and help the agent learn which queries are most efficient for each dataset.

FAQs

Should I store all state in a single table or multiple tables?

Multiple tables. Checkpoints change frequently (per turn), user preferences change rarely (once per user session), tool results accumulate (immutable logs), and approval state changes on workflow events. Separate tables let you optimize each for its access pattern and retention policy.

How long should I keep checkpoints?

Keep recent checkpoints for recovery (typically 24 hours or the agent's session TTL). Older checkpoints can be archived to cheaper storage. User preferences and approval state should be kept indefinitely for learning and compliance.

Can I use Lakebase for both the agent's long-term memory and its runtime state?

Yes. Lakebase stores both the runtime execution log ("I just called tool X and got result Y") and the long-term memory ("I learned that this user prefers JSON output"). They coexist in the same workspace, queryable together.

What if my approval workflows require external review?

Your approval state table records the pending action with fields for reviewer comments and deadlines. When external review completes, you update the table and the agent resumes. Unity Catalog access controls ensure only authorized reviewers can modify approval state.

How do I handle tool results that are very large or unstructured?

Store small, structured results (API responses, data summaries) directly in the execution log. For large or unstructured data (images, PDFs, raw files), store a reference or object ID in the execution log and keep the artifact in Unity Catalog volumes or an external store. Link them by ID for recovery.

The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.