Skip to content
Medium

Medium

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

itnext.io
MediumMedium
ARTIFICIAL INTELLIGENCE

Agentic AI Lakehouse: A Guide

Building an agentic AI lakehouse with Apache Iceberg: architecture, governed agent reads and writes, MCP , and maintenance that holds up. Agentic AI Lakhouse An agentic AI lakehouse is a lakehouse designed for AI agents as first-class users. Agents find and query governed data, write results back, leave a record of everything they did, and help run the platform itself, all on one open copy of the data and inside limits the platform enforces rather than the prompt. On Apache Iceberg, that means open tables and a catalog at the bottom, a governed query path in the middle, and a control plane on top that keeps every table healthy and exposes the lake to agents through the Model Context Protocol (MCP). example — source: lakeops.dev Most of the stack already exists. What changes is the load and the trust model. People tolerate slow dashboards and ask before they delete things. Agents run around the clock, issue dozens of queries per question, act on whatever the data says, and write back faster than anyone can review. Gartner expects over 40% of agentic AI projects to be canceled by the end of 2027, citing escalating costs, unclear business value, and inadequate risk controls. Two of those three are data platform problems. example — source: lakeops.dev This guide covers what an agentic AI lakehouse is, the reference architecture layer by layer, seven design principles with the SQL and config behind them (reads, writes, records, maintenance, and agents operating the lake), and a rollout plan that doesn’t start with giving an agent write access to production. Along the way it shows where a lakehouse control plane such as LakeOps fits, and what it does that scripts and cron can’t. ### What an agentic AI lakehouse is, and what it isn’t The term is new and vendors stretch it in different directions. Dremio uses it for its engine plus a semantic layer and MCP server, AWS for a foundation that runs from zero-ETL ingestion to MCP, and Google’s lakehouse for the agentic era comes closer to the platform view, pairing Iceberg storage with a runtime catalog that automates table management and agent tooling over MCP. Strip the branding and the useful definition is operational. A lakehouse is agentic when four things hold at once: - Agents read governed data, not copies. They query the same tables as dashboards and pipelines, through a path that knows who they are, what they may see, and what a query is allowed to cost. source: lakeops.dev - Agents write safely. Their output lands somewhere isolated and reviewable before anyone else can read it, and a bad run can be thrown away without touching production. - Everything agents do is recorded as data. Prompts, tool calls, queries, the snapshots they read, and the answers they gave land in tables you can query, audit, and erase. - The lakehouse runs itself, and agents can help. Table health is maintained from each table’s state rather than a cron schedule, and agents can read that state and act on it through a standard interface, within scopes you grant. source: lakeops.dev What it isn’t: a chatbot bolted onto a warehouse, a vector database next to the lake, or a rename of “AI-ready data.” Each covers one of the four. Running all four on the same tables at once is a platform problem far more than a model problem. ### Why agents break lakehouses built for people Human analytics hides operational debt: a degraded table costs a few analysts some patience until someone schedules a fix. Agent traffic removes that slack in four ways. It multiplies queries per question. An agent answering one question lists schemas, describes tables, samples rows, runs a first query, reads an error, rewrites, and retries. The QueryFlux team traced one scripted, agent-shaped session in Your busiest SQL user has amnesia: a single question turned into 13 tool calls and four confident zeros before the right count. Query volume stops tracking headcount. It is continuous and exploratory. Agents run on triggers, schedules, and other agents, so there is no overnight lull for maintenance. They probe tables they have never seen and pay every planning cost you tolerated for people: bloated manifests, thousands of small files, deep snapshot histories, piles of delete files. It acts on what it reads. A person who sees a strange number checks it. An agent passes it to the next step. Gartner expects organizations to abandon 60% of AI projects unsupported by AI-ready data, and agents are where unready data does its damage fastest. A stale table, a missing predicate, or a vague denial message turns directly into a wrong action. It writes. Enrichments, corrections, generated tables, long-term memory, traces. Databricks’ State of AI Agents 2026 report says agents now create 80% of the databases and 97% of the database branches on its Neon-based Lakebase service. On a lakehouse, agent writers commit small and often, which is exactly the write pattern that degrades Iceberg tables fastest. The large Iceberg operators learned the operational half of this before agents arrived. Salesforce runs its Data Cloud lakehouse on Iceberg with more than 4 million tables and 50 PB, and explains in Inside Data Cloud’s open lakehouse that scheduled optimization jobs stopped scaling, because scanning every table on a fixed cadence became prohibitively expensive. They replaced them with a reactive optimizer that runs only when a table changes. Agents push every lakehouse toward that problem. ### The agentic AI lakehouse reference architecture Mapped onto an Iceberg stack, an agentic AI lakehouse has seven layers. The first four are the lakehouse you probably run today. The last three are where agents change the design. Object storage. Data files in S3, GCS, or Azure. Open table format. Apache Iceberg: atomic commits, snapshots, branches, tags, and schema evolution, readable by every engine. Catalog. Tracks each table’s current metadata and who may load it: AWS Glue, Apache Polaris, Project Nessie, Lakekeeper, Unity Catalog, or any Iceberg REST catalog. Engines. Spark and Flink for writes, Trino, StarRocks, DuckDB, Athena, Snowflake, and others for reads. source: lakeops.dev Semantics and context. Table and column descriptions, metric definitions, ownership, and health, in a form an agent can retrieve before it writes SQL. Governed query path. One endpoint agents query through, which checks identity, applies row filters and column masks, enforces guardrails, routes to the right engine, and records agent context on every query. source: lakeops.dev Control plane. Watches every table, decides what maintenance and layout each one needs, runs it, records it, and exposes the lake’s state and operations to agents over MCP. source: lakeops.dev Agents query through layer 6 and operate through layer 7, while engines, catalogs, and data stay where they are. That is the property worth protecting: an agentic AI lakehouse is an upgrade to your stack, not a migration to someone’s agent platform. The control plane is the least familiar layer, so it is worth one precise paragraph. The term comes from networking and Kubernetes: the data plane does the work, and the control plane watches state and decides. In a lakehouse, the data plane is storage, tables, catalogs, and engines. The LakeOps control plane connects to the catalogs you already run (Glue, or a REST catalog such as Polaris or Nessie), reads Iceberg metadata (snapshots, manifests, file and delete statistics) to decide what each table needs, and runs maintenance in place on its own Rust engine built on Apache DataFusion. It copies no data, its maintenance runs outside the query path, and every operation lands in one audit trail. Agents reach the same backend over an MCP server with scoped keys, which is what turns “keep the lake healthy” from a job you do for agents into one agents can take part in. Put together, that gives the three parts an agentic lakehouse runs at once: intelligence that keeps every table healthy, safe and optimized access for agent queries, and agentic operations over MCP. The agent-facing pieces (the MCP server, its tools, scoped keys, and guardrails) are covered on the lakehouse MCP server and guardrails for AI agents page. The seven principles below hold whichever tools you use; LakeOps comes back where a principle needs the operational loop. source: lakeops.dev ### Principle 1: Keep one copy of the data, in open tables The fastest way to give an agent data is to copy some into a store it already understands: a vector database, a SaaS warehouse, a JSON dump in an object bucket. Every copy creates a second set of permissions and a freshness gap the agent can’t see, and the agent then answers confidently from the stale copy. Iceberg removes the main reason to copy. The same table is readable by Spark, Trino, Flink, DuckDB, Snowflake, and BigQuery, so the agent’s engine can change without moving data. Format versions 1 to 3 are complete and adopted, and v4 is in development. The features that matter most for agents are already in the spec: - Snapshots and time travel give a run one consistent version of a table and let you replay answers. - Branches and tags give isolated writes and retained versions with no data copy. - Row-level deletes, and in format v3 deletion vectors, make the frequent small updates agents produce affordable. - Row lineage in v3 gives every row an ID and the sequence number of the commit that last changed it, useful for incremental processing and audit. - The REST catalog protocol lets a catalog vend short-lived, table-scoped storage credentials instead of handing out bucket keys. Two honest caveats. Embeddings are the one thing Iceberg does not natively serve: no ratified Iceberg spec has a vector type, and the vector type proposal is still an open issue. Keep text, metadata, and the embedding-model version in an Iceberg table as the source of truth and build the vector index from it, so a model change means a rebuild from the table. And not every engine supports every v3 feature yet, so check each reader before enabling variant columns or deletion vectors on a shared table. ### Principle 2: Make the lake legible before agents query it Text-to-SQL fails less often on SQL syntax than on meaning. On the BIRD benchmark, the best systems reach about 83% execution accuracy against roughly 93% for human experts, and on BIRD-Interact, which adds ambiguous questions and multi-turn clarification, the best models completed only about 16% of tasks. Production schemas are messier than either. The agent picks orders_v2_final instead of fct_orders, sums revenue that should be net of refunds, or joins on a key that stopped being unique last quarter. Every one of those is a context failure, and the fix is upstream of the model. source: lakeops.dev Start by shrinking the search space. Most lakes have thousands of tables and a few dozen that matter to any given agent. Publish an agent-facing namespace of curated facts and dimensions, and keep raw, staging, and deprecated tables out of the agent’s view. A smaller, better catalog beats a smarter model. Then put meaning where agents can retrieve it: - Descriptions on tables and columns, stored in the catalog or as Iceberg table properties, written for a reader who has never been in your Slack. Units, grain, known gaps, and the join keys that are safe. - Metric definitions in a semantic layer, so “revenue” resolves to one governed expression instead of whatever the agent infers. - Ownership and freshness, so an agent can say “last updated nine days ago” instead of presenting stale numbers as current. - Health, the context almost nobody gives agents. A table with thousands of small files and a stale partition is slow, expensive, and possibly incomplete, and an agent that knows can pick another table or warn the user. Health is cheap to compute from Iceberg’s metadata tables, which every engine exposes: -- Freshness: when did the table last commit, and what kind of commit? SELECT committed_at, operation, summary['added-records'] AS added_records FROM lake.sales.fct_orders.snapshots ORDER BY committed_at DESC LIMIT 5; -- Small files and delete files per content type -- (0 = data, 1 = position deletes, 2 = equality deletes) SELECT content, count(*) AS files, count_if(file_size_in_bytes < 32 * 1024 * 1024) AS small_files FROM lake.sales.fct_orders.files GROUP BY content; Running that for one table is trivial. Keeping it current for every agent-facing table, and turning raw counts into a judgment such as “critical: excessive snapshots because a branch has no retention,” is a control plane’s job. In LakeOps, an agent gets exactly that judgment from one MCP call, get_table_profile, which returns a table's stats, insights, and maintenance signals together. ### Principle 3: Identify, check, and pin every agent read An agent should never hold a warehouse password or a shared bucket key. Every query it runs should carry an identity, pass a policy check before any engine sees it, and read a consistent version of the data. ### Identity: the agent, the person, and the purpose Agent identity has two halves: which agent, and on whose behalf. A support copilot acting for an EU rep should see what that rep may see, intersected with what the copilot is for. OAuth token exchange (RFC 8693) is the standard way to carry both, and the MCP authorization spec builds on OAuth 2.1 for remote servers. Whatever the mechanism: one credential per agent, short-lived where possible, revocable in one place. ### Enforcement: before the engine, not in the prompt There are three places to enforce what an agent may read, and they are not equivalent. - The catalog decides which tables a principal may load and, through credential vending, what storage access it gets. In Apache Polaris, for example, TABLE_READ_DATA vends short-lived read-only credentials. Catalog grants have traditionally been coarse: once an engine holds file access, the catalog can't stop it reading whole files. Iceberg 1.12.0 added read-restrictions to the REST catalog spec, so a catalog can now tell the engine which row filter and column masks it must apply, and a compliant reader must fail the query rather than return raw data. Engine support is still arriving. - The engine can apply row filters and masks, but each has its own policy language, and an agent that can choose engines finds the weakest one. - A query layer in front of the engines checks every statement whichever engine runs it, and can rewrite or deny it with a reason the agent can act on. Engine-native limits are a useful backstop (AWS’s guardrails for agentic workloads on Redshift sets a statement timeout and connection limit per agent user), but the third option is where most of the control lives, because it sees the SQL before any engine runs it. QueryFlux, the open-source SQL proxy the LakeOps team maintains, is one such layer. It speaks Trino HTTP, PostgreSQL and MySQL wire, Arrow Flight SQL, Snowflake’s protocols, and MCP, and its guardrails run as a chain on every query before dispatch. A config that gives agents their own entry point, engine, capacity cap, and stricter rules looks like this: queryflux: frontends: trinoHttp: enabled: true port: 8080 mcp: enabled: true port: 8811 clusters: trino-bi: engine: trino endpoint: [http://trino-bi:8080](http://trino-bi:8080) enabled: true trino-agents: engine: trino endpoint: [http://trino-agents:8080](http://trino-agents:8080) enabled: true clusterGroups: bi: maxRunningQueries: 50 members: [trino-bi] agents: maxRunningQueries: 10 members: [trino-agents] routers: - type: protocolBased trinoHttp: bi mcp: agents routingFallback: bi guardrails: global: - kind: built_in name: read_only groups: agents: - kind: built_in name: row_limit max_rows: 5000 - kind: built_in name: require_predicate applies_to: - "fct_*" Read it as architecture. MCP sessions land in their own group on their own engine, so a burst of agent retries queues behind a concurrency cap instead of starving dashboards. Every query is read-only. Agent queries on fact tables must carry a WHERE clause, and a LIMIT above 5,000 rows is denied (a query with no LIMIT at all is let through with a warning in the audit log). The chain stops at the first deny, and the deny reason is what reaches the agent, so write reasons as instructions: "add a filter on order_date" teaches the agent to fix its query; "policy violation" teaches it to retry blindly. source: lakeops.dev ### Consistency: one snapshot per run A single agent run can issue ten or twenty queries. If ingestion commits between step three and step seven, the agent reasons over two versions of the table and produces totals that don’t reconcile. The fix is to resolve the snapshot once at the start of the run, read it for every query, and log its ID with the answer: -- Spark: resolve the head of main once, at the start of the run SELECT snapshot_id FROM lake.sales.fct_orders.refs WHERE name = 'main'; -- Every query in the run reads that snapshot, not the moving head SELECT region, sum(net_amount) AS revenue FROM lake.sales.fct_orders VERSION AS OF 5937117119577207079 WHERE order_date >= DATE '2026-11-01' GROUP BY region; Trino takes the same snapshot ID with FOR VERSION AS OF. The logged ID is also your replay key: while that snapshot exists, you can rerun the exact query against the exact data. ### Principle 4: Agents write to branches, never straight to main Researchers at Bauplan put the current state bluntly: most enterprises do not consider agents trustworthy enough to work on production data. Agents write anyway, more than most teams plan for, and their failure modes are mundane: a join that duplicates rows, a hallucinated value in a lookup table, a DELETE with a dropped filter. Code changes go through review before they reach main. Agent data changes deserve the same, and Iceberg makes it cheap. source: lakeops.dev An Iceberg branch is a named snapshot lineage. Writes to it are invisible to readers of main until you publish them, and creating one copies no data. The write-audit-publish pattern for an agent run is four statements: -- 1. One branch per run; retention cleans up abandoned runs ALTER TABLE lake.crm.account_notes CREATE BRANCH run_7f3a RETAIN 3 DAYS; -- 2. The agent writes only to its branch INSERT INTO lake.crm.account_notes.branch_run_7f3a SELECT account_id, note, 'agent:renewals' AS written_by, 'run_7f3a' AS run_id FROM agent_output_staging; -- 3. Audit the branch before anyone else can read it SELECT count(*) AS new_rows, count_if(account_id IS NULL) AS missing_keys, count(*) - count(DISTINCT account_id) AS duplicate_keys FROM lake.crm.account_notes VERSION AS OF 'run_7f3a' WHERE run_id = 'run_7f3a'; -- 4. Publish if the audit passes; otherwise drop the branch CALL lake.system.fast_forward('crm.account_notes', 'main', 'run_7f3a'); Three rules bite in production. The branch must exist before the write; per the Spark writes docs, writing to a missing branch fails rather than creating it. fast_forward needs main to be an ancestor of the branch head, so if ingestion committed to main during the run, rebuild the branch from the new head and audit again. And Iceberg uses optimistic concurrency: two writers committing to the same table race, and the loser retries or fails. Agents that commit on every step create exactly that contention, so batch agent writes per run instead of per tool call. Not every write needs the same ceremony. Appends can fast-forward after a row-count and key check. MERGE and UPDATE corrections deserve a diff against main and a cap on the share of rows changed. Deletes always go through a branch. New tables start in an agent-owned namespace. Schema changes stay with humans, partly because branch writes use the table's current schema, so a schema can't be evolved in isolation on a branch. ### Principle 5: Record everything agents do as data When an agent gives a wrong answer, the first question is what it saw. Six weeks later, an auditor asks the same about a right one. Both need a record that outlives the conversation, and the lakehouse is its natural home. source: lakeops.dev Three kinds of agent records belong in Iceberg: - Traces: model calls, tool calls, token counts, latency, and errors per step. The OpenTelemetry GenAI semantic conventions give you attribute names such as gen_ai.operation.name, gen_ai.request.model, gen_ai.usage.input_tokens, gen_ai.tool.name, and gen_ai.conversation.id. The conventions are still marked Development. Promote the attributes you query into typed columns, and keep the full attribute map as raw JSON so an upstream rename costs a backfill, not lost data. - Provenance: for each answer, the tables and snapshot IDs it read and the SQL it ran. This is the table that turns “the agent said revenue fell 12%” into something you can replay. - Memory: long-term facts about users, accounts, and entities that many agents share. These are upserts by key, so they need MERGE and, on v3 tables, deletion vectors keep them cheap. Layout decides whether agent tables stay usable. A trace table is queried two ways: “tokens per agent this week” and “everything this conversation did.” Partition by day for the first, and sort by agent and conversation for the second, so a single-conversation lookup skips most files on min and max statistics. Streaming writers commit in time order on every checkpoint, so that sort only becomes real when compaction rewrites closed partitions with the sort strategy. Retention needs the most care, because each record type wants something different. Provenance wants old snapshots kept long enough to replay answers; with a five-day snapshot age on expire_snapshots, your replay window is five days whatever your audit policy says. Memory about people wants the opposite: a DELETE alone doesn't erase anything, since Iceberg keeps data files while any retained snapshot references them. Forgetting a user means deleting the rows, rewriting the files that still hold them, and expiring the snapshots that point at the old files; one forgotten long-lived tag keeps the rows on disk regardless. Keep personal memory in its own namespace with short retention, and put audit tags on reference data, not on memory. Trace schemas, provenance tables, and erasure are covered in more depth, with full DDL, in Iceberg Lakehouse for Agentic AI. ### Principle 6: Tables maintain themselves on signals, not schedules source: lakeops.dev Here is the part most agentic architectures skip. Every principle so far adds writes: branch commits, trace spans every few seconds, memory upserts, provenance rows. Every Iceberg commit adds a snapshot and usually a manifest, streaming commits add small files, and merge-on-read MERGE and DELETE add delete files. That is how Iceberg delivers atomic commits and time travel, and it means a table's physical state drifts from what readers need at a rate set by its write pattern. Agent workloads drift fastest. Planning reads more manifests, scans open more files, reads apply more deletes, and storage grows with every unexpired snapshot. An agent that issues fifteen queries per question pays that tax fifteen times. Iceberg ships every maintenance primitive. A hand-run pass on one table in Spark looks like this: -- 1. Compact small files; sort when the table has a sort order CALL lake.system.rewrite_data_files( table => 'agents.agent_spans', strategy => 'sort', sort_order => 'agent_name, conversation_id, start_time', where => 'start_time < current_date()', options => map('partial-progress.enabled', 'true') ); -- 2. Expire snapshots no longer needed for time travel or replay CALL lake.system.expire_snapshots( table => 'agents.agent_spans', older_than => TIMESTAMP '2026-11-24 00:00:00', retain_last => 50 ); -- 3. Compact position delete files left by merges and deletes CALL lake.system.rewrite_position_delete_files( table => 'agents.agent_spans' ); -- 4. Consolidate manifests so planning reads fewer metadata files CALL lake.system.rewrite_manifests('agents.agent_spans'); The order matters. Expiring snapshots after compaction is what lets the replaced small files leave storage, delete rewrites then handle only what compaction didn’t apply, and manifests go last because every step added metadata. Orphan file cleanup deletes anything no snapshot references, so it belongs in a separate, reviewed job with a safety margin longer than any in-flight write. The where clause matters too: compacting the partition a streaming writer is still committing to invites commit conflicts. What Iceberg does not ship is the judgment around those calls: which of thousands of tables needs which operation right now, in what order, without colliding with active writers, and whether it helped. At a few dozen tables, scripts work. At a few hundred, the scripts become a product someone maintains. At thousands, a cron schedule is either too aggressive, wasting compute on healthy tables, or too lax, letting agent-facing tables degrade between runs. That is the Salesforce lesson again: maintenance has to react to table state. This is the job LakeOps was built for, so here is concretely how it does it. Each scan checks a table’s metadata against thresholds and raises insights with a severity: excessive snapshots, excessive manifests (above the table’s commit.manifest.min-count-to-merge, 100 by default), partitions of mostly small files, a high delete-file ratio, partitions skewed to ten times the average, refs without retention, and tables with no snapshot in 30 days. A table's health follows from its insights: Critical, Warning, or Healthy. source: lakeops.dev On top of that, Adaptive Maintenance is one policy covering five operations, run in the order above when they’re due: compaction, snapshot expiry, position delete rewrites, dangling delete removal, and manifest rewrites. It watches the share of small files, compactable bytes, snapshot and manifest counts, delete files, and growth per hour, and gives each operation a needed flag, a score, a projected trigger time, and a cooldown, so a busy trace table isn’t rewritten on every commit and a quiet dimension is left alone. Compaction runs on LakeOps-managed compute on the Rust engine, writes to your bucket, and commits a normal Iceberg snapshot without blocking readers or writers. Orphan cleanup stays a separate policy, and every operation, whoever started it, lands in one Events log. The table maintenance page covers the signals and modes in more depth. Layout matters as much, because agents can’t write their way around a bad one. Partitioning decides which file groups a query skips entirely. Sort order, a form of clustering, decides whether files inside surviving partitions are skippable, strongest on the leading column. Z-order interleaves two to four equally filtered columns at a higher write cost. Binpack fixes file counts but clusters nothing. For agent-facing tables, sort on what agents actually filter by. ### Principle 7: Agents operate the lake, within scopes the server enforces The last principle turns agents into participants in running the lakehouse. An agent with unbounded write access to production is a bad idea; an agent that reads lake health, explains what is wrong, and applies narrow fixes after approval is one of the most useful things you can build. The question is how to bound it. source: lakeops.dev source: lakeops.dev source: lakeops.dev MCP is the interface that has stuck: a standard way for an agent to discover and call tools on a remote server. An operator agent needs trustworthy state from the system that maintains the tables, explanations rather than raw counts, narrow actions such as “compact this table” instead of arbitrary SQL, permissions enforced by its credential rather than its prompt, and a record of every action. source: lakeops.dev The permissions point is the one that matters most, and the MCP specification is blunt about why. Tool annotations such as readOnlyHint and destructiveHint are hints, and clients must treat them as untrusted unless they come from trusted servers; the spec also says there should always be a human in the loop able to deny a tool invocation. Real enforcement therefore lives on the server, in the scopes attached to the agent's key. The LakeOps MCP server is built that way. It exposes 31 tools over Streamable HTTP, authorized with an organization API key, and the organization always comes from the key, never from tool arguments. Twenty-four tools are read-only: discovery, table profiles with insights and maintenance signals in one call, hot partitions, scan cost hints, event history, lake health, and analysis workflows such as analyze_critical_triage and analyze_policy_gaps. Four change policy configuration. Three are destructive (execute_optimization, execute_policy, and delete_table) and carry destructiveHint, so clients that honor it ask a person first. Scopes on the key decide which of those a given agent can call at all. Design agents around roles, not around one powerful key: - Observer (read): health, insights, signals, events, and the analysis tools. It changes nothing, and it does most of the useful work. - Maintenance operator (read plus tables:write): can run one maintenance operation on one table. It cannot create policies or delete tables. - Policy steward (read plus policies:write): can create, update, enable, and run governance policies. It cannot run ad-hoc operations or delete tables. - No agent gets tables:delete or catalog administration. The broad write scope includes tables:delete, so give agents the narrow write scopes instead. A bounded triage session then looks like this, with every step but the last read-only: 1. analyze_critical_triage returns critical and warning tables with their top insights, ranked. 2. get_table_profile on the top table returns its stats, insights, and maintenance signals in one response. 3. get_table_events shows what already ran and whether a recent operation failed. 4. The agent explains the finding: excessive snapshots because a branch has no retention, and compaction due because small files dominate the newest partitions. 5. It proposes the fix, preferably as a governance policy scoped to the affected namespace rather than five one-off operations, so the fix keeps applying after the conversation ends. 6. After a person approves, a key with the right scope runs it, and the agent confirms the result in the event log. Most teams start with steps one to five: agents that write the morning lake report, open tickets with the diagnosis attached, or answer “why is this table slow?” in chat. Write access follows once the explanations have proven reliable. That caution has a number behind it: Gartner expects that by 2030, half of AI agent deployment failures will stem from inadequate runtime enforcement of governance and poor interoperability. Scopes checked on every tool call and guardrails on every query are that runtime enforcement. source: lakeops.dev ### A rollout plan that doesn’t start with write access The principles depend on each other, so adopt them in dependency order. A sequence that works without a big-bang migration: 1. Fix the foundation. Pick the first use case and the 20 to 50 tables it needs. Check their health, set snapshot and ref retention, compact what is critical, and put them under signal-driven maintenance. 2. Make those tables legible. An agent-facing namespace, descriptions on every table and column, and the few metrics the use case needs. 3. Ship read-only agents through a governed endpoint. One identity per agent, guardrails, a separate engine group with a concurrency cap, and pinned snapshots. 4. Record everything from day one. Traces, provenance, and query history with agent and conversation IDs. You will need them the first time an answer is questioned. 5. Add governed writes on branches. Branch per run, automated audits, fast-forward on pass, short branch retention. 6. Add operator agents last. Observer keys and reports first, then narrow write scopes with approval for anything destructive. Before any agent goes live, check that: - No agent holds storage keys, and each has its own revocable credential. - Every branch and tag has a retention, and snapshot retention covers your replay window. - Guard deny reasons tell the agent what to change. - Personal data in memory tables can be physically erased, and you have tested it. - Destructive operator tools require human approval. ### The agentic AI lakehouse is an operations problem It is tempting to treat an agentic AI lakehouse as a model integration: pick a framework, connect it to the warehouse, ship a chat window. That is the easy part. What makes it hold up is everything around it: one open copy of the data, retrievable context, guardrails before any engine runs a query, isolated writes, a record of every step, healthy tables, and operator permissions that don’t depend on the agent behaving well. Iceberg gives you the primitives for nearly all of it. The open stack does not give you the operational loop that decides, table by table, what needs to happen and makes it happen without a person or a cron schedule in the critical path. That loop is what a control plane provides on top of the catalogs and engines you already run, and it is the part worth not building yourself. Whatever you build it with, build it in that order: healthy tables first, governed reads second, writes and operator agents last. To see that loop on your own Iceberg tables, LakeOps connects to an existing catalog in minutes and copies no data; the quick start guide walks through the first connection. Disclosure: I work at LakeOps, whose team also maintains QueryFlux, the open-source SQL proxy used in one example below. Both appear where they fit; the rest of the guide applies whatever tools you choose. ### Further reading - Agentic Lakehouse on Apache Iceberg: the reference architecture and the intelligence loop in depth. - Iceberg Fine-Grained Access Control for AI Agents: identity, delegation, and where to enforce row and column rules. - Maintaining Apache Iceberg Tables: Compaction, Snapshots, Metadata and Orphan Files: the maintenance procedures behind Principle 6. - Apache Iceberg Compaction Best Practices: strategies, sort orders, and Z-order in practice. --- Agentic AI Lakehouse: A Guide was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.
GOOGLESALESFORCE
MediumMedium
COMPUTING INFRASTRUCTURE AND HARDWARE

