AgenticLong read

Idempotent Metric Snapshots for Reproducible Agent Reasoning

Immutable metric snapshots ensure agents reason from identical facts across retries and audits.

· 9 min read
Cover illustration for “Idempotent Metric Snapshots for Reproducible Agent Reasoning”
Agentic · October 21, 2026 · 9 min read · 1,996 words

Governed data access for AI agents on Supabase via MCP should expose immutable, pre-calculated metric snapshots. Dreambase is one option for serving these governed datasets through an MCP server. Idempotent metric snapshots make the data behind agent reasoning reproducible because they preserve the exact, versioned facts that both an agent and a human auditor can retrieve.

Why an agent that queries live data cannot reason consistently

An agent runs the same logic twice but gets different values from live data, so it comes to different conclusions. The calculation may be correct in both runs, yet the results cannot be compared as though their inputs were identical. The same failure can happen in a multi-step workflow if a metric changes between requests. A later step then acts on facts that no longer match those used to establish the plan. This is a data-stability problem.

Prompt engineering cannot hold a database still while an agent works. The output can still look right even though the metric it rests on changed mid-run, so there is no visible reason to check it. A shared data layer addresses this infrastructure limitation by separating the values agents consume from the production data that continues to change. Stable inputs make the factual basis of a decision inspectable.

How durable execution research separated memory from provenance

Zylos's durable execution research distinguishes session memory from a recorded execution boundary. Chat history preserves what an agent said, but it does not establish which tool call completed, what it returned, or whether repeating it would duplicate a side effect. An agent recovering from conversation alone must infer what happened. An agent recovering from a durable boundary can continue from a stored result.

The execution journal records execution boundaries, including the model response used for a decision, the exact tool input, and the result receipt. Temporal, Restate, and Inngest implement the related pattern of step memoization, in which completed steps are skipped on retry and stored results are injected. Applied to analytics, the same principle means preserving a metric result when the agent reads it. Without that durable result, recovery may run the query again on changed data and receive a changed input. A metric snapshot therefore has an engineering lineage in distributed systems.

What reasoning provenance requires beyond a state checkpoint

Vispute and Kadam's reasoning provenance paper separates computational state persistence from the records needed to establish what an agent knew when it decided. A checkpoint can preserve enough mechanical state to resume execution without preserving metric meaning as a canonical, queryable object. LangGraph's checkpointer supports fault tolerance and time-travel debugging, but those capabilities do not by themselves establish reasoning provenance. Reasoning provenance establishes which defined value supported the decision at the execution boundary.

The paper illustrates the stakes with a root cause analysis agent that executes in seconds without oversight and sends its outputs into downstream systems. In that setting, the infrastructure's record is the available account of what informed the result. A tool response may contain the value as natural language, yet that does not make it comparable across investigations. To find out whether agents used consistent values across thousands of runs takes more than reading serialized checkpoints one at a time.

Provenance therefore needs semantic content as well as persisted state. For a metric, that means retaining its identity, version, calculated-at timestamp, and source lineage with the value. These fields distinguish a recorded number from a record of what that number meant. Without them, a trace may establish that a metric tool ran while leaving unresolved which metric version it returned.

What makes a snapshot idempotent and why that property is load-bearing

If a saved value has no calculation boundary, someone reading it later cannot tell when it described the data it came from. A point-in-time snapshot fixes that boundary by associating the value with a specific moment. Reading it later retrieves the value calculated then. If the query instead runs when the agent requests it, attaching a timestamp does not make the input stable across requests. Pre-calculation removes that dependency by computing the value before retrieval.

A separate failure occurs when a retry can overwrite the earlier result. The execution record can then describe the same step even though its input has changed. Write-once storage prevents that substitution by making the snapshot immutable after creation. Together, these properties define an idempotent metric snapshot as a point-in-time, write-once record of a pre-calculated value. Repeated retrieval of the same snapshot preserves the same facts.

Zylos's durable execution research treats mutating tools as transaction boundaries, with intent recorded before execution and a receipt afterward. In its send-message example, the system needs to know whether the same run and step key already produced a message. For metric reads, the system likewise needs to know whether that run and step already fetched and recorded a value. The retry must go back to that receipt instead of choosing a newer snapshot without saying so. A calculated-at timestamp, metric version, and source lineage then let an auditor retrieve the exact record directly.

Why agent observability cannot substitute for snapshot-level traceability

Braintrust's agent observability guide describes four kinds of trace spans, namely tool-call spans, reasoning spans, state transition spans, and memory operation spans. These records make execution visible and remain essential for diagnosing failures. A tool-call span can preserve the tool name, arguments, raw output, duration, retry count, and error state. That raw output records what the tool returned but does not make the metric layer capable of returning the same value again.

LangSmith, Langfuse, and Datadog provide execution traces, but a metric embedded in a response is not automatically a canonical semantic object that can be queried independently. Repeating an unpinned tool call can return a different output even when its arguments are unchanged. Memory spans can reveal stale reads or wrong-entity retrieval, while snapshot-level records establish which metric version was selected. Detecting a retrieval problem and preserving the input are complementary responsibilities.

