Skip to content
Back to blog

Iceberg Lakehouse for Agentic AI

Agents don't only read your lakehouse. They write to it, and every run leaves traces you have to keep. How to design Iceberg branches, snapshots, trace tables, and maintenance for agentic AI.

Illustration of three AI agents writing to and reading from an Iceberg lakehouse, with data files flowing in and a maintenance loop around it

An Iceberg lakehouse for agentic AI is designed for three data flows at once: what agents read, what agents write, and the record of what agents did. Most writing about agents and lakehouses covers only the first flow. The other two are where production systems break: an agent commits a bad MERGE to a shared table, an auditor asks which data produced an answer six weeks ago, or a trace table grows to hundreds of thousands of small files in a month.

The volume is already real. Databricks reported in March 2026 that in its Lakebase service, AI agents create roughly 4x more databases than human users, and Gartner expects 40% of enterprise applications to include task-specific AI agents by the end of 2026, up from less than 5% in 2025. Agents like these read and write at machine speed, and they don't file a ticket before changing a table.

Iceberg already ships the primitives this needs: snapshots, branches and tags, time travel, row-level deletes, and in format v3, row lineage, deletion vectors, and a variant type. This guide shows how to use them for agent workloads: branch-isolated writes with an audit step, snapshot pinning so answers can be reproduced, trace tables built on OpenTelemetry's GenAI conventions, memory tables you can erase, and the maintenance all of it creates.

Those primitives only hold up if the tables stay healthy and the retention rules match what agents need, and that operational loop is the part the open stack doesn't provide as one system. A control plane such as LakeOps supplies it on top of an existing Iceberg stack. It connects to the catalogs you already run (AWS Glue or any Iceberg REST catalog, such as Apache Polaris or Project Nessie), reads table metadata (snapshots, manifests, and file statistics) to decide what each table needs, and runs maintenance in place on its own engine. Its maintenance copies no data and runs outside the query path. Agents reach the same backend over MCP, and every operation lands in one audit record, whether a policy, a person, or an agent started it.

Lakehouse control plane diagram: LakeOps above an Amazon S3 data lake, connected to Iceberg catalogs and query engines
The control plane connects to catalogs, Iceberg tables in object storage, and engines. Maintenance reads metadata and rewrites files in place, outside the query path.

For the wider architecture, the agentic lakehouse page shows how intelligence, safe agent access, and agentic operations fit together, and the agentic lakehouse on Apache Iceberg guide walks through the reference design. This article stays one level down, at the tables: how agent data should be laid out, isolated, retained, and maintained.

Three data flows an agentic system puts on the lakehouse

An agentic system touches the lakehouse in three different ways, and each needs a different Iceberg mechanism. Treating them as one workload ("agents run SQL") is how teams end up with agents writing straight to main and no way to replay an answer.

FlowTypical tablesIceberg mechanismWhat breaks without it
ReadsFacts, dimensions, and documents agents query for contextPinned snapshots, time travel, vended credentialsNumbers change between steps of one run; answers can't be replayed
WritesAgent-generated tables, corrections, enrichments, long-term memoryBranches, write-audit-publish, MERGE with row-level deletesUnreviewed writes land on main; one bad run corrupts a shared table
RecordsTraces, tool calls, evaluations, answer provenancePartitioned append tables, tags, explicit retentionNo audit trail; the replay window disappears with snapshot expiry

The flows also want different retention. Reads want old snapshots kept long enough to replay an answer. Writes want short-lived branches that disappear after review. Records want long retention for audit, plus guaranteed physical deletion when a user asks to be forgotten. Iceberg can do all three, but its defaults match none of them: a branch or tag created without a RETAIN clause is kept forever, while expire_snapshots removes snapshots older than five days unless you configure it otherwise.

The rest of this guide takes the flows in order, then covers the maintenance they generate, because that's where a lakehouse that serves agents succeeds or slowly degrades.

Reads: give every agent run one snapshot

A single agent run often issues ten or twenty queries: discover tables, check a schema, aggregate, drill down, compare. If ingestion commits to the table between step three and step seven, the agent reasons over two different versions of the data and can produce totals that don't add up. A person rereading a dashboard notices; an agent chaining tool calls doesn't.

The fix is to resolve the table's current snapshot once, at the start of the run, and read that snapshot for every query in the run. Log the snapshot ID with the answer, and the same ID later lets you replay it. Iceberg exposes the head of each branch in the refs metadata table, and time travel syntax takes the snapshot ID directly:

sql
1-- Spark: resolve the head of main once, at the start of the run2SELECT snapshot_id3FROM lake.sales.orders.refs4WHERE name = 'main';5 6-- Every query in the run reads that snapshot, not the moving head7SELECT region, sum(amount) AS revenue8FROM lake.sales.orders VERSION AS OF 89545970674934229559WHERE order_date >= DATE '2026-11-01'10GROUP BY region;

Trino uses FOR VERSION AS OF with the same snapshot ID, and its Iceberg connector exposes the same history through the $snapshots and $refs metadata tables:

sql
1SELECT region, sum(amount) AS revenue2FROM lake.sales.orders FOR VERSION AS OF 89545970674934229553WHERE order_date >= DATE '2026-11-01'4GROUP BY region;

Two details matter. A snapshot read uses the schema as of that snapshot, so a column added later isn't visible in a pinned read. And if a branch or tag name happens to equal a snapshot ID, the snapshot ID wins, so don't name refs with bare numbers.

One identity per agent, short-lived credentials

Pinning fixes consistency; it does nothing for access. Agents should never share a long-lived storage key. The Iceberg REST protocol lets a client request delegated storage access per table through the X-Iceberg-Access-Delegation header (vended-credentials or remote-signing), defined in the REST catalog OpenAPI spec. Catalogs then decide what each principal receives. In Apache Polaris, for example, `TABLE_READ_DATA` grants short-lived read-only storage credentials and `TABLE_WRITE_DATA` grants read and write, so a research agent and a remediation agent can be two principals with two different grants instead of one shared key.

Catalog grants decide which tables an agent can touch. They don't decide what SQL it may run, how many rows it can pull, or which engine pays for the query. Those controls belong in a query layer in front of the engines. QueryFlux, the open-source SQL proxy maintained by the LakeOps team, is one such layer: it gives agents one SQL endpoint instead of keys to every engine, and applies row filters and column masks above the engines, so a notebook, a dashboard, and an agent all get the same rewrite. The eight access layers for enterprise agents post covers that stack in depth, so this guide moves on to the part that post doesn't: what happens when agents write.

Writes: put every agent run on a branch

Agents write more than most teams plan for: enrichment columns, corrected records, generated summary tables, long-term memory. The failure modes are not exotic. An agent misreads a join and duplicates rows, hallucinates values into a lookup table, or drops a filter on a DELETE. Research on agent-safe lakehouses argues that data branching extends naturally to agents, with changes checked for correctness before they're accepted, the same way code changes are.

Iceberg branches give you that isolation at table level with no data copy. A branch is a named reference to a snapshot lineage; writes to it create snapshots that main doesn't see until you publish them. The pattern for an agent run is: create a branch, write only to the branch, audit it, then fast-forward main or drop the branch.

sql
1-- 1. One branch per agent run, with short retention so abandoned runs clean up2ALTER TABLE lake.crm.account_notes3  CREATE BRANCH run_20261129_7f3a RETAIN 3 DAYS;4 5-- 2. The agent writes only to its branch6INSERT INTO lake.crm.account_notes.branch_run_20261129_7f3a7SELECT account_id,8       note,9       'agent:renewals-v2'  AS written_by,10       'run_20261129_7f3a'  AS run_id,11       current_timestamp()  AS written_at12FROM agent_output_staging;13 14-- 3. Audit the branch before anyone else can read it15SELECT count(*)                     AS new_rows,16       count_if(account_id IS NULL) AS missing_keys,17       count(DISTINCT account_id)   AS accounts_touched18FROM lake.crm.account_notes VERSION AS OF 'run_20261129_7f3a'19WHERE run_id = 'run_20261129_7f3a';20 21-- 4a. Publish: move main to the branch head22CALL lake.system.fast_forward('crm.account_notes', 'main', 'run_20261129_7f3a');23 24-- 4b. Or reject: drop the branch; expiry removes its snapshots once they pass the age cutoff25ALTER TABLE lake.crm.account_notes DROP BRANCH run_20261129_7f3a;

The audit step is where the value is. Row counts, null keys, duplicate keys, value ranges, and a diff against main are cheap queries on a branch, and they run before any consumer, dashboard, or other agent reads the result. Failing runs cost nothing but the dropped branch.