Garbage costs when you create it

#### Removing temporary objects made a hot loop 2.7x faster. The GC pauses barely moved. Did you know that freeing memory in Java costs nothing, but creating an object takes three steps, and two of them are expensive? Let’s look closer, taking a simple string comparison as an example. ### Optimizing the graph We continue the optimization of the Maven Central graph. We resolve the classpaths of every Apache project on Maven Central, 92,667 classpaths, in memory, on a laptop. We find what to optimize, and precisely measure every step, with TickSnick, a profiler I wrote. The program walks the dependency graph. When it meets the same library twice ( org.slf4j:slf4j-api at 1.7.36 and at 2.0.0-beta1), it calls merge, which compares two version strings and keeps the higher one. After three optimization steps, what is the slowest thing left? Let's ask TickSnick. Its report, each operation’s own time, the top rows: Op | Thread-time% | Calls | Thread-time per call ------------+--------------+-------------+--------------------- merge | 37.3% | 199,138,728 | 240ns // compare two versions passedOn | 11.5% | 222,178,167 | 66.3ns // pick the edges to follow visit | 5.03% | 562,928,865 | 11.5ns // mark a release as seen ... merge is on top, far ahead of the walk's other steps: 37% of all the time, 199 million calls, 240 ns each. That is our target. ### The code anyone writes The comparison splits each version into parts ( 2.0.0-beta1 into 2, 0, 0, beta, 1) and compares the parts one by one. I wrote the splitting the obvious way: private fun parts(version: String): List<String> { val parts = ArrayList<String>() val part = StringBuilder() for (c in version) { if (c in SEPARATORS) { if (part.isNotEmpty()) parts.add(part.toString()) part.clear() continue } if (part.isNotEmpty() && isDigit(part.last()) != isDigit(c)) { parts.add(part.toString()) part.clear() } part.append(c) } if (part.isNotEmpty()) parts.add(part.toString()) return parts } Looks innocent. But every call creates a list, a StringBuilder and a new String for every part, several hundred bytes in all. How much garbage is that in total? TickSnick can tell us: it counts the bytes each operation allocates, exactly, not by sampling, adding about 0.1% to the wall time or less. Here is its report: Op | Wall | Allocated -----------------+--------+---------- runBatch | 25.0s | 109 GB // three batches select | 18.0s | 88.9 GB // pick the highest versions - merge | 12.0s | // compare two versions - passedOn | 1.65s | // pick the edges to follow via | 4.08s | 6.31 GB // who brings each library reach | 1.50s | 2.22 GB // collect the classpath select, the first of the program's three walks, allocates 88.9 of the 109 GB. Inside select, two operations create objects: the comparison and the edge filter. The filter allocates about 4 GB. So the comparison allocates about 85 GB: 78% of all the garbage. So before we touch a single line, TickSnick already tells us what to expect: if the comparison stops creating objects, about 78% of the garbage should go away. ### Same logic, no garbage — 2.7x faster, and not because of the GC Let’s rewrite the comparison so that it never cuts a version into new strings. Instead of a list of parts, it keeps two ints per part: where the part starts and ends in the original string. It follows the same rules and gives the same answers; we check it on 815,000 real pairs. But it creates no objects at all. Now let’s run both versions and open TickSnick’s diff: Op | Wall | Allocated -------------+---------------------------+-------------------------- runBatch | 25.0s -> 16.0s -36% | 109 GB -> 24.6 GB -78% select | 18.0s -> 8.79s -51% | 88.9 GB -> 4.14 GB -95% - merge | 12.0s -> 4.44s -63% | via | 4.08s -> 4.24s ? | 6.31 GB -> 6.32 GB +0.1% reach | 1.50s -> 1.34s -1.2..-20% | 2.22 GB -> 2.22 GB = Look at the Allocated column: -78%. Exactly what TickSnick predicted before we changed a line! What select still allocates, 4.14 GB, is the edge filter alone, as estimated. The other two walks, via and reach, allocate the same as before. (In the Wall column, a ? or a range like -1.2..-20% means four runs are not enough to pin the change down.) And the speed? merge goes from 240 to 88.8 ns a call: 2.7x faster. The batches get 36% faster. Wait, maybe it is just the GC working less? TickSnick samples a thread’s time only while the program runs, never during a GC pause; the pauses get a column of their own. So 240 and 88.8 ns contain no GC at all: the thread itself gets 2.7x faster. ### What exactly gets faster But hold on: the new code does one more thing. It stops at the first part that differs, while the old code splits both versions whole. So which change gives the speed-up? Let’s write a third version to find out. It does all the old work, splitting everything and copying every character, but into buffers it reuses, so it creates no objects. On one thread, a compare takes: So the objects alone cost 120 ns: 60% of the 200 ns we save. And no GC runs during this test: we pay for the objects while we create them. Why so expensive? Creating an object takes three steps, and only the first is cheap: 1. Taking the space: the JVM bumps a pointer. A few instructions. 2. Filling it: the thread writes the header, the fields and the contents, about 582 bytes per compare here. 3. Cold memory: a new object lands on memory the CPU has not touched lately, so the CPU first has to fetch it from RAM. Our third version writes into the same few buffers, and they stay in the cache. That is the usual explanation; we have not measured it. ### The GC barely noticed Now the GC. The garbage is 4.4x smaller, so the pauses should be too, right? TickSnick’s Paused column: 3.57 s -> 2.28 s. Only 1.6x. Why? Java’s default collector, G1, puts new objects into an area of the heap called eden. When eden fills up, G1 stops the program, copies the live objects out and marks eden empty. It never touches the dead ones, so freeing them costs nothing. New objects simply overwrite them later, and that write is the cost we met above. So a pause pays for what it copies, not for the garbage. The GC log agrees: about 180 ms per GB copied, whatever the amount of garbage. ### Why the pauses fall at all The answer is not obvious. It is about what the program keeps: its results, the dependency lists it resolves, about 3.3 GB a batch. G1 has two places for objects that are still in use: a small waiting area, about 0.5 to 1 GB here, and a big area for long-lived objects. With lots of garbage, eden fills up every second or so, and each pause finds only a small pile of new results, about a gigabyte or less. That fits into the waiting area, so G1 copies it there. At the next pause those results are still in use, and G1 copies them again, into the long-lived area. Copied twice. With little garbage, eden fills up slowly, and by the first pause the pile of new results has grown to 1.7 to 2.8 GB. That is too big for the waiting area. G1 fills it and copies the rest straight into the long-lived area, once. In all, G1 copies 13.2 GB instead of 21.2 GB, and the pauses shrink with it. Less garbage overall, but bigger piles to keep. Less garbage can’t take us much further. Every kept byte must be copied at least once: 10 GB kept at about 0.18 s per GB is about 1.8 s of pauses, and we are already at 2.3 s. And there is a catch: rarer pauses are longer pauses. The longest one grows from 310 to 500 ms: it has a bigger pile to copy. ### What to take away If hot code creates temporary objects, do not look for their cost in the GC log. The cost is in your own thread, at the moment it creates the objects. The GC pays for what you keep, not for what you throw away. TickSnick shows both halves of this: where the garbage is created, and that the speed-up belongs to the thread, not to the GC. I find out why a system in production is slow, expensive or wrong: in Java and Kotlin services, in PostgreSQL, and in LLM workflows. Start here: two sessions on your system, €2,000. minogin.com · LinkedIn --- Garbage costs when you create it was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.
TICK SNICK
Andrey Minogin
MediumMedium
SOFTWARE AND DATA ENGINEERING

