Most agent frameworks persist the conversation, and some checkpoint their execution state; far fewer persist the work itself as an auditable business record. A returns agent needs the customer’s order, the applicable policy, the work already completed by other agents, and a place to record a decision that a human can approve later.
For teams already using Databricks, much of that business context exists in the Lakehouse. The challenge is making it useful inside an interactive application, alongside the state that the application creates.
Databricks Lakebase brings those two sides together: curated business data and operational agent state, accessible through Postgres. Managed synchronization, search, elastic compute, and database branching extend its value across both production and development. [1]
Throughout this post, we use a single example: an e-commerce returns agent. Before recommending a resolution, it retrieves the order and current case state, searches the applicable return policy, and combines that evidence into a proposal. It then records the proposal for approval and tracks the resulting action.
Lakebase supports the data operations throughout this workflow: retrieving business context, searching policy passages, and persisting progress. Each interaction may be small, but an agent can repeat them across several reasoning steps, and many agents can perform them concurrently.
Figure 1 shows how the returns agent moves from the initial request to an approved action. The first step is making the business context available to the agent.
Figure 1. Returns agent workflow, from request to approved action.
Turn Lakehouse data into context agents can use immediately.
A returns agent might need purchase history, delivery information, customer service tier, and prior return activity. In many organizations, data engineering pipelines already reconcile those sources and calculate business attributes.
Publishing that work as a governed context table in Unity Catalog gives every agent the same definition of a customer, an order, and a return. A policy specialist and a customer-service specialist can work from a shared evidence bundle.
Lakebase synced tables make that prepared context available through Postgres. They maintain a managed copy of Unity Catalog data using Lakeflow pipelines, with snapshot, triggered, and continuous synchronization options. Applications can query the served data alongside their own operational tables. Choose the sync mode based on how fresh the data needs to be: continuous sync minimizes lag, while snapshot or triggered sync can cost less when periodic updates are sufficient. Sources without Change Data Feed, such as views and Iceberg tables, support only snapshot sync. [2]
This shortens the path from a data product to an application feature. When the data team improves the customer context, the agent can consume the enriched result without rebuilding those transformations in its own tools.
For the returns application, the data model can stay small:
Table 1. Data ownership for the returns agent: pipelines publish order context and policy evidence, and application tools write case state and retain decision evidence.
The agent reads the published context without modifying it. Application tools write the case state and retain the evidence used in each decision. Once data is served in Postgres, access is enforced by Postgres roles rather than Unity Catalog permissions, so the agent’s role should get read-only access to the served schema, with Row-Level Security by merchant as an additional safeguard.
A useful context contract includes a revision and a processing watermark (the latest source timestamp reflected in the published data). The revision identifies the evidence used in a proposal; the watermark lets the application decide when to refresh it. Lookup speed and evidence freshness are separate design choices.
Bring context and case state into the same query.
Keeping business context and operational state in the same database changes how an agent tool can work.
Suppose a second agent picks up a return that is already under review. It needs both the order information and the current proposal. Fetching them together makes the tool’s result directly useful for the next decision.
Assuming the context is served as agent_serving.return_context and cases live in app.return_case, the lookup can be ordinary Postgres SQL:
SELECT
c.case_id,
c.status,
c.proposal,
c.version AS case_version,
r.service_tier,
r.delivered_at,
r.paid_amount_minor,
r.previous_returns_count,
r.context_revision
FROM app.return_case AS c
LEFT JOIN agent_serving.return_context AS r
ON r.merchant_id = c.merchant_id
AND r.order_id = c.order_id
WHERE c.merchant_id = %(merchant_id)s
AND c.case_id = %(case_id)s;
The application derives the merchant identity from the authenticated session and passes it to the bounded query tool. The model cannot choose or override the merchant. The tool returns the case, its current status, and the context needed to move it forward. The left join keeps the case visible when its context has not synced yet, so the tool can report missing context instead of a missing case.
That boundary keeps responsibilities clear: data preparation remains in the lakehouse, while the agent’s tools focus on decisions and actions.
The chat transcript stays in the application’s conversation store, linked to the return by case ID. The case record in Lakebase holds the current proposal and the evidence used to make it, so a reviewer can pick up the work without replaying the chat.
Give concurrent agents a shared operational state.
A return investigation can involve several activities at once: checking delivery information, interpreting policy, and preparing a customer response. Each activity produces information that the others may need.
Lakebase gives those workers durable shared state. Findings remain available after a worker finishes, an application restarts, or a human takes hours to approve the proposal. Postgres transactions and constraints provide the mechanisms for controlling updates. [1]
A simple way to coordinate the workers is optimistic concurrency control: a write succeeds only if the case is still at the version the agent read. Suppose two agents read version 7 of the same return. The delivery agent finds a carrier delay and saves a proposed refund, advancing the case to version 8. The policy agent then tries to save a different proposal, conditioned on the case still being at version 7:
UPDATE app.return_case
SET proposal = %(proposal)s,
version = version + 1
WHERE merchant_id = %(merchant_id)s
AND case_id = %(case_id)s
AND version = %(expected_version)s; -- 7
The update affects zero rows, which the tool detects by checking the row count. The policy agent reloads version 8 and checks the carrier evidence before deciding whether to revise the proposal.
These are established Postgres capabilities. What Lakebase adds is making them available beside lakehouse-derived context, within the Databricks application environment.
The same design supports a complete workflow:
Table 2. Return workflow stages and what the application records at each step.
Lakebase does not replace the system of record for orders or payments. The order or payment service validates and performs the external action, and Lakebase holds the application’s record of the workflow. The execute step passes the payment service an idempotency key derived from the case ID and its approved version, so a retried call cannot issue a second refund.
For example, a customer requests a return after the standard deadline. The carrier confirms a delivery delay, and the policy allows an extension in that situation. The agent attaches the delivery date and policy passage to its proposal. A reviewer approves it, and the application records the refund reference after the payment service confirms the refund.
Retrieve policies alongside the data they govern.
Return policies combine exact rules with natural-language descriptions. A product code requires precise matching, while “the item arrived damaged” may need semantic matching against a policy written with different terminology.
Lakebase Search supports keyword, vector, and hybrid retrieval through the lakebase_text and lakebase_vector Postgres extensions, with lakebase_tokenizer for configurable tokenization. Lakebase Search is generally available on AWS and Azure and in beta on Google Cloud. It can also index data served from Unity Catalog, including text and embeddings prepared upstream. [3]
For the returns agent, that means policy retrieval can sit alongside order context and case state. The team can prepare and enrich policy content in Databricks, serve it through Lakebase, and expose a focused retrieval tool to the agent. The tool can filter passages by effective date, so the agent applies the policy in force when the order was placed.
As a result, the team can avoid operating a separate vector database and full-text search service for this workload. Relational facts, retrieved passages, and operational writes share a database environment. Databricks AI Search remains the managed option for retrieval over Delta tables; Lakebase Search fits when retrieval needs to sit next to the application’s transactional state.
It also makes evidence easier to retain. A proposal can reference its context revision and preserve the policy passages used to justify it. A reviewer then sees both the recommendation and its basis.
That record becomes valuable beyond the individual case. If reviewers repeatedly overturn recommendations involving one exception, the team has a specific policy or retrieval problem to investigate.
Match database capacity to bursts of agent activity.
Agent workloads often arrive in bursts. A single return request can trigger an order lookup, policy retrieval, a case-state check, and a proposal write. Further reasoning steps may repeat those operations, while other agents process their own requests.
This makes database latency part of the agent’s response time. Sequential tool calls accumulate waiting time, and parallel calls still depend on the slowest required result. Low-latency lookups and short transactional writes help keep the agent moving between reasoning steps as concurrent activity grows.
Lakebase separates Postgres compute from durable storage. Autoscaling adjusts capacity within a configured range while committed application data remains in the storage layer. For the returns application, this supports two useful operating patterns: [4][5]
Production: maintain baseline capacity so interactive requests do not wait for a cold start, and scale up during busy periods.
Development and evaluation: use environments whose compute can suspend between runs.
Connection pooling helps put that capacity to work: connections are used for database operations and released while agents wait for model responses or external services.
Built-in monitoring (CPU, memory, connections, cache behavior, and the most frequent or slowest queries) helps the team tell whether slower responses call for more capacity, better indexing, or changes to how tools access data. [6]
A burst of returns can also raise questions that span many cases. Suppose several customers report damage to the same product. Before flagging a possible batch defect, the agent could compare this week’s similar reports with last week’s. Lakebase’s Lake Transactional/Analytical Processing (LTAP) architecture is designed for that kind of read: registered Lakebase data can be queried from Lakehouse//RT, a Databricks SQL warehouse built for real-time analytics, without slowing down the Postgres writes that record incoming cases. Lakehouse//RT is in beta, and querying live Lakebase data from it is currently in private preview, so treat this path as forward-looking. [7]
Together, these cover different workload shapes: responsive reads and writes for individual cases, elastic capacity for concurrent agents, and an emerging analytical path for questions that span many cases.
Test changes to the agent’s data as easily as changes to its instructions.
Agent quality depends on the information supplied to the model. Adding delivery exceptions, changing how customer history is summarized, or improving policy passages can affect decisions as much as a prompt change.
Lakebase branching makes those changes easier to evaluate. A branch inherits its parent’s schema and data using copy-on-write storage, then evolves independently. Teams can create an isolated database environment without building a full export-and-restore process. [8]
For the returns agent, create baseline and candidate environments from the same database starting point. Keep the requests and model configuration consistent, then change one part of the candidate’s context. Because model outputs vary, run each configuration several times before treating a difference as real.
One detail matters when the context arrives through synced tables. A branch captures the synced data as it was when the branch was created, and the managed pipeline keeps updating only the branch the synced table belongs to. To test a context change, publish the candidate version as a separate Unity Catalog table, sync it into the candidate branch, and point the candidate’s context tool at it. Changes that live only in Postgres, such as the case-state schema or how proposals are stored, can be made directly on the branch.
Table 3. Baseline and candidate experiments for the returns agent.
Record the data revision with the application and model versions in the evaluation results, for example as MLflow run parameters. Point action tools at sandbox or mock endpoints during these experiments, so no evaluation run can trigger a real refund. Because a branch copies production data, mask customer details in the branch before using it for evaluation.
Agent context becomes a versioned engineering input. The team can test whether a data change improves outcomes before publishing it into the production serving path.
Branching also helps developers work independently. A schema change for one agent does not require every developer to adopt it immediately.
Connect the workflow to the rest of Databricks.
The platform fit becomes clearer when the components are assembled:
Figure 2. Reference architecture for the returns agent.
Databricks Apps can attach Lakebase as a database resource, with a Postgres role associated with the app’s service principal and connection settings supplied to the application. Database state persists across app deployments. [9]
MLflow tracing provides the execution view: model calls, tool inputs, outputs, and durations. Instrumenting the context and policy tools makes it possible to connect a recommendation to the information the agent consumed. [10]
The case record and the trace answer complementary questions. The case shows what happened to the return. The trace shows how the agent arrived at a particular proposal.
For a team already preparing data and serving models on Databricks, this reduces the integration work between data engineering, application development, and agent evaluation.
Conclusion: from reasoning to completed work.
A chat history records what the agent said. A case record shows what it did, which evidence it used, and what still needs approval.
For the returns agent, Lakebase keeps governed context available for decisions and gives the application a durable place to record proposals and outcomes. Database branches let the team compare changes before they reach production.
A read-only assistant that answers from static documents can usually rely on its existing retrieval layer and chat store. A dedicated operational backend pays off when work spans sessions, needs approval, or requires an audit trail.
That is what makes Lakebase useful beyond chat history: an operational backend for the repeated data interactions that turn an agent’s reasoning into completed work.