The rules that bite in production

  • The branch must exist before the write. Per the Spark writes docs, writing to table.branch_x doesn't create the branch; the run fails instead. Create it in the orchestration step that starts the run.
  • Fast-forward needs a linear history. fast_forward only succeeds when main is an ancestor of the branch head. If ingestion committed to main during the run, the call fails. For append-only runs, cherrypick_snapshot can apply the branch snapshot onto the new main (only append and dynamic-overwrite snapshots can be cherry-picked); otherwise rebuild the branch from the new head and rerun the audit.
  • Set retention on every branch. A branch without RETAIN lives forever, and so do the snapshots and data files it references. Abandoned agent branches are a slow storage leak.
  • Session-level WAP is the alternative. With write.wap.enabled=true, setting spark.wap.branch routes a session's writes to a branch without changing table names in the SQL. You can't combine it with an explicit branch_ identifier in the same write.
  • Publishing is per table. Each table commits independently. An agent that writes three related tables can leave consumers seeing one published and two pending. The REST spec defines a multi-table commit endpoint (transactions/commit), but catalog support varies; without it, publish in dependency order and let readers key off the last table.
  • Engines differ. Creating, writing, and querying branches is supported in the Iceberg Java library, Spark, and Flink. Trino reads branches and tags with FOR VERSION AS OF 'name'.

Not every agent write needs the same ceremony. A simple rule set covers most cases:

Agent writePatternAudit before publish
Appending enrichment rowsBranch per run, fast-forwardRow count, null and duplicate keys
Correcting existing rows (MERGE, UPDATE)Branch per run, fast-forwardDiff of changed rows against main, change ratio cap
Deleting rowsBranch per run, never directly on mainDeleted-row count against an expected bound
Creating a new tableAgent-owned namespace; promote with a reviewed CREATE TABLE AS SELECTSchema and row count review
Changing a schemaNot from an agent; a human-owned migrationNot applicable

Schema changes stay out of agent hands for a mechanical reason as well as a governance one: branch writes use the table's current schema, so an agent can't evolve a schema on a branch in isolation the way it can change data.

Memory and state: what belongs in Iceberg

"Agent memory" covers very different data, and only some of it belongs in a table format with second-scale commits and optimistic concurrency. Iceberg is the right home for memory that must be durable, shared across agents, queryable by engines, and erasable. It's the wrong home for per-step scratch state that changes every few hundred milliseconds.

Memory typeAccess patternWhere it belongs
Working state inside a runMillisecond reads and writes, overwritten constantlyAgent runtime or an OLTP database
Conversation historyOne append per turn, read by conversationOLTP for live reads; Iceberg append table as the durable record
Long-term memory (facts about users, accounts, entities)Upserts by key, shared by many agents, must be erasableIceberg table with MERGE; v3 deletion vectors keep updates cheap
EmbeddingsSimilarity searchA vector index built from an Iceberg source table
Evaluation datasetsVersioned, reproducibleIceberg tables, tagged per evaluation run

Embeddings deserve a note. Iceberg has no vector type in any ratified spec; a vector type proposal is still an open issue. The workable design today keeps text, metadata, and an embedding-model version in an Iceberg table as the source of truth, and builds the index elsewhere: a vector database, pgvector, or Amazon S3 Vectors, generally available since December 2025 with up to two billion vectors per index. When the embedding model changes, you rebuild the index from the table, not from whatever the old index happened to hold.

Forgetting a user takes three steps

Long-term memory about people is personal data, and a DELETE alone doesn't remove it. Iceberg keeps data files for as long as any snapshot that may be used for time travel or rollback still references them, per the maintenance docs. Physical erasure means deleting the rows, rewriting any files that still hold them, and expiring the snapshots that point at the old files:

sql
1-- 1. Logical delete. On merge-on-read tables this writes delete files2--    (deletion vectors on v3); copy-on-write rewrites the files immediately.3DELETE FROM lake.agents.long_term_memory WHERE user_id = 'u_48213';4 5-- 2. Merge-on-read only: rewrite every data file that has a delete attached6CALL lake.system.rewrite_data_files(7  table   => 'agents.long_term_memory',8  options => map('delete-file-threshold', '1')9);10 11-- 3. Expire snapshots that still reference the old files; expiry deletes12--    data files no remaining snapshot references13CALL lake.system.expire_snapshots(14  table       => 'agents.long_term_memory',15  older_than  => TIMESTAMP '2026-11-29 12:00:00',16  retain_last => 117);