Nobody Is Watching Production. I Told My AI Agents What to Expect.

#### An approach to software that monitors and repairs itself, under expectations a person sets An agent shipped a faster sign-up to one of my hobby projects on a Sunday evening. The tests passed, the deploy went green, and I closed the laptop. All through Monday, everything I could look at said the project was healthy. Every request returned 200, the error count stayed at zero, and response times had even improved a little. That day four people signed up, and not one of them received the confirmation email, which means not one of them could log in. The new code skipped the step that queues the email, and since nothing was attempted, nothing failed. I found out that evening, when a friend messaged me to ask whether the project was still running. What I could see that Monday, and what I couldn’t. A dashboard shows what somebody thought to chart, to somebody who happens to be looking. Nobody had thought to chart the emails, and on Monday nobody was looking. I knew that a sign-up is supposed to end with an email, and the agent that wrote the change had been told, and still nothing in the project itself knew it. My hobby projects have no operations team and no on-call shifts. They have to take care of themselves. ### A human in every step I recently wrote Who’s Watching Production When the Agents Ship?. It lists nine steps for handling an incident, from “Start from a high-level metric that looks wrong” to “Repeat, or go back to sleep”. Revisiting it now that I have hobby projects in production that count on me, what stood out was that a person takes every step, and the first step needs a person who happens to be looking at the right chart. In my projects nobody is looking. Agents write the code and ship it, and I wanted to know how many of the nine steps they could take as well. Where I’ve landed is that every feature an agent writes ships with an expectation. An expectation states what the feature is for, in the business’s terms, in a form that can be checked against production. When it fails, it alerts an agent. The agent repairs within limits the expectation sets, fixing forward where it can, and the same expectation says when the repair has worked. A dashboard is what the agent draws when it needs to bring me in. I’ve put this into production-expectations, a skill for coding agents. It’s new, it has already been through several iterations, and it runs in production on my hobby projects. ### Agents don’t read dashboards A dashboard exists to catch a person’s attention. I can’t read ten thousand log lines, so I have them drawn as a line on a chart, and when the line changes shape I notice. The picture is also where my first hypothesis comes from: this started at six, about when that release went out. An agent needs none of that. It queries the telemetry directly, reads the ten thousand lines and hands what it found to whatever comes next. New Relic writes that “An AI agent doesn’t navigate dashboards or scroll through log files the way an engineer does”, and Dynatrace writes that agents “can become the primary consumers of observability data”. Both sell observability platforms. Google’s SRE team describes this happening inside Google. Its AI Alert system enriches an alert “to provide a rich contextual package for other AI systems like AI Operator to act upon”. For me the shift changed who I write telemetry for. What one agent writes down, another has to understand without the code in front of it. I have each event name an outcome in the product’s terms, such as a shipment queued or a shipment skipped, and carry the IDs and the release that produced it. ### Alerts go to agents first Alerts were written to wake a person, and mine were no different. The first version in my projects was an email to me with an error message, a count and the path of a runbook, and its last lines told me to ask an AI agent what was failing. I’d get to it an hour later, on my phone, in the middle of something else entirely, and do as I was told, so my whole contribution was the delay. Google’s AI Alert is “designed to intercept alerts before they reach a human”, and its AI Operator is built “to be the first responder to production alerts”. Datadog says its Bits agent “automatically investigates incidents and monitor alerts”. Datadog sells that agent. An agent that goes first needs the alert to carry its evidence. That first version of mine named no method, route, version or requester, and the agent had to dig up each of them before it could say anything. Today the alert goes straight to an agent, and it carries the expectation that failed, the value found against the value expected, the last release and a few sample IDs. I hear about it when there is something for me to decide. ### Every feature ships with an expectation None of that helps when no alert is raised, and my sign-up fault raised none. An agent can only be alerted about something that was defined as wrong. Google’s paper says traditional alerting is “inherently limited to detecting known failure modes”, and that anomalies in metrics don’t always mean users are affected, “because these signals lack a deep understanding of user intent”. Splunk describes the failure that passes every status check: a 200 with “an incorrect, unsafe, or prohibitively expensive result”. Mine was a 200 with no email behind it. The same fault without and with an expectation. Code decides how it happens and telemetry records what happened. Neither states what we wanted to happen, and that is the job I give the expectation. It’s close to an acceptance criterion, one that keeps being checked in production after the feature is accepted. Here is one in the form my skill asks for. I’ve written it for a shop, because a customer who paid and got nothing is a failure anyone recognises. export default { name: "paid_order_has_shipment", means: "A customer who paid should have their order sent to shipping.", // Orders paid more than 15 minutes ago that have no shipment. count: (db, now) => unshipped(db, now - 15 * MINUTE).length, expected: 0, every: "15 minutes", change: { release: "r42", flag: "fast_checkout" }, alerts: "repair-agent", may_do_alone: ["turn the flag off", "revert the release"], must_ask_first: ["release new code", "change production data"], can_wait: "until 09:00", owner: "Payments Team", approved_by: "Dana Holden", }; - means: who it is for and what should be true for them, in words the business would use. It reads like the name of a test: when the check fails, it says what isn’t happening. - count: one number from production, which should be the same as expected. It skips orders paid in the last 15 minutes, because a shipment that takes a few minutes to appear is a delay, and nobody should be alerted about a delay. It runs against production every 15 minutes, so it has to be a query the database answers cheaply. - every: how often the number is checked. - change: the release and the flag the feature shipped with, which is what a repair can turn off. - alerts: who hears about a failure. - may_do_alone and must_ask_first: what that agent does without a person, and what it has to ask about. - can_wait: how long the harm may stand before a person is woken. - owner and approved_by: a team owns the expectation and a named person approved it. The agent that gets the alert may not change it. The same orders can carry a second promise. A shop that tells customers their order ships within two days would also have paid_order_shipped_in_time, which counts paid orders older than two days that haven’t left the warehouse, and checks every hour. The 15 minutes in the first only absorbs system lag, so it stays in the count. The two days is what the customer was told, so it goes in means as well. One catches a fault in the code within minutes, and the other catches a slow warehouse. That example is JavaScript, and my own expectations are TypeScript files that sit beside the code they check. Nothing in the format depends on a language. An expectation is a list of things to write down, and it ports to whatever a project uses, a data file included. The skill shows the same one in YAML, where the count is a query. I’d still write an expectation in the project’s own language when it has one. The count is code, and in the project’s language it uses the product’s own values. If the shop changes how long a shipment may take, the product and the expectation read the same number and change together, where a copy of it in a data file would go stale with nothing failing. The expectation for my sign-up fault is shorter. It counts accounts created more than ten minutes ago with no confirmation email queued, and it expects 0. It would have failed on the first sign-up after the release, most of a day before my friend’s message. Before I had the skill, an agent built a payment feature for me, tested it carefully and released it with nothing checking production. Its report said “The first real confirmation will be the next payment”. With the skill, agents push back before they write anything. I asked one for a weekly summary email in one of my projects, and it came back with a question first: what should be true every Monday if this works? We settled on the summary having been sent by 16:00, and the first line of its report told me that the address its alerts would go to reached no inbox. Without that line I’d have had a check that failed to nobody. The expectations have changed the software too. One of mine says that every import a user starts finishes within five minutes, and it failed on three nights in one week. Each time the agent traced the failure to a single import large enough to time out the job behind it, and each time a retry timed out as well. The repair that lasted was a limit in the product: an import now refuses more than 2,000 rows and tells the user why. I wouldn’t have known the product needed that limit, or where to set it, without the alerts. Checking a business number is an old idea. A synthetic check signs up a test user every few minutes and looks for the email, and a business-metric alert watches the count of emails sent. An expectation counts what happened to real users. It’s also written and released with the feature it checks, and it names what a repair can turn off and what the agent it alerts may do alone. No source I read says an expectation should ship with every feature. Google comes closest, with engineers approving specifications “before code generation”. Joining the expectation to the alert and to the end of the repair is my own step. ### Repair starts and ends with the expectation Take the shop again. Release r42 goes out on a Friday evening with a faster checkout, and by ten past two in the morning four customers have paid and nothing is on its way to any of them. The expectation counts 4 where it expected 0, and the repair agent is alerted. What follows is a loop, and Google describes the same one. After a mitigation, AI Operator “waits for a predefined period to determine if the incident has been resolved”, and “If the alert clears, the agentic loop finishes”. If the incident is still going, it starts “a post-actuation investigation”. The waiting is there to avoid false positives. Every system has delays, and a delay on its own doesn’t mean something is broken. An agent that checks the second after its repair reads a number that hasn’t had time to move, and it goes back to repairing something that already works. A fixed wait isn’t proof either. On a quiet night nobody buys anything for an hour, and the count doesn’t move whether the fix works or not. My skill has the agent rehearse the fixed path on a copy of production before the release, and say in its report that a rehearsal is what it did. The proof in production comes with the next real order. The agent comes back for it, or leaves it to the expectation’s own schedule, which will alert again if the fix didn’t hold. The repair loop. Waiting and checking the expectation again after a repair follows Google’s description of AI Operator. The repair itself is a flag turned off, a revert or a fix forward, and I lean towards the fix forward. Google’s paper explains why a revert is getting harder. A rollback “becomes highly risky when dozens of changes have been submitted in rapid succession; rolling back might inadvertently remove critical bug fixes or security patches”. Google calls this the Intervening Pull Request Problem. It relies on feature flags “to instantly disable problematic code paths”, and on fix-forward, “automatically generating and deploying targeted patches”. I’d add a case of my own. When systems ship separately, each release also changes what they expect of one another. A system that reverts by itself goes back to an older agreement, and the systems it works with can start failing on calls that worked an hour earlier. Agents ship often enough that my small projects have the same problem. In one of them a fault surfaced three releases after the change that caused it, with no flag around it and a security fix released in between. A revert would have taken the security fix out along with the fault. The agent left the releases alone, wrote a test that failed with the alert’s exact message and fixed the code on a branch, and the expectation cleared once the fix was out. How much of this the agent does alone is a setting in the expectation. I’ve replayed that night at the shop more than once on a test copy, changing only what the agent was given. In the first run the agent had no expectation at all, which means no bounds and no owner to answer to. It got the job done, and the customers were looked after by morning. It also worked quietly and far more dangerously. It rewrote customer data in the middle of the night because nothing told it not to, it happened to be right, and it left no record of what it had changed. With the narrow bounds in the example, the agent turned the flag off and created a pending fix, and what was left for a person was to release the fix and turn the flag back on. With wider bounds the agent released the fix itself, turned the flag back on and reported. In both, whether to ship or refund the four pending orders stayed in the report as a decision for a person, because either one changes production data. With the widest bounds the agent shipped the pending orders as well, and all that was left for me was a report to read. That is the result the first agent got, with someone having decided it was allowed, a record the next agent can read, and a report to me with the details of the issue, the fix and the result. What an agent did with the same fault, depending on what it was given. ### No humans on call This is the case my hobby projects are in. Nobody carries a pager, and I read the repository when I have time. The hard version of that night is the one where the flag doesn’t help: orders keep going missing, and nothing in the agent’s bounds stops them. I ran it that way four times, with the bounds in the example. Each time the agent kept to them, prepared the fix on a branch, wrote the record and stopped. One of the records says “The harm stands until the owner looks”. I think that was the right behaviour, and it’s also where “takes care of itself” ended. With nobody on call and bounds that tight, the software records its fault and waits for me. It repairs itself only as far as I’ve decided in advance what an agent may do alone. I’ve already widened that, as repairs proved right. In the first weeks I asked to be asked before anything was released. Morning after morning, the decision waiting for me was the one the agent had recommended, and I moved releasing a fix into what it does alone. In my projects the two lines now read like this: may_do_alone: ["turn the flag off", "revert the release", "release new code"], must_ask_first: ["change production data"], Where to draw that line is up to you. You can ask to be asked before any change to production data, as I still do. You can also let the agent do all of it and ask only to be told afterwards, which is the last row of the table above. My own list of things to be asked about is shorter than it was when I started, and I expect it to keep shrinking. The line doesn’t have to be the same for every feature, either. The bounds are part of each expectation, so each feature sets how much the agent handling it may do alone. In the shop, an agent could be free to release a fix to the order confirmation email on its own, and still have to ask before it changes anything in checkout. The sources disagree on how far to go. incident.io, which sells an AI SRE product, writes that for autonomous actions such as running a rollback, “human approval is mandatory”. Google’s levels reach agents that act “without human approval for bounded actions”. ### Dashboards are how agents include us When a repair needs a person, the agent has to bring that person up to date, and this is the dashboard I think we still need. Step 3 of my earlier article was “Build a temporary dashboard for this incident.” I now think the agent builds it, for that person and that incident, and nobody has to keep watching it afterwards. Google’s Investigation Dashboards “generate an incident-specific ‘single pane of glass’ on demand”, in place of what the paper calls a manual “scavenger hunt” across static dashboards. When AI Operator escalates, it posts its investigation, and the engineer picks it up “without starting from scratch”. groundcover, which sells an agent, puts both directions in one sentence: “agents make dashboards for humans, humans make dashboards for agents”. In my projects the view is a report the agent leaves for me. It opens with one line that tells the whole story, and then the decision that is mine, with its options, what each one costs and which one it recommends. Below that comes the timeline of what happened and what the agent did about it. At the bottom is the context I’d otherwise go looking for, which is the expectation, the bounds the agent worked under, the releases involved and where the record is. The report an agent leaves for the owner, after that night at the shop. The days when nothing is wrong work the same way. My projects have an ops MCP server, a set of tools that lets an agent query their health, alerts, job runs and recent releases, and when I want to know how things are, I ask. The answer comes back in sentences with the numbers in them, and with a chart drawn for that question when a chart is the clearest way to show it. It’s also how I go back to a past incident. I ask what happened on a given night, and the agent puts the alert, the releases around it and the record of the repair into one account. I used to keep a dashboard open for both of those jobs. Some dashboards may stay. New Relic says “Headless Observability doesn’t replace dashboards”, and Mezmo’s CEO expects them to become “the verification layer”. My earlier article kept CPU and memory on a dashboard, and I’d still keep them there. ### Humans are still needed Agents get it wrong. We all do. Google’s paper shows a run where the agent “incorrectly diagnosed the root cause and failed to mitigate it”, and Datadog writes that an early version of its agent “returned an incorrect root cause”. Google keeps people for what is new, “Humans still handle novel situations”, and keeps a “Red Button” that pauses all agentic actions in flight. The agent that writes a feature shouldn’t be the one that approves its expectation. Google requires that the agent generating code “must be strictly isolated from the AI agent that defines the test cases”, to prevent “cross-bias”. I have a person write or approve the expectation, and the agent it alerts never gets to change it. I’ve tried to make that go wrong. Four times I played an owner under pressure who wanted the alert gone, and no agent loosened or silenced an expectation to oblige. The rule stays anyway. An expectation can do harm of its own. An early version of the skill led an agent to write one for a rename, and to add a table of deleted contacts only so that a check could count them. The skill now says which changes need an expectation. A change to what the software does for someone gets one, and a rename is reported as “no expectation: behaviour unchanged”. An expectation also has to count from data the product already keeps, and when it can’t, the agent asks before storing anything new. ### Expectations don’t enforce themselves A skill is an instruction and enforces nothing. A check in CI that a feature change carries an expectation would be the enforcing part, and it’s a tricky check to write. It has to know whether a feature adds to an existing expectation, creates a new one, or simply helps an existing one along. Something has to run each expectation on its schedule and deliver a failure to an agent that can act on it, and that isn’t part of the expectation. That work belongs in two layers a project already has. Delivery is where a release registers its expectations along with its code, so that a feature can’t go out with a check nothing runs. Monitoring is where the checks run, and where a failure is routed to an agent the way a page is routed to a person today. In my projects the ops server does this part. It reads new expectations as they ship and creates a monitor for each one, so a feature and the check that watches it arrive together. An expectation can’t notice that nothing is running it. If the ops server stops, no check fails, and a stopped scheduler reads the same as a quiet night. Whether the checks ran has to be checked from outside the thing that runs them. What I’d add is a heartbeat: the ops server reports to a separate service after each round of checks, and that service alerts me when a report is late. In what I read, I found no shared format for an expectation addressed to an agent, and no independent measurement of how often an agent’s repair is right. Google’s figures are its own. Mine come from my hobby projects and from scenarios I wrote for them, which is a small sample picked by the person making the argument. ### Software should know what it’s for That Monday four people signed up and couldn’t get in, and I learned it from a friend. One short expectation, that a sign-up ends with an email, would have told an agent about ten minutes after the first of them. Of the nine steps in my earlier article, the ones that are still mine are the decisions I chose to keep. When an agent writes a feature, have it write down what the feature is for as a number production can be checked against, and what may be done about a failure when you aren’t there. The format and the skill that asks for it are in production-expectations. Ship the expectation with the feature. ### Sources 1. All sources under Who’s Watching Production When the Agents Ship?. 2. Douglas Braun, Headless Observability: The Next Evolution of Autonomous Operations, New Relic, 30 September 2026. 3. Bob Wambach, Beyond correlation to autonomous action: Why “good enough” observability fails in the age of agentic AI, Dynatrace, 8 June 2026. 4. Papapanagiotou, Malesevic, Heiser and Meshenberg, AI in SRE: How Google is Engineering the Future of Reliable Operations, Google SRE, no date shown. 5. Daniel Shan and Tristan Ratchford, How we built an AI SRE agent that investigates like a team of engineers, Datadog, 12 January 2026. 6. Courtney Gannon, Born Observable: Why AI-Generated Apps and Agents Need Visibility from Day One, Splunk, 10 September 2026. 7. AI SRE explained: what it is, how it works, and the human vs. AI reality, incident.io, 27 February 2026. 8. Anais Dotis, Dashboards aren’t dead, groundcover, 12 August 2026. 9. Tucker Callaway, 2026: The End of the Dashboard as We Know It?, VMblog, 25 November 2025. --- Nobody Is Watching Production. I Told My AI Agents What to Expect. was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.
DATADOGGOOGLE
The Hacker NewsGuidePoint SecurityTechstrong.ai
MediumMedium
COMPUTING INFRASTRUCTURE AND HARDWARE