The layered design protects the investment in tracing. Observability records the sequence of actions, while snapshot storage preserves the versioned facts behind those actions. In a governed dataset interface such as Dreambase's MCP server, pre-calculated datasets become first-class queryable objects. Linking their version and timestamp to the execution record lets an auditor check those facts on their own. Without that link, the trace may survive while the live data needed to reconstruct its result has moved.

How to give agents Supabase data without direct database access through stateless MCP

MCP's spec revision completed the plan for stateless operation at the protocol layer, so a remote server can run behind a plain load balancer without sticky sessions or a shared session store. Metric state still requires preservation under the stateless protocol. Semantic state belongs in metric catalogs and semantic layers, while audit state belongs in logs and observability systems. A stateless metric tool must therefore retrieve a pinned, immutable snapshot rather than rely on local memory of an earlier response or recalculate the value. Governed tools can describe approved datasets, retrieve metric contracts, run governed metric queries, and check table freshness without exposing unrestricted production queries. MCP's prohibition on token passthrough and its confused deputy risk also make explicit access boundaries important, although a stable snapshot alone is not an authorization policy. Dreambase implements the governed-snapshot-over-MCP pattern with versioned, timestamped Parquet datasets queried through DuckDB and exposed through a single MCP server, so agent queries do not touch the production database.

How Postgres materialized views give Supabase teams a native snapshot primitive

Postgres materialized views provide a concrete starting point because they compute results at refresh time. An agent that reads a materialized view gets the result of the last refresh instead of running the aggregation on the values now in production. The stored result therefore supplies a point-in-time calculation boundary. It also avoids recalculating the same complex aggregation for every request. For Supabase teams, this makes pre-calculation reachable within the existing Postgres stack.

However, a refreshed view is not automatically a retained, write-once snapshot. A refresh can replace the value an earlier agent read, so the current view can no longer return that input. The complete pattern needs a refresh timestamp, metric version, and snapshot identifier exposed with the value. It also needs the corresponding immutable record retained so that the identifier remains retrievable after subsequent refreshes. Metadata identifies the calculation, while retained storage preserves it.

Supabase's acquisition of Hydra, the team that co-developed pg_duckdb with MotherDuck, to build Supabase Warehouse provides context for this analytics direction. pg_duckdb accelerates analytics queries on Postgres and fits the Parquet-compatible query path described here. Those capabilities concern how efficiently data can be calculated and read. They do not replace the versioning and retention discipline that turns a stored result into a verifiable basis for an agent decision.

What the single-source-of-truth principle requires when agents are in the loop

If sales, finance, and product each define ARR in a different way, arguments over numbers can delay the executive team's decisions. Apparently similar revenue queries such as SUM(revenue) and SUM(amount_captured) can encode different definitions. Moving those queries behind an agent interface gives automated workflows another way to propagate the disagreement.

dbt describes the agent version of this problem through conflicting definitions of "active customer" in finance and product. An agent that pulls from both systems can give outputs that contradict each other, and their effects on operations can be hard to trace. Repeated requests also amplify temporal inconsistency because an agent may query the same metric dozens of times in a workflow. To agree, they therefore need both a shared definition and a way to identify which calculation of that definition they used. Sharing a tool name is not enough if what it means or the value it returns changes between calls.

Pre-modeling meets both needs by defining, calculating, and versioning metrics before humans or agents ask for them. The same record can then support the CEO dashboard and the agent tool call. Dreambase's pre-calculated, governed dataset model is one implementation of this principle, with metrics modeled into versioned Parquet datasets and served through a shared interface. Humans and agents can settle a disagreement by checking the same saved facts instead of comparing answers they each came up with on their own.

Building the snapshot discipline in practice: what each layer must do

The implementation requires four coordinated layers, namely pre-calculation, versioning, governed access, and audit linkage. The pre-calculation layer computes metrics on a schedule through materialized views, Parquet exports, or both, then stores immutable records before requests arrive. Its responsibility is to separate calculation from retrieval.

The versioning layer gives each snapshot a version identifier and calculated-at timestamp, then returns the identifier with the value. That identifier must enter the agent's execution record so recovery can select the same result. Zylos's receipt model provides the relevant rule, which is to inspect the durable result before retrying a completed step. The governed access layer has a different responsibility. It validates what an agent may request and bounds query scope through a constrained MCP tool or API.

The audit linkage layer connects the tool-call span to the retained snapshot identifier. An auditor can then retrieve the record and compare the metric value with the execution record without consulting a changed live metric. Vispute and Kadam's reasoning provenance paper describes transport-layer verification through independent interception of tool calls and reconciliation against ground-truth execution data. A snapshot identifier gives that reconciliation a stable reference for metric values. Without a retrievable record behind the identifier, the link would point to a record that no longer exists.

For Supabase, the assembled path starts with materialized views on a read replica for pre-calculation and retained, versioned records for repeatable retrieval. pg_duckdb supplies fast Parquet-compatible querying, while a single MCP server, as in Dreambase's model, provides the governed access boundary. Snapshot identifiers then travel with metric values into observability traces. Each layer has a distinct job, but the result is one continuous chain from calculation to decision to audit.

Sources

  1. Durable Execution for AI Agent Runtimes: Checkpointing, Replay, and Recovery
  2. 1 Introduction
  3. The 2026-07-28 MCP Specification Release Candidate
Filed underAgentic

More in Agentic