Expiry never removes a snapshot that a branch or tag still references. That's what makes tags useful for audit, and it's also why memory tables should stay out of long-lived audit tags: one forgotten RETAIN 365 DAYS tag keeps the deleted rows on disk for a year. Keep personal memory in its own namespace with short retention, and put audit tags on the reference data agents read, not on what they remember about people.

Traces: an agent telemetry table that survives audit and scale

Every agent run produces spans: model calls, tool calls, sub-agent invocations, token counts, errors. The platforms already treat this as table data. Databricks stores MLflow traces in OpenTelemetry format as Delta tables in Unity Catalog, and Snowflake records Cortex Agents activity as OpenTelemetry-style events you query with SQL. On an Iceberg lakehouse, the same data becomes an open table any engine can query and join with the business data the agent touched.

The per-step record matters more than it first appears. The QueryFlux team followed one scripted, agent-shaped session through their proxy: a single question took 13 tool calls and returned four confident zeros before the right count. Without a record of every step, those zeros look like answers.

There's a fair counterargument. Braintrust's case for a dedicated trace lake points out that a single trace can run to about 10 MB and that traditional warehouses are too slow at ingest and query for agent traces. That's a real constraint, and it doesn't conflict with a lakehouse: keep a hot, purpose-built store for interactive debugging, and land the same spans in Iceberg as the durable system of record for cost, audit, evaluation, and joins.

For column names, the OpenTelemetry GenAI semantic conventions define attributes such as gen_ai.operation.name (for example chat or execute_tool), gen_ai.request.model, gen_ai.usage.input_tokens, gen_ai.tool.name, gen_ai.tool.call.id, and gen_ai.conversation.id. The conventions are still marked Development, so promote the attributes you query into typed columns and keep the full attribute map as raw JSON. A rename upstream then costs a backfill, not lost data.

sql
1CREATE TABLE lake.agents.agent_spans (2  trace_id         STRING    NOT NULL,3  span_id          STRING    NOT NULL,4  parent_span_id   STRING,5  conversation_id  STRING,     -- gen_ai.conversation.id6  agent_name       STRING,     -- gen_ai.agent.name7  operation_name   STRING,     -- gen_ai.operation.name8  request_model    STRING,     -- gen_ai.request.model9  tool_name        STRING,     -- gen_ai.tool.name10  tool_call_id     STRING,     -- gen_ai.tool.call.id11  input_tokens     BIGINT,     -- gen_ai.usage.input_tokens12  output_tokens    BIGINT,     -- gen_ai.usage.output_tokens13  status_code      STRING,14  start_time       TIMESTAMP NOT NULL,15  end_time         TIMESTAMP,16  attributes       STRING      -- full span attributes as JSON17)18USING iceberg19PARTITIONED BY (days(start_time));20 21ALTER TABLE lake.agents.agent_spans22  WRITE ORDERED BY agent_name, conversation_id, start_time;

Iceberg v3 adds a VARIANT type for semi-structured data, which fits the attribute map better than a JSON string. Check every engine that reads the table before using it: Trino's v3 support is experimental, Amazon Redshift's v3 support excludes variant, and BigQuery reads v3 tables but not variant columns. Until all your readers handle it, a JSON string is the portable choice.

Layout: partition for time, sort for conversations

Trace queries come in two shapes: aggregates over a time window ("tokens per agent this week") and lookups of one conversation or trace ("show me what this run did"). The two layers of pruning map onto those shapes:

  • Partitioning by day is the coarse filter. A seven-day aggregate opens seven partitions out of hundreds.
  • Sort order is the fine filter. Writing rows ordered by agent_name, conversation_id, start_time gives each data file tight min and max statistics on those columns, so a lookup for one conversation skips most files inside a day's partition. The leading column gets the strongest pruning; a filter on conversation_id alone still benefits because rows for one conversation sit together within each agent's range.
  • Z-order isn't needed here. It earns its cost when two to four columns are filtered independently with equal weight, which trace lookups don't do.

Ingestion is where this layout erodes. There's no official Iceberg exporter in the OpenTelemetry Collector, so spans usually travel through Kafka into Flink or Spark streaming, or into a managed topic-to-table service. Flink commits on every checkpoint and Spark Structured Streaming on every micro-batch, so the table collects a small file per writer per commit, plus a snapshot and a manifest each time. Rows arrive in time order, not sort order, which means the sort only becomes real when compaction rewrites closed partitions with the sort strategy. If you use a managed service such as Confluent Tableflow, it compacts and expires its own tables; observe those tables, but don't run a second maintenance process on them.