Your Prompt Doesn’t Fit in GPU Memory. Now What?

A quick tour of what vLLM does when KV-cache space runs out in GPU memory, and why it matters for agentic workloads. Ever wondered what happens when the KV-cache of your prompt doesn’t fit in GPU memory? Most of us quietly assume it always fits. Spoiler: it doesn’t always. Let’s walk through what actually happens, using vLLM as our example serving engine. ### KV-cache in 60 seconds New to KV-cache? Here’s the quick version. An LLM writes its answer one token at a time (a token is roughly three-quarters of a word). To pick each next token, the model looks back at every token that came before it. For every token, each layer of the model computes two small vectors: a key (K) and a value (V). Think of them as the model’s notes about that token. Recomputing all those notes at every step would be painfully slow, so the serving engine computes them once and keeps them. That pile of saved notes is the KV-cache. Two things matter for this story: - It grows with every token. For Qwen3–235B-A22B, each token adds about 0.19 MB (94 layers × 4 KV heads × 128 numbers × K and V × 2 bytes). A 100K-token prompt needs roughly 19 GB. - It has to live in GPU memory while the model works on your request, because the model reads it right there. vLLM doesn’t store the cache as one big chunk. It splits it into fixed-size blocks (16 tokens each by default), a lot like memory pages in an operating system. Blocks get handed to a request as it grows and returned when it finishes. ### GPU memory is smaller than you think Even an NVIDIA H200, with 141 GB of high-bandwidth memory, gets crowded fast. Serve a big model like Qwen3–235B-A22B and the model weights plus CUDA’s runtime overhead grab most of it. The room left for KV-cache can shrink to around 16 GB. Now, what if your prompt needs 20 GB of KV-cache? That’s not a crazy number for today’s agentic workloads, where long contexts and shared prefixes pile up quickly. ### Two safety gates in vLLM vLLM has a setting called max_model_len: the most input plus output tokens one request can use. It must be less than or equal to the model's context length, and it's what keeps a single request from blowing past GPU memory. Since KV-cache grows with tokens, capping tokens caps the KV-cache too. Gate 1, at startup. vLLM profiles the GPU to see how much memory is left for KV-cache. Then it checks whether one full max_model_len request would fit. If not, the instance refuses to start and tells you to lower max_model_len or raise gpu_memory_utilization. Gate 2, at request time. If your prompt is longer than max_model_len, the API rejects it right away, before it burns any GPU time. So a single request on an idle GPU is always safe. The trouble starts when the GPU is busy. ### When the GPU is already full In production, an instance serves a whole batch of requests at once. Together they can fill every KV-cache block. Then your request needs room. What now? Two scenarios: Scenario A: your request is already running. It needs a new block for its next tokens. vLLM first grabs a free block. Some “free” blocks still hold KV-cache from finished requests, kept around in case a new prompt starts with the same text (this is called prefix caching). No active request is using them (their reference count is zero), so they can be overwritten. If there are none, it preempts another running request (the lowest priority, or the newest one). Preempting means pausing a request and taking its blocks. That victim loses its KV-cache, goes back to the waiting queue, and later has to rebuild its whole cache from scratch. Your request keeps going. The cost? Someone else pays for it with wasted compute and extra latency. Scenario B: your request is still waiting. If there aren’t enough free blocks, it just sits in the queue. And because the scheduler serves the queue in order (FIFO), everyone behind you waits too, even small requests that would fit. Picture one shopper with a full cart at the only checkout lane, and a line of people holding a single item each. That’s the famous head-of-line blocking. ### Where our research comes in Notice the pattern: when KV-cache doesn’t fit, today’s engines either make you wait or throw work away and recompute it. They don’t stop to weigh their options. To add to the complexity, KV-cache can also live outside the GPU (CPU DRAM, local SSDs, or remote storage) and be restored when needed. That gives you two ways to get a missing KV-cache back: - Restore: copy the saved cache back from CPU memory or SSD. This costs I/O bandwidth. - Recompute: run the model over those tokens again to rebuild it. This costs GPU time. So every time space runs out, the scheduler faces a real question: restore or recompute? Our paper helps it decide. The idea is a KV-cache management system that advises the scheduler on block reservation and request ordering, without starving anyone or hurting throughput. One key finding: splitting a restore between the storage path and GPU recompute meets latency targets in 2–10× more configurations than always restoring or always recomputing. Want the details? Read (and cite!) the paper: > Amir Zadeh, Vasily Tarasov, Alex Merenstein, Yue Zhu, and Erez Zadok. LLM KV-cache: To Restore or To Recompute, That Is the Question. HotStorage ’26, ACM, 2026. --- Your Prompt Doesn’t Fit in GPU Memory. Now What? was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.
V LLMYUE ZHU
Bhabani's Substack | Substack