A table shaped this way answers the operational questions directly:

sql
1-- Token spend and tool error rate per agent, last 7 days2SELECT agent_name,3       sum(coalesce(input_tokens, 0) + coalesce(output_tokens, 0)) AS tokens,4       count_if(operation_name = 'execute_tool')                   AS tool_calls,5       count_if(operation_name = 'execute_tool'6                AND status_code = 'ERROR')                         AS tool_errors7FROM lake.agents.agent_spans8WHERE start_time >= current_timestamp() - INTERVAL 7 DAYS9GROUP BY agent_name10ORDER BY tokens DESC;

Reproducibility: record which snapshot produced each answer

"Why did the agent say revenue dropped 12%?" is unanswerable if you can't see the data the agent saw. The pinned snapshot from the read section makes it answerable, provided you record it and keep it. A provenance table ties each answer to the exact table versions behind it:

sql
1CREATE TABLE lake.agents.answer_provenance (2  answer_id        STRING    NOT NULL,3  conversation_id  STRING,4  agent_name       STRING,5  table_name       STRING    NOT NULL,6  snapshot_id      BIGINT    NOT NULL,7  query_text       STRING,8  answered_at      TIMESTAMP NOT NULL9)10USING iceberg11PARTITIONED BY (days(answered_at));

Replaying is a time-travel query with the recorded snapshot_id, and it works only while that snapshot exists. With a five-day snapshot age on expire_snapshots, your replay window is five days, whatever your audit policy says. Retention is the real design decision, and it's a trade between replay precision and storage:

Retention approachReplay windowStorage costUse when
Default expiryAbout 5 daysLowestAnswers aren't audited
Longer snapshot age on the tableN days, every snapshotGrows with write rateLow-churn reference tables
Daily tag with RETAINDaily granularity for N daysOne snapshot per dayAudit by day is acceptable
Tag the snapshot behind each audited answerExact, for N daysOne ref per answerRegulated decisions at low volume

A daily tag is one statement, and it protects that snapshot from expiry until the tag's own retention runs out:

sql
1ALTER TABLE lake.sales.orders2  CREATE TAG `eod-2026-11-29` AS OF VERSION 8954597067493422955 RETAIN 90 DAYS;

Be honest about what a daily tag gives you: it replays against the end-of-day state, not the snapshot an agent read at 10:14. If exact replay matters, tag the recorded snapshot itself. Compaction doesn't interfere either way. It writes new files and a new snapshot, while the tagged snapshot keeps referencing the old files until the tag expires, so maintenance and audit coexist as long as retention is explicit. The snapshot retention and time travel guide covers the retention settings in more depth.

The snapshot record covers the data side of a replay. For the SQL side, QueryFlux's session replay stores each query with its agent and conversation IDs, plus the step index and tool-call ID when the client sends them, so you can list a run's queries in order and rerun them against the snapshot it read.

Format v3 adds one more tool. With row lineage, every row carries a _row_id and the sequence number of the commit that last updated it. Record the sequence number of the snapshot an agent read next to its ID (it's part of each snapshot's metadata), and the rows with a higher last-updated number are the ones that changed after the answer, with no snapshot diff. Lineage isn't tracked for rows updated through equality deletes, which matters for Flink upsert tables.

What agent workloads do to table health

Everything above creates maintenance work. Agent systems commit more often, in smaller pieces, across more tables than batch pipelines do, and they leave branches, delete files, and abandoned tables behind. Each pattern accumulates something specific:

Agent patternWhat accumulatesMaintenance that fixes itCaution
Streaming trace appendsSmall files, snapshots, manifestsSort compaction, snapshot expiry, manifest rewriteCompact closed partitions, not the one being written
Branch per runSnapshots and files held by unexpired refsRETAIN on every branch, then expiryA ref without retention never cleans up
MERGE corrections and memory upsertsPosition deletes, deletion vectors, dangling deletesCompaction with a delete threshold, position delete rewrites, dangling delete removalA high delete ratio slows every read
Erasure requestsDeleted rows still in files and old snapshotsRewrite, then expiryLong-lived tags block physical deletion
Abandoned agent tables and failed writesStale tables, orphan filesOrphan cleanup on its own schedule, stale-table reviewNever use a short orphan window

For a single trace table, the maintenance sequence looks like this. Compaction comes first so that, once the pre-compaction snapshots pass the expiry window, expiry deletes the small files it replaced. Orphan cleanup runs separately, with an older_than of at least three days, the procedure's default, so it never deletes files from writes still in flight:

sql
1-- 1. Rewrite yesterday and older into sorted ~512 MB files2CALL lake.system.rewrite_data_files(3  table      => 'agents.agent_spans',4  strategy   => 'sort',5  sort_order => 'agent_name ASC, conversation_id ASC, start_time ASC',6  where      => 'start_time < "2026-11-29 00:00:00"',7  options    => map('target-file-size-bytes', '536870912',8                    'partial-progress.enabled', 'true')9);10 11-- 2. Expire snapshots older than a week, keeping the last 2012CALL lake.system.expire_snapshots(13  table       => 'agents.agent_spans',14  older_than  => TIMESTAMP '2026-11-22 00:00:00',15  retain_last => 2016);17 18-- 3. Regroup manifests after the rewrite19CALL lake.system.rewrite_manifests('agents.agent_spans');20 21-- Separately, on its own schedule: files no snapshot references22CALL lake.system.remove_orphan_files(23  table      => 'agents.agent_spans',24  older_than => TIMESTAMP '2026-11-26 00:00:00'25);

That's manageable for one table. An agentic system adds tables per agent, per tenant, and per evaluation run, and their write rates change whenever a prompt or a tool changes. A cron job per table, with thresholds someone tuned once, falls behind exactly when agent traffic grows. The maintenance has to be decided by each table's state, not by the clock.

How LakeOps maintains agent tables

This is the loop LakeOps runs. Each scan reads a table's metadata, records insights against fixed thresholds, and derives health from them: Critical if the table has a critical insight, Warning if it has a warning, Healthy otherwise. The LakeOps control plane shows that state lake-wide, across every connected catalog, before you open a single table.

LakeOps dashboard with 30-day optimization activity and counts of total, critical, warning, and healthy tables
Lake-wide state first: 30-day maintenance activity and how many tables are Critical, Warning, or Healthy across connected catalogs.
Watch demoYouTube ↗
Autonomous Iceberg data lake management: connecting catalogs, reading table health, and running maintenance from one control plane.
LakeOps tables list showing each Iceberg table's namespace, records, size, and Healthy, Warning, or Critical status
Per-table health, records, and size, filterable by catalog and namespace, so an agents namespace can be reviewed on its own.

Several insight types map directly onto the agent patterns above. Refs without retention flags branches and tags that will never expire, which is how abandoned agent branches show up. Excessive snapshots and excessive manifests catch streaming trace tables that commit faster than they're cleaned. Partitions of mostly small files and high delete ratio catch memory tables after a wave of upserts. Stale table flags tables with no snapshot in 30 days, which is often an agent-created table nobody owns anymore.

LakeOps insights list with a severity for each table issue, including partition data files, excessive manifests, and excessive snapshots
Insights with a severity per table: small-file partitions, manifest buildup, and snapshot buildup, the signatures of high-frequency agent writes.

Maintenance runs through Adaptive Maintenance: one policy covering five operations, run in a fixed order when they're due: compaction, snapshot expiry, position delete rewrites, dangling delete removal, and manifest rewrites. The signals are the ones that matter for agent tables: share of small files, compactable bytes, snapshot and manifest counts, position, equality, and dangling deletes, and per-hour growth. Each operation has a needed flag, a score, a projected trigger time, and a cooldown. In Automatic mode it runs when signals cross a threshold, with no cron; Scheduled mode adds a cron cap if you want maintenance kept away from peak agent hours. The Adaptive Maintenance docs list the signals and thresholds.

Compaction runs on LakeOps-managed compute with a Rust engine built on Apache DataFusion, so there's no Spark cluster to size for a trace table that doubles overnight. It uses binpack by default, or sort when the table has an Iceberg sort order, which means the WRITE ORDERED BY you set on the span table is what compaction applies. Commits don't block readers or writers. Orphan cleanup is deliberately a separate policy, because it's the one operation where a too-short window deletes live data.

LakeOps policies list with compaction, expire snapshots, rewrite manifests, configuration, and a separate orphan files policy
Policies by type and schedule. Orphan cleanup is its own policy, here running across all catalogs every 7 days.

Policies are where agent namespaces get their own rules. A governance policy can target all catalogs, one catalog, or namespaces and tables by exact name or regex, with exclude lists, and new tables in scope inherit it on the next scan. An agent that creates a table in a governed namespace therefore gets maintenance from its first scan, with no ticket and no DAG to add. The same scoping applies to snapshot tags: a tag policy creates tags on a schedule from a template (by default eod-{yyyy}-{MM}-{dd}) with their own retention (30 days by default), which gives you the daily replay points from the reproducibility section. Scope it to the tables agents read for answers, and keep memory tables out with the exclude list. Expiry never removes snapshots referenced by a tag or branch, so those replay points survive routine cleanup.

LakeOps snapshots tab for an Iceberg table with snapshot IDs, references, and actions to tag, branch, or roll back
Snapshot history with branch and tag references, plus actions to tag, branch, or roll back to a snapshot.

Every operation lands in Events, whether a policy, Adaptive Maintenance, someone in the console, a REST call, or an agent over MCP started it, with status, duration, and impact. When an agent triggers maintenance, the record looks the same as when a policy does, which is what an auditor wants. Together, these pieces cover the lakehouse table maintenance lifecycle for agent-written tables the same way they do for pipeline tables.

LakeOps events log listing compaction, snapshot expiry, and manifest rewrite operations with impact, duration, and status
One record of every operation: type, impact (for example 970 to 87 files), duration, and status, whoever started it.

Agents operating the lakehouse, within scopes

Agents can also work the loop themselves. The LakeOps MCP server exposes 31 tools on the same backend: get_lake_health for an org summary, get_table_profile for one table's statistics, insights, and signals in a single call, get_maintenance_signals, and, for keys with write scopes, execute_optimization and create_policy. Each tool requires a permission scope, and the destructive ones (execute_optimization, execute_policy, and delete_table) carry destructiveHint, so clients that honor the annotation ask for confirmation first. That matches the MCP tools spec, which says there should always be a human able to deny a tool call and that clients must treat annotations from untrusted servers as untrusted. The MCP server reference lists every tool and scope, and the lakehouse MCP server and guardrails for AI agents page shows the setup end to end.

For agent SQL on the data itself, the query layer matters more than the catalog. QueryFlux runs guardrails before a query reaches an engine: read_only, row_limit (which denies a query whose LIMIT exceeds the cap and records a warning when there's no LIMIT), and require_predicate. Over MCP it records an agent ID (the authenticated user by default) and a conversation ID (the MCP session) with each query, per its agent context docs. Pass your framework's conversation and tool-call IDs as tool arguments, and query history joins directly with the agent_spans table.

Watercolor diagram of guardrails in front of the lakehouse: allowed agent requests pass to Iceberg tables and unsafe ones are stopped
Guardrails sit in front of the engines: a query is checked against its rules before it runs, not audited after it has scanned the lake.

Rollout checklist

  1. 1.Give each agent its own catalog principal with short-lived, vended credentials. No shared storage keys.
  2. 2.Pin one snapshot per agent run, and record the snapshot ID with every answer in a provenance table.
  3. 3.Route every agent write to a branch created with RETAIN; audit the branch, then fast-forward or drop it.
  4. 4.Keep schema changes out of agent permissions.
  5. 5.Put agent-owned tables in their own namespaces, so policies and reviews can target them.
  6. 6.Land traces in a day-partitioned Iceberg table sorted by agent, conversation, and time, with promoted OpenTelemetry GenAI columns plus the raw attributes.
  7. 7.Choose retention per flow: short for branches, explicit tags for audited reads, short and tag-free for personal memory.
  8. 8.Treat erasure as delete, rewrite, then expire, and test it end to end on a copy of a real memory table.
  9. 9.Trigger compaction, expiry, delete handling, and manifest rewrites from table state rather than a fixed schedule, and run orphan cleanup separately with a window of at least three days.
  10. 10.Keep one record of every operation, whether a person, a policy, or an agent started it.

Agent data needs its own retention and maintenance rules

Reading, writing, and recording are three different contracts with the lakehouse, and Iceberg supports all three if you use branches, snapshots, tags, and row-level deletes deliberately. What fails in practice is the maintenance and retention underneath: branches that never expire, replay windows that end at five days, trace tables full of small files, and memory that a DELETE didn't remove. If you'd rather not build that loop table by table, LakeOps runs it on the Iceberg tables you already have.

Related articles

Found this useful? Share it with your team.