<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prantik Gachhayat on Medium]]></title>
        <description><![CDATA[Stories by Prantik Gachhayat on Medium]]></description>
        <link>https://medium.com/@prantikg?source=rss-60b32ec7f7d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YruOoDCUeUILRkVWURRN0g.jpeg</url>
            <title>Stories by Prantik Gachhayat on Medium</title>
            <link>https://medium.com/@prantikg?source=rss-60b32ec7f7d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:39:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prantikg/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Harness Engineering Deep Dive: The Outer Ring of Agentic AI]]></title>
            <link>https://medium.com/@prantikg/harness-engineering-deep-dive-the-outer-ring-of-agentic-ai-32002ca8f8ba?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/32002ca8f8ba</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[agentic-ai-architecture]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <category><![CDATA[llm-guardrails]]></category>
            <category><![CDATA[databricks-ai]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Thu, 29 Oct 2026 00:54:22 GMT</pubDate>
            <atom:updated>2026-10-29T00:55:13.740Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>This is the third post in my series on the three rings of agentic AI. The first covered the big picture: prompt, context and harness. The second went deep into context engineering. This one covers the outer ring, harness engineering.</p><p>The harness is where an agent goes from demo to production. A clever prompt and a well-built context can give you a great answer once. The harness is what makes the agent safe, reliable and affordable when it runs thousands of times a day.</p><p>I’ll cover six parts of the harness: guardrails and permissions, orchestration and planning, the feedback loop, evals, observability and tracing, and cost management. After that, I’ll cover latency, deployment, a reference architecture and a production checklist. Each part comes with a diagram or table, and I’ll keep using the retail sales agent from the last post as the running example.</p><h3>What the harness is</h3><p>A model only produces text. On its own, it can’t run a query, call an API or remember where it left off. The harness is everything around the model that makes it act. It runs the loop, calls the tools, holds the state and decides what’s allowed.</p><p>In the last post, the context layer decided what the model sees. The harness decides what the model can do, how its work is checked, and what it all costs.</p><p>At its center is the agent loop: call the model, let it pick a tool, run the tool, feed the result back, and repeat until the job is done. Six parts sit around that loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*Mv0qsUQ3nXDu4Oxp8L8Yow.png" /></figure><p>The three on the left shape each run while it happens. The three on the right measure every run, so you know whether the agent works, what it did and what it cost.</p><h3>1. Guardrails and permissions</h3><p>Guardrails control what goes into and out of the model. Permissions control what the agent is allowed to touch. Together, they are the agent’s safety layer.</p><p>There are three checkpoints:</p><ol><li><strong>Before the model.</strong> Input guardrails screen the request for prompt injection, off-topic asks, and sensitive data that shouldn’t go to a model.</li><li><strong>Before every tool call.</strong> Each action is checked against a policy and lands in one of three buckets: allowed, needs a human’s approval, or blocked.</li><li><strong>Before the user.</strong> Output guardrails check the answer for personal data, unsupported claims and policy breaks.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*JunqLj8dtqKUKVVKSdnzUA.png" /></figure><p>For the retail sales agent, reading sales and inventory is allowed. Emailing the store managers about a stock problem needs the regional manager’s approval. Reading payroll is blocked, because the agent has no reason to see it.</p><p>A few principles make this hold up in production:</p><ul><li><strong>Least privilege.</strong> Give the agent only the tools and data it needs, and make tools read-only by default.</li><li><strong>Act as the user.</strong> Where you can, run tools with the user’s own permissions instead of a powerful service account. A manager who sees only the Northeast shouldn’t see other regions through the agent.</li><li><strong>Treat tool output as data.</strong> A document or web page that says “ignore your rules” is just text. It never becomes an instruction.</li><li><strong>Put risky actions behind a human.</strong> Anything that writes data, sends a message or spends money waits for approval.</li></ul><h4>Sandboxing and audit</h4><p>Guardrails decide what the agent may do. You also need to control where it runs and keep a record of what it did.</p><ul><li><strong>Sandbox anything that runs code.</strong> If the agent writes and runs Python or SQL, run it in an isolated environment with no network access by default, limited compute, and only the data it needs.</li><li><strong>Keep secrets out of the context.</strong> API keys and passwords live in a secret store, and tools fetch them at call time. The model should never see them, because anything in the context can end up in an answer or a log.</li><li><strong>Give the agent its own identity.</strong> Each agent gets its own service identity, so its actions show up clearly in logs and can be switched off on their own.</li><li><strong>Keep an audit trail.</strong> Record who asked, what the agent did, which tools it called, and who approved any risky action. In regulated industries, this is often the first thing an auditor asks for.</li></ul><h3>2. Orchestration and planning</h3><p>Orchestration is how the work is structured. Planning is how the agent decides what to do next. This is where loop engineering lives.</p><p>There are three common patterns, from simplest to most complex:</p><ul><li><strong>Single loop.</strong> One agent decides one step at a time. Good for short tasks with a handful of tool calls.</li><li><strong>Plan, then execute.</strong> The agent writes a plan first, works through it, and re-plans when a step fails. Good for longer tasks where you want the steps visible.</li><li><strong>Supervisor and sub-agents.</strong> A supervisor splits the job and hands each part to a specialist agent with its own tools and smaller context. Good when the work spans different skills or data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*deNlFEvbrIJ2Vjh4C8D84g.png" /></figure><p>For the retail question, a planning agent might plan four steps: confirm the drop, check promotions, check inventory, then explain. A supervisor version might hand the sales query to a SQL agent and the document search to a research agent.</p><p>Start with the simplest pattern that works. Each step up adds power, but also cost, latency and more ways to fail.</p><p>Orchestration also covers the plumbing that makes runs dependable:</p><ul><li><strong>State and checkpoints,</strong> so a run can resume after a crash or a pause for human approval.</li><li><strong>Stop conditions:</strong> what counts as done, a maximum number of steps, and when to hand off to a person.</li><li><strong>Retries and fallbacks</strong> for flaky tools, with tools that are safe to call twice.</li><li><strong>Timeouts</strong> on every tool call and on the run as a whole.</li></ul><h3>3. The feedback loop</h3><p>A feedback loop is how the agent, and the team behind it, learn from what just happened. There are two, and they run at very different speeds.</p><p><strong>The inner loop runs within a single task, in seconds.</strong> After each step, the agent checks the result before moving on. Did the query return rows? Does the number look sensible? Does the answer actually address the question? If not, it fixes the query or tries another approach.</p><p>In the retail example, say the sales query comes back empty because of a wrong fiscal week filter. A good agent notices and fixes the filter. A bad one reports that sales were zero.</p><p><strong>The outer loop runs across many runs, over days and weeks.</strong> Real usage creates traces. Users rate answers, and reviewers flag bad ones. Those signals point to fixes in the prompt, the context or the tools. You test the fix with evals, release it, and watch the next round of runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*SnkzTPkiLsVxAsSaxknouA.png" /></figure><p>The inner loop makes each answer better. The outer loop makes the whole system better. You need both, and the outer loop only works if you have the next two parts in place: evals and tracing.</p><h3>4. Evals</h3><p>Evals tell you whether the agent works, and whether a change made it better or worse. Without them, every prompt tweak is a guess.</p><p>With agents, checking the final answer isn’t enough. An agent can reach the right answer by luck, or the wrong answer through a mostly good path. So evaluate at several levels:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vFQuFJeaAHCVR11xhxbxg.png" /></figure><p>Run evals in two places:</p><ul><li><strong>Offline, before release.</strong> Keep a fixed set of real questions with known good answers, including the tricky ones. Run it in your release pipeline. If the score drops, the change doesn’t ship.</li><li><strong>Online, on live traffic.</strong> Sample real runs, score them automatically, and send a slice to human reviewers. This catches the problems your test set didn’t think of, and good finds become new test cases.</li></ul><p>Use the cheapest check that works. Code checks come first: did the SQL run, is the output valid JSON? LLM judges handle what code can’t, like whether an explanation is accurate. Human reviews keep the judges honest.</p><h3>5. Observability and tracing</h3><p>When an agent gives a wrong answer, the first question is always the same: what did it actually do? Tracing answers that.</p><p>A trace records one full run of the agent. It’s made of spans, one for each step: every model call, tool call, retrieval and guardrail check, in order and with timing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*mun8KFEdCCU3PChbsCxcSA.png" /></figure><p>Each span records its inputs and outputs, tokens, time taken, cost and any errors. For model calls, it also records the exact context that was sent, which ties straight back to the last post.</p><p>With traces in place, debugging stops being guesswork. Say the retail agent blamed the weather instead of the stockouts. The trace shows whether the inventory tool was never called, came back empty, or was called and then ignored. Each of those has a different fix.</p><p>On top of traces, keep a dashboard of a few signals:</p><ul><li>Success rate and user ratings</li><li>Latency, for the whole run and for each step</li><li>Tool error rates</li><li>Guardrail triggers and blocked actions</li><li>Tokens and cost per run</li></ul><p>Two practical tips. Tag every trace with the user, session, agent version and prompt version, so you can filter and compare. And mask sensitive data before traces are stored, because a trace holds everything the agent saw.</p><h3>6. Cost management</h3><p>An agent costs more than a chatbot. It makes many model calls for each question, and each call carries a growing context. Multiply that by thousands of users, and cost becomes a design decision, not an afterthought.</p><p>The money goes to four places:</p><ul><li><strong>Model calls,</strong> driven by tokens in and out and by which model you use.</li><li><strong>Tool calls,</strong> like SQL warehouses, search and external APIs.</li><li><strong>Infrastructure,</strong> like vector indexes, serving endpoints and memory databases.</li><li><strong>Wasted work,</strong> like loops that go in circles, needless retries and oversized context.</li></ul><p>These are the main levers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*YeKULaoz1PxEvhqC9u3EKA.png" /></figure><p>The goal isn’t the cheapest agent. It’s the best answer at a cost the business is happy to pay. Track cost next to quality, because cutting one often moves the other.</p><h3>7. Latency</h3><p>Users feel a slow agent long before finance notices its cost. An agent that makes many calls in a row can take a long time to answer, and people stop waiting.</p><ul><li><strong>Stream the answer.</strong> Show progress and partial results as they arrive, like “Checking inventory…”. Visible steps feel faster than a blank screen.</li><li><strong>Run independent steps in parallel.</strong> The retail agent can check inventory, promotions and weather at the same time, because none of them depends on the others.</li><li><strong>Use small models for quick steps.</strong> Routing, input checks and simple lookups don’t need the largest model.</li><li><strong>Cache what repeats.</strong> Store lists and metric definitions rarely change during the day.</li><li><strong>Set a time budget.</strong> Decide how long a user should wait, and design the plan to fit. If a task will take longer, say so up front, or run it in the background and notify the user when it’s done.</li></ul><p>Latency and cost usually move together. Fewer, smaller, parallel calls make the agent both faster and cheaper.</p><h3>8. Deployment and versioning</h3><p>An agent isn’t one thing you deploy. It’s a prompt, a set of tools, a context setup, a model and orchestration code. Changing any one of them changes how the agent behaves.</p><ul><li><strong>Version everything together.</strong> Treat a release as a bundle of prompt, tools, model and agent code. Tag every trace with the bundle, so you know which version produced which answer.</li><li><strong>Promote through environments.</strong> Build in development, test in staging against your offline evals, then move to production.</li><li><strong>Release to a few users first.</strong> Send a small share of traffic to the new version. Compare its quality, cost and latency with the current one, then roll it out.</li><li><strong>Keep rollback one step away.</strong> If the new version misbehaves, switch back quickly, without a rebuild.</li><li><strong>Plan for model changes.</strong> Providers update and retire models. Pin the model version, rerun your evals before switching, and set a fallback model in the gateway in case the main one is down.</li></ul><p>For the retail agent, a prompt change in how “last week” is read would go to a handful of managers first. If their answers score as well as before, it rolls out to everyone.</p><h3>The technical architecture</h3><p>Here’s how all of these parts fit together as one system. As in the last post, I’ve used Databricks names, but the shape works on any platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*0oMq3HWeLo3MFob4Kgg9yQ.png" /></figure><p>Read it from top to bottom.</p><ol><li><strong>Entry.</strong> Every request comes through an AI gateway, which checks identity, applies rate limits and runs the input guardrails.</li><li><strong>Agent runtime.</strong> The orchestrator runs the loop and the plan. It saves state at each step, asks the context service from the last post for what the model should see, and pauses for human approval when an action needs it.</li><li><strong>Execution.</strong> This is where work actually happens: model calls, tool calls and sandboxed code. Every action passes a permission check first.</li><li><strong>Observe and measure.</strong> Every step is traced, scored by evals, counted for cost, and written to an audit log.</li><li><strong>Release.</strong> What you learn turns into fixes, and fixes reach the runtime only as a new tested version.</li></ol><p>The loop from the bottom back up to the runtime is the outer feedback loop from section 3, drawn as a system.</p><h3>What to use for each part</h3><p>As in the last post, start from what each part needs, then pick a tool. Here’s a Databricks option and some common alternatives. Product names change quickly, so treat this as a starting point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*qivaG3O7uK5SxwDrIvSG-w.png" /></figure><h3>Production checklist</h3><p>Here’s everything above as one list you can check an agent against before it goes live.</p><p><strong>Safety</strong></p><ul><li>Input and output guardrails are in place.</li><li>Every tool has a policy: allowed, needs approval, or blocked.</li><li>Tools are read-only by default and run with the user’s permissions.</li><li>Code runs in a sandbox, and secrets never enter the context.</li><li>The agent has its own identity, and every action lands in an audit log.</li></ul><p><strong>Reliability</strong></p><ul><li>Every run has a step limit, a timeout and a cost cap.</li><li>State is checkpointed, so runs can resume after a crash or an approval pause.</li><li>Flaky tools have retries, and tools are safe to call twice.</li><li>The agent checks each result before moving on.</li></ul><p><strong>Quality</strong></p><ul><li>An offline eval set of real questions runs on every change.</li><li>Online evals sample live traffic, with human review on a slice.</li><li>Evals check tool use and the path taken, not just the final answer.</li></ul><p><strong>Visibility</strong></p><ul><li>Every run is traced, with each span tagged by user, session and version.</li><li>Sensitive data is masked before traces are stored.</li><li>A dashboard tracks success rate, latency, errors, guardrail triggers and cost.</li></ul><p><strong>Cost and speed</strong></p><ul><li>Small models handle simple steps, and context is trimmed.</li><li>Independent steps run in parallel, and answers stream.</li><li>Budgets and alerts are set per team and per agent.</li></ul><p><strong>Release</strong></p><ul><li>Prompt, tools, model and code are versioned together.</li><li>New versions go to a small group first, and rollback is one step away.</li><li>The model version is pinned, with a fallback in the gateway.</li></ul><h3>Takeaways</h3><ul><li>The harness is what turns a model into a dependable agent. Prompt and context can get a good answer once. The harness gets it every time, safely.</li><li>Guardrails and permissions decide what the agent may see and do. Default to read-only, and put risky actions behind a human.</li><li>Start with the simplest orchestration that works. Add planning or sub-agents only when the task needs them.</li><li>Build both feedback loops. The agent checks its own steps, and your team learns from real runs.</li><li>You can’t improve what you can’t see. Evals tell you whether it works, and traces tell you why.</li><li>Treat cost as a design decision, and always measure it next to quality.</li></ul><p>That completes the three rings. The prompt tells the model what to do, the context gives it what it needs to see, and the harness makes it safe, reliable and affordable to run.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32002ca8f8ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Context Engineering Deep Dive: The Middle Ring of Agentic AI]]></title>
            <link>https://medium.com/@prantikg/context-engineering-deep-dive-the-middle-ring-of-agentic-ai-29112f1b3230?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/29112f1b3230</guid>
            <category><![CDATA[mosaicai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ontology]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[context-engineering]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 01:43:45 GMT</pubDate>
            <atom:updated>2026-10-23T01:43:45.477Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>In my last post ( <a href="https://medium.com/@prantikg/prompt-context-harness-the-three-rings-of-agentic-ai-9c63b66896d6">https://medium.com/@prantikg/prompt-context-harness-the-three-rings-of-agentic-ai-9c63b66896d6</a>) I described agentic AI as three rings: the prompt, the context and the harness. This post zooms into the middle ring, context engineering.</p><p>If your agent gives wrong or inconsistent answers, the context is the first place to look. The model can only reason about what it sees. Give it the wrong things, or too many things, and even the best model will struggle.</p><p>I’ll walk through every component that goes into an agent’s context, with a diagram, and use one retail example from start to finish so each piece feels concrete.</p><h3>What context engineering is</h3><p>Every time an agent calls a model, it sends a block of text called the context window. The model reads that block and nothing else. It has no other view of your data, your business or your user.</p><p>Context engineering is the work of deciding what goes into that block on every call. What to include, what to leave out, how to shrink what’s too long, and in what order to put it all.</p><p>A simple way to think about it: the prompt is the question you ask a new analyst. The context is the folder you hand them along with it. A sharp analyst with the wrong folder still gives you the wrong answer.</p><h3>Meet the retail agent</h3><p>Picture a mid-size apparel retailer with a few hundred stores and an online shop. They’ve built a sales analyst agent for their regional managers. Managers ask questions in plain English, and the agent queries the data and explains what it finds.</p><p>One Monday morning, the Northeast regional manager asks:</p><blockquote><em>Why did winter jacket sales drop in my stores last week?</em></blockquote><p>It looks like a simple question. But to answer it well, the agent needs to know a lot that isn’t in the question:</p><ul><li>Which stores are “my stores”?</li><li>What counts as a “winter jacket” in the product catalog?</li><li>Does “last week” mean the calendar week or the retail fiscal week?</li><li>Does “sales” mean gross sales or net sales after returns?</li><li>Is a drop normal for this time of year, or unusual?</li><li>What else happened last week: weather, promotions, stock problems?</li></ul><p>Every one of those answers has to come from the context. Let’s look at where each one comes from.</p><h3>The nine components of context</h3><p>A context window is built from nine kinds of content. I find it helps to sort them into three groups.</p><ul><li><strong>What to do:</strong> the instructions, the user’s question and a few worked examples.</li><li><strong>What happened before:</strong> the conversation so far and long-term memory about the user.</li><li><strong>What’s true in the world:</strong> retrieved documents, data with its metadata, the ontology, and the tools with their results.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*34MXe34EzI-lW647sTGy5A.png" /></figure><p>Not every agent needs all nine, and no single call should carry all of them in full. But a good agent designer knows each one and decides on purpose what to include.</p><h3>Each component, one by one</h3><h3>1. Instructions</h3><p>The instructions, or system prompt, tell the agent who it is and how to behave. They are the same on every call.</p><p><em>Retail example:</em> “You help regional managers understand sales performance. Use net sales unless told otherwise. Compare against the same fiscal week last year. Show the SQL you ran. Never show individual customer details.”</p><p>Keep instructions about behavior, not facts. Facts change, and they belong in the other components.</p><h3>2. The user’s question</h3><p>This is the request itself. It sounds obvious, but how you place it matters. Put it where the model will clearly see it, usually near the end, and mark it clearly as user input so the model doesn’t confuse it with instructions.</p><p><em>Retail example:</em> “Why did winter jacket sales drop in my stores last week?”</p><h3>3. Examples</h3><p>One or two worked examples show the model what a good answer looks like. They often work better than another paragraph of rules.</p><p><em>Retail example:</em> a sample question like “How did denim do in the Midwest last month?”, paired with the right SQL and a short, well-shaped answer.</p><p>Pick examples that match the question type. A sales comparison example helps a sales comparison question. A random one adds noise.</p><h3>4. Conversation history</h3><p>This is short-term memory: what was said earlier in this session.</p><p><em>Retail example:</em> ten minutes ago, the same manager asked about the Boston flagship store. If she now asks “what about online?”, the agent needs that history to know she still means winter jackets.</p><p>History grows fast. Long sessions need old turns summarized, or they push out more useful content.</p><h3>5. Long-term memory</h3><p>This is what the agent knows about the user across sessions.</p><p><em>Retail example:</em> this manager runs the Northeast region, prefers a chart with every answer, and usually compares against last year rather than last month.</p><p>This is how “my stores” becomes a list of real store IDs. Without it, the agent has to ask every time, or worse, guess.</p><h3>6. Retrieved documents</h3><p>These are unstructured documents pulled in because they relate to the question. This is the classic RAG piece.</p><p><em>Retail example:</em> the promotions calendar, last week’s operations notes from the region, and a memo about a delay at the distribution center.</p><p>The goal is a few highly relevant passages, not a pile of loosely related ones. Ten documents that mention “jackets” are worse than the one that explains why they were out of stock.</p><h3>7. Data and metadata</h3><p>The agent needs to know what data exists before it can query it. That means table names, column names, and plain-English descriptions of each.</p><p><em>Retail example:</em> a daily sales table with columns for store, product, fiscal date, gross sales, returns and discounts, each with a short description of what it holds.</p><p>Good column descriptions are some of the cheapest, highest-value context you can add. “amt_2” tells the model nothing. “Net sales after returns and discounts, in USD” tells it everything.</p><h3>8. Ontology</h3><p>Metadata describes tables. The ontology describes the business. It names the things the business cares about, how they connect, and what its terms mean.</p><p><em>Retail example:</em> a product belongs to a category, and winter jackets sit under outerwear. A store sits in a district, and a district sits in a region. A sale ties a store, a product and a fiscal week together. “Net sales” means gross sales minus returns and discounts. “Comparable stores” means stores open at least a year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*xIkHMU6W7sRwxdSVRI7OpA.png" /></figure><p>This is what turns a vague business question into the right query. It is also what makes two managers asking the same question get the same answer.</p><h3>9. Tools and tool results</h3><p>Tools are the actions the agent can take, like running a SQL query, checking inventory or looking up weather. The context holds two things here: a short description of each tool, so the model knows when to use it, and the results of tools it has already called.</p><p><em>Retail example:</em> the agent runs a sales query and gets back a small table of results. It then checks inventory and finds the top-selling jacket styles were out of stock for part of the week.</p><p>Tool results can be huge. Send back a summary or the top rows, not the full output of a thousand-row query.</p><h3>How the context gets built</h3><p>Knowing the nine components is half the job. The other half is the process that turns them into one context window, on every single call. I think of it as five steps.</p><ol><li><strong>Gather.</strong> Collect the candidates: search the documents, look up the user’s memory, find the relevant tables and ontology terms.</li><li><strong>Select.</strong> Keep only what helps with this question. Rank by relevance and drop the rest.</li><li><strong>Compress.</strong> Shrink what’s left. Summarize old conversation turns, keep the top rows of big results, and trim long documents to the passages that matter.</li><li><strong>Order.</strong> Arrange it so the model reads it well. Instructions first, then background, then the question near the end. Use clear labels for each part.</li><li><strong>Check.</strong> Before sending, confirm two things: the context fits the size budget, and the user is allowed to see everything in it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*dZrKIvQtwZHQ2DjWbgtv3g.png" /></figure><p>That last step is easy to forget. If a manager can only see her own region’s data, the context must follow the same rule. An agent that retrieves another region’s numbers into the window has already leaked them, even if the answer never mentions them.</p><h3>The technical architecture</h3><p>So far we’ve looked at what goes into the context and the steps that build it. Here’s how that looks as a system. I’ve used Databricks names, but the same shape works on any platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*AkRCPZ68DZCJP1JT9iYxlA.png" /></figure><p>There are five layers, read from top to bottom.</p><ol><li><strong>Sources.</strong> Where context comes from: business tables, documents, the ontology and metric definitions, past conversations, user memory and the tools the agent can call. Unity Catalog governs all of it.</li><li><strong>Prepare and index.</strong> Work that happens ahead of time, not during the question. Pipelines load the data, documents get chunked and embedded into a vector index, and table descriptions and tags stay in sync.</li><li><strong>Context assembly service.</strong> The heart of context engineering. It runs on every model call and does the gather, select, compress, order and check steps from the last section. Each box is a small, testable part: one fetches documents, one loads memory, one turns business words into tables and metrics, and so on.</li><li><strong>Agent runtime.</strong> The agent loop asks the assembly service for context, then calls the model through an AI gateway that enforces limits and logs usage.</li><li><strong>Observe and improve.</strong> Tracing records the exact context sent on every call. Evals and user feedback show where retrieval or the ontology needs fixing, and those fixes flow back into the assembly service.</li></ol><p>The key design choice is the middle layer. Keep context assembly as its own service, separate from the agent loop. That way you can test it, reuse it across agents, and change how it retrieves without touching the agent’s logic.</p><h3>What to use for each component</h3><p>The right tool depends on what each component needs, so start with the need. The table lists a Databricks option and some common alternatives. Product names change faster than the ideas behind them, so treat this as a starting point, not a final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5SOYNwcghpAmSqrqzMQTbw.png" /></figure><p>Two patterns stand out. Long-term memory and conversation history need an operational database, not an analytics table, because they are read and written on every turn. And whatever you pick for each row, tracing should cover all of them. MLflow tracing, Langfuse or LangSmith can show exactly which component put what into the window.The retail question, end to end</p><p>Here’s how the components work together to answer the manager’s question.</p><ol><li><strong>Long-term memory</strong> turns “my stores” into the list of Northeast stores.</li><li><strong>The ontology</strong> turns “winter jackets” into the right product category, “sales” into net sales, and “last week” into the last fiscal week.</li><li><strong>Metadata</strong> points the agent to the daily sales table and the right columns.</li><li><strong>The instructions</strong> say to compare against the same fiscal week last year. The agent runs a query with its <strong>SQL tool</strong>, and the result confirms a real drop.</li><li><strong>Retrieved documents</strong> bring in last week’s operations notes and the memo about the distribution center delay.</li><li>The agent checks the <strong>inventory tool</strong> and finds the best-selling jacket styles were out of stock for several days.</li><li>Following the <strong>example</strong> it was given, it writes a short answer with a chart.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*WC0RXUeSQ0wmcKVuFuhgBQ.png" /></figure><p>The answer: winter jacket sales fell against last year mainly because the top styles ran out of stock after a delay at the distribution center. Promotions weren’t the cause, since nothing changed on the promotions calendar.</p><p>Notice that the model did very little guessing. Almost every step was settled by something in the context. That’s the goal.</p><h3>How context goes wrong</h3><p>Most bad agent answers trace back to one of these five problems.</p><ul><li><strong>Too much.</strong> The window is stuffed with loosely related documents, and the one useful fact gets lost. More context is not better context.</li><li><strong>Too little.</strong> A key piece is missing, so the model fills the gap with a guess. Missing column descriptions and missing business definitions are the usual culprits.</li><li><strong>Stale.</strong> The context is out of date. Last quarter’s store list, an old promotions calendar, or an index that stopped refreshing.</li><li><strong>Conflicting.</strong> Two sources disagree, like a document that defines net sales one way and a metric definition that says another. The model picks one, and you can’t predict which.</li><li><strong>Leaking.</strong> The context holds data the user shouldn’t see. Even if the answer looks fine, the access rule has already been broken.</li></ul><p>In the retail example, a missing ontology would mean a gross sales number instead of net. A stale memory would point to the wrong stores. Each looks like a model mistake, but each is a context mistake.</p><h3>Making it production ready</h3><ul><li><strong>Measure retrieval on its own.</strong> Check whether the right documents and tables came back, separately from whether the final answer was right.</li><li><strong>Govern the ontology and metadata.</strong> Give each business term and table an owner, review definitions, and version them like code.</li><li><strong>Keep sources fresh.</strong> Schedule index refreshes and metadata syncs, and alert when they fail.</li><li><strong>Set a budget per component.</strong> Decide how much room history, documents and tool results each get, and summarize when they go over.</li><li><strong>Enforce access at retrieval time.</strong> Apply the same row and column rules as your data platform before anything enters the window.</li><li><strong>Log the full context.</strong> Save exactly what went into each call, so you can replay and debug a bad answer.</li><li><strong>Test with real questions.</strong> Build a set of real manager questions with known correct answers, and run it on every change.</li></ul><p>On Databricks, much of this maps to tools you may already use. Unity Catalog holds the metadata and access rules, metric views hold shared business definitions, Vector Search handles documents, and MLflow tracing records what each call saw.</p><h3>Takeaways</h3><ul><li>The model only knows what’s in the window. Context engineering decides what that is.</li><li>There are nine components, in three groups: what to do, what happened before, and what’s true in the world.</li><li>Building the window is a process: gather, select, compress, order and check.</li><li>The ontology is the piece most teams skip, and the one that most often fixes wrong answers on business data.</li><li>When an agent gets it wrong, check the context before you blame the model.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29112f1b3230" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prompt, Context, Harness: The Three Rings of Agentic AI]]></title>
            <link>https://medium.com/@prantikg/prompt-context-harness-the-three-rings-of-agentic-ai-9c63b66896d6?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c63b66896d6</guid>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <category><![CDATA[context-engineering]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[agentic-ai-architecture]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Sun, 18 Oct 2026 21:38:53 GMT</pubDate>
            <atom:updated>2026-10-18T21:38:53.716Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>This post is a simple way to explain the fundamental components of an agentic architecture. Every agent is built from the same three parts: a prompt, a context and a harness. That holds whether it answers questions over your data or runs a multi-step workflow.</p><p>These three parts also make a good design checklist. When you design an agent, work through each one in turn:</p><ol><li><strong>Prompt:</strong> What are we asking the agent to do, and how should it answer?</li><li><strong>Context:</strong> What does it need to see to do that well, including the business meaning behind the data?</li><li><strong>Harness:</strong> What can it do, how does its loop run, and what keeps it safe?</li></ol><p>Get all three right and the agent holds up in production. Skip one, and that’s usually where it breaks. The rest of this post walks through each layer, with a diagram and a production-ready checklist for each.</p><h3>Three names for one shift</h3><p>Every so often the AI world gives the same job a new name. First it was prompt engineering. Then people started talking about context engineering. Now I keep hearing harness engineering.</p><p>At first this sounded like rebranding to me. After building a few agentic systems, I think each name points at something real. The three don’t replace each other. Each one is a layer of the same system, and each layer wraps the one before it.</p><p>So yes, you can call them the three layers of agentic AI. I just find it more useful to picture them as rings than as a stack. Here is why.</p><h3>The big picture</h3><p>Picture an agent as a model sitting in the middle of three rings.</p><ul><li><strong>The prompt</strong> is what you tell the model.</li><li><strong>The context</strong> is everything the model can see when it answers.</li><li><strong>The harness</strong> is everything around the model that lets it act, and keeps it safe while it does.</li></ul><p>The prompt lives inside the context, and the harness decides what goes into the context. That’s why I avoid the word “stack.” In a stack, you can change one layer without touching the others. Here, a change in an outer ring changes what lands in the inner ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*tpdoqVYS6kNhC47afA1v9A.png" /></figure><h3>Ring 1: Prompt engineering</h3><p>Prompt engineering is about how you ask. It’s the oldest of the three, and the one most people already know.</p><p>A good prompt usually has a few parts: a role, the task, some rules, an example or two, and the shape of the answer you want back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*JLiS7r8byIiQaaeSNLJ6Lg.png" /></figure><p>This still matters. A vague instruction gives you a vague agent. But in a real agent, the prompt is often a small slice of what the model reads on any turn. It sits next to retrieved documents, tool results and chat history. You can polish the wording for days and still get bad answers if the rest of the window is wrong.</p><h3>Making it production ready</h3><ul><li><strong>Treat prompts as code.</strong> Keep them in version control, review every change, and never hard-code them deep inside the app.</li><li><strong>Test before you ship.</strong> Keep a fixed set of questions with known good answers, and run every prompt change against it.</li><li><strong>Keep it short.</strong> Rules and instructions go in the prompt. Facts and data belong in the context.</li><li><strong>Ask for structured output.</strong> Request JSON that follows a schema, and validate it before anything downstream uses it.</li><li><strong>Separate instructions from input.</strong> Mark clearly where user text and retrieved text begin, so injected instructions in a document are not obeyed.</li><li><strong>Log the prompt version.</strong> When an answer goes wrong, you should know exactly which prompt produced it.</li></ul><h3>Ring 2: Context engineering</h3><p>Context engineering is about what the model sees. Before every model call, something has to decide what goes into the context window and what stays out.</p><p>That window gets filled from several places: the system prompt, the conversation so far, documents pulled from a vector index, results from earlier tool calls, long-term memory, metadata like table and column descriptions, and an ontology of your business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*C_1p3xY3zsVMmp-lOZxLiQ.png" /></figure><p>The hard part is choosing. The window has a limit, and more is not better. Fill it with loosely related documents and the model gets distracted. Leave out the one column description it needed and it guesses. Good context engineering means fetching the right things, summarizing old turns, and keeping key instructions where the model won’t lose them.</p><h3>The ontology: teaching the agent your business</h3><p>The piece people skip most often is the ontology. An ontology is a shared map of your business. It names the things you care about, like customer, store, order and product. It says how they relate: an order belongs to a customer, a store sits in a region. And it pins down what your terms mean, like “active customer” or “net sales.”</p><p>Without it, the model guesses. Ask for revenue and it might pick gross sales from one table when finance means net sales from another. With an ontology in the context, the agent can map a business question to the right tables, joins and formulas, and give the same answer every time.</p><p>On Databricks, you can build much of this from what you already have: table and column comments in Unity Catalog, metric views for shared definitions, and the instructions and sample queries in a Genie space.</p><p>Put together, a solid context layer on Databricks usually combines Vector Search for documents, Unity Catalog for metadata and access rules, and an ontology for business meaning.</p><h3>Making it production ready</h3><ul><li><strong>Measure retrieval on its own.</strong> Check whether the right documents came back, separately from whether the final answer was good. Most bad answers start here.</li><li><strong>Keep sources fresh.</strong> Put index refreshes and metadata syncs on a schedule, and alert when they fail.</li><li><strong>Govern the ontology.</strong> Give every business term an owner, review definitions like any other data asset, and version them.</li><li><strong>Set a budget per source.</strong> Decide how much room history, documents and tool results each get, and summarize long conversations.</li><li><strong>Enforce access at retrieval time.</strong> Users should only get context they are allowed to see, using the same row and column rules as your data platform.</li><li><strong>Log what went in.</strong> Save the exact context for each call, so you can replay and debug a bad answer.</li></ul><h3>Ring 3: Harness engineering</h3><p>Harness engineering is about what the model can do, and how you keep it in check. A model only produces text. The harness is the software that turns that text into actions.</p><p>At its core is the agent loop: call the model, see which tool it wants, run that tool, feed the result back, and repeat until the job is done. Around the loop sit the tool definitions, permissions, a sandbox, saved state, retries, sub-agents, guardrails, tracing and evals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*YP1X6kdtP8rjrvK4Y5-WUQ.png" /></figure><p>This is where most production problems show up. An agent that loops forever, calls the wrong tool, or reads data it shouldn’t see usually has a harness problem, not a prompt problem.</p><p>On Databricks, a common setup is LangGraph for the loop and state, Unity Catalog for who can see what, and MLflow tracing to see what the agent actually did.</p><h3>Loop engineering: the heart of the harness</h3><p>The agent loop is the cycle in the middle of the diagram. Every agent has one, even a badly built one. Loop engineering is the work of designing that cycle so it behaves well, the same way data engineering is the work of building pipelines that hold up.</p><p>It comes down to a few decisions:</p><ul><li><strong>When to stop.</strong> What counts as done, how many steps are allowed, and when to give up and hand off.</li><li><strong>How to plan.</strong> Make a plan up front and work through it, or decide one step at a time. Long tasks usually need a plan.</li><li><strong>How to recover.</strong> When a tool fails or the model goes off track, retry, go back a step, or re-plan.</li><li><strong>When to check its own work.</strong> A quick self-review before answering, or a second agent that checks the first.</li><li><strong>When to split the work.</strong> Hand focused pieces to sub-agents, each with its own smaller context.</li><li><strong>When to bring in a human.</strong> Pause before writing data, sending messages or spending money, and stop to ask when unsure instead of guessing.</li></ul><p>Human in the loop shows how the loop and the harness work together. Loop engineering decides where the run pauses for a person. The harness makes the pause work: it saves the state, shows the request, records who approved, and resumes the run. In LangGraph, choosing where to put an interrupt is loop engineering. The checkpointer that lets the run pause and resume is harness.</p><p>To make the loop production ready, test the unhappy paths: failing tools, empty results and vague requests. Check that the loop stops, recovers or asks for help the way you designed it.</p><h3>Making it production ready</h3><ul><li><strong>Put limits on every run.</strong> Set a maximum number of steps, a timeout and a cost budget, so a stuck agent stops on its own.</li><li><strong>Give tools the least access they need.</strong> Read-only by default. Writes, deletes and anything that leaves the building need a human approval step.</li><li><strong>Save state and retry safely.</strong> Checkpoint the run so it can resume after a failure, and make tools safe to call twice.</li><li><strong>Trace every step.</strong> Record each model call, tool call, input and output, and watch cost, latency and failure rates on a dashboard.</li><li><strong>Run evals in two places.</strong> Offline, in your release pipeline, against a test set. Online, by sampling live runs for automated and human review.</li><li><strong>Add guardrails on both ends.</strong> Check inputs for injection and off-topic requests, and check outputs for sensitive data and policy breaks.</li><li><strong>Roll out like any other service.</strong> Use a staging environment, release to a small group first, and keep a way to roll back or switch models.</li></ul><h3>Why the focus keeps moving outward</h3><p>Early chatbots answered one question at a time. The prompt was almost the whole system, so prompt engineering was the skill that mattered.</p><p>Then we added retrieval and memory, and the question became what to put in front of the model. Now agents run for many steps, call tools and touch real systems. The question has become how to run them reliably and safely.</p><p>The three-ring picture leaves out two things:</p><ul><li><strong>The model itself.</strong> It sits at the center of all three rings. Choosing it, or fine-tuning it, is a separate decision.</li><li><strong>Governance.</strong> Who owns the agent, who approves its access, and how you audit it. Technically this lives in the harness, but in most companies a different team owns it.</li></ul><h3>What to take away</h3><ul><li>Prompt engineering is how you ask. Context engineering is what the model sees. Harness engineering is what the model can do.</li><li>The layers are nested, not stacked. The harness builds the context, and the prompt lives inside it.</li><li>When an agent misbehaves, debug from the outside in. The outer rings are where many failures hide.</li><li>None of the old skills went away. A good agent still needs a clear prompt.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c63b66896d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build an AI FinOps Analyst on Databricks with a Genie Agent]]></title>
            <link>https://medium.com/@prantikg/build-an-ai-finops-analyst-on-databricks-with-a-genie-agent-31f0e41104a3?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/31f0e41104a3</guid>
            <category><![CDATA[ai-finops]]></category>
            <category><![CDATA[databricks-genie]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[databricks-finops]]></category>
            <category><![CDATA[genie-agents]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 02:50:17 GMT</pubDate>
            <atom:updated>2026-10-13T02:50:17.226Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Overview</strong></p><p>Your Databricks bill is easy to read in total and hard to explain. A Genie Agent can answer “what changed, and why?” in plain language, but only if it reads governed definitions of cost instead of raw system tables. This post shows how to build that: curated cost views on the billing and compute system tables, a Genie Agent configured on top of them, and a scheduled job that asks it a fixed set of questions every morning, validates the answers and writes a short brief. The agent recommends. People approve every change.</p><h3>What you’ll learn</h3><ul><li>Why FinOps questions suit a Genie Agent, and where they don’t</li><li>How to turn system tables into governed cost views (dollars per team, SKU, job and pipeline; cost spikes by resource; cluster utilization; task duration baselines)</li><li>How to configure the agent so its answers follow your definitions and thresholds</li><li>How to get a summary of the SKUs that drive the bill, the resource behind each spike, and a recommended change grounded in your own playbook</li><li>How to run it daily through the Genie API, capture the SQL behind each answer, and validate it</li><li>Which of the common FinOps questions the agent can answer well, and which need something else</li><li>The guardrails that keep an automated cost analyst trustworthy</li></ul><h3>The problem: a bill nobody can explain</h3><p>Cost reviews tend to follow the same script. Someone notices the monthly number went up. Someone else opens the usage dashboard, filters by workspace, finds three jobs that look expensive, and asks their owners. A week later there’s a partial answer and the spend has moved again.</p><p>The data to answer these questions already exists. Databricks records billable usage, list prices, compute utilization and job runs in system tables. What’s missing is the layer between the tables and the person asking: a shared definition of “cost,” an owner for every dollar, and something that asks the same questions every day without being reminded.</p><p>A Genie Agent is a good fit for the “asking” part. It turns a question like “which team’s spend grew most this month?” into SQL, runs it as the user, and explains the result. But an agent is only as accurate as the definitions it can find. If you point it at raw system.billing.usage, it will have to guess how to convert usage into dollars. That is the same lesson as in my post on Genie Ontology: meaning comes first, then the agent.</p><h3>The architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4S5jK8_zr2dEjDz4IlEveA.png" /></figure><p>Read it left to right. System tables hold the facts. Governed views turn them into business terms. The Genie Agent reads only those views. A scheduled job asks it questions and checks its work. Outputs go to people.</p><p>There are two lanes on purpose. Rule-based jobs on the same views handle the known, safe fixes, such as a cluster with no auto-termination. The agent handles the open-ended questions and the explanations. Because both read the same governed definitions of cost, they never disagree on a number.</p><p>This post is about the agent lane. The rule-based lane is a topic of its own.</p><h3>Step 1: Make cost attributable</h3><p>An analyst can’t tell you which team spent a dollar if nobody recorded the team. Attribution comes first, and the agent can’t invent it later.</p><ul><li><strong>Tag compute.</strong> Use cluster policies to require a tag such as team on every cluster, so no compute can be created without an owner. In this post, team is just my example tag key. Use whatever your organization already uses.</li><li><strong>Tag serverless usage.</strong> For serverless workloads, use budget policies, which add tags to usage records. The custom_tags column of the billing usage table includes tags added by serverless usage policies.</li><li><strong>Measure what’s untagged.</strong> Make untagged spend a metric in its own right. It tells you how much of your analysis is blind.</li></ul><h3>Step 2: Build governed cost views</h3><p>The billing documentation shows how to convert usage into dollars: multiply usage quantity by the list price, joining on the SKU and on the price’s validity window. I’ll wrap that in a view so everyone, including the agent, uses the same calculation.</p><pre>CREATE SCHEMA IF NOT EXISTS main.finops;<br><br>CREATE OR REPLACE VIEW main.finops.cost_daily<br>COMMENT &#39;Daily list-price cost in USD per usage record. Source of truth for FinOps questions.&#39;<br>AS<br>SELECT<br>  u.usage_date,<br>  u.workspace_id,<br>  u.sku_name,<br>  u.billing_origin_product,<br>  u.custom_tags,<br>  u.usage_metadata,<br>  u.identity_metadata,<br>  u.usage_quantity * p.pricing.effective_list.default AS list_cost_usd<br>FROM system.billing.usage u<br>JOIN system.billing.list_prices p<br>  ON p.sku_name = u.sku_name<br> AND u.usage_end_time &gt;= p.price_start_time<br> AND (p.price_end_time IS NULL OR u.usage_end_time &lt; p.price_end_time);</pre><p>Two things to say out loud, in the view comment and in the agent’s instructions. This is <strong>list price</strong>, not your negotiated rate, so treat the numbers as relative, not as invoice values.</p><h3>Team spend growth</h3><p>Compare the current month so far against the same stretch of the previous month, so a half-finished month doesn’t look like a drop.</p><pre>CREATE OR REPLACE VIEW main.finops.team_spend_growth AS<br>WITH cur AS (<br>  SELECT COALESCE(custom_tags[&#39;team&#39;], &#39;untagged&#39;) AS team, SUM(list_cost_usd) AS cost_usd<br>  FROM main.finops.cost_daily<br>  WHERE usage_date &gt;= date_trunc(&#39;month&#39;, current_date())<br>    AND usage_date &lt;  current_date()<br>  GROUP BY 1<br>),<br>prev AS (<br>  SELECT COALESCE(custom_tags[&#39;team&#39;], &#39;untagged&#39;) AS team, SUM(list_cost_usd) AS cost_usd<br>  FROM main.finops.cost_daily<br>  WHERE usage_date &gt;= add_months(date_trunc(&#39;month&#39;, current_date()), -1)<br>    AND usage_date &lt;  add_months(current_date(), -1)<br>  GROUP BY 1<br>)<br>SELECT<br>  COALESCE(cur.team, prev.team)                   AS team,<br>  COALESCE(prev.cost_usd, 0)                      AS prior_period_usd,<br>  COALESCE(cur.cost_usd, 0)                       AS current_period_usd,<br>  COALESCE(cur.cost_usd, 0) - COALESCE(prev.cost_usd, 0) AS growth_usd<br>FROM cur FULL OUTER JOIN prev ON cur.team = prev.team;</pre><h3>Jobs and pipelines by cost</h3><p>Usage records carry the job or pipeline that incurred them in usage_metadata. Pipelines have a name in system.lakeflow.pipelines, which is a slowly changing table, so I keep only the latest row per pipeline.</p><pre>CREATE OR REPLACE VIEW main.finops.workload_cost_30d AS<br>WITH pipelines AS (<br>  SELECT workspace_id, pipeline_id, name<br>  FROM system.lakeflow.pipelines<br>  QUALIFY ROW_NUMBER() OVER (PARTITION BY workspace_id, pipeline_id ORDER BY change_time DESC) = 1<br>)<br>SELECT<br>  CASE WHEN c.usage_metadata.job_id IS NOT NULL THEN &#39;job&#39; ELSE &#39;pipeline&#39; END AS workload_type,<br>  COALESCE(c.usage_metadata.job_id, c.usage_metadata.dlt_pipeline_id)        AS workload_id,<br>  MAX(p.name)                                                                 AS pipeline_name,<br>  COALESCE(MAX(c.custom_tags[&#39;team&#39;]), &#39;untagged&#39;)                            AS team,<br>  SUM(c.list_cost_usd)                                                        AS cost_30d_usd<br>FROM main.finops.cost_daily c<br>LEFT JOIN pipelines p<br>  ON c.workspace_id = p.workspace_id<br> AND c.usage_metadata.dlt_pipeline_id = p.pipeline_id<br>WHERE c.usage_date &gt;= date_sub(current_date(), 30)<br>  AND COALESCE(c.usage_metadata.job_id, c.usage_metadata.dlt_pipeline_id) IS NOT NULL<br>GROUP BY 1, 2;</pre><p>To show a job name rather than an ID, join the jobs table in system.lakeflow the same way. Check its current columns first.</p><h3>Long-running tasks, against their own baseline</h3><p>A task that takes an hour is only a problem if it used to take ten minutes. Compare each task with its own history.</p><p>One detail matters here: in the job timeline tables, a run longer than an hour is split into several rows, and only the final row carries the result state. So measure each task run as the span from its first row to its last, not as a single row.</p><pre>CREATE OR REPLACE VIEW main.finops.task_duration_drift AS<br>WITH task_runs AS (<br>  SELECT<br>    job_id, task_key, run_id,<br>    MIN(period_start_time) AS started_at,<br>    MAX(period_end_time)   AS ended_at,<br>    MAX_BY(result_state, period_end_time) AS final_state<br>  FROM system.lakeflow.job_task_run_timeline<br>  WHERE period_start_time &gt;= date_sub(current_date(), 37)<br>  GROUP BY job_id, task_key, run_id<br>),<br>durations AS (<br>  SELECT job_id, task_key, started_at,<br>         unix_timestamp(ended_at) - unix_timestamp(started_at) AS duration_s<br>  FROM task_runs<br>  WHERE final_state = &#39;SUCCEEDED&#39;<br>),<br>baseline AS (<br>  SELECT job_id, task_key,<br>         percentile_approx(duration_s, 0.5) AS median_30d_s,<br>         COUNT(*) AS runs_30d<br>  FROM durations<br>  WHERE started_at &lt;  date_sub(current_date(), 7)<br>  GROUP BY job_id, task_key<br>),<br>recent AS (<br>  SELECT job_id, task_key, AVG(duration_s) AS avg_7d_s, COUNT(*) AS runs_7d<br>  FROM durations<br>  WHERE started_at &gt;= date_sub(current_date(), 7)<br>  GROUP BY job_id, task_key<br>)<br>SELECT r.job_id, r.task_key, b.median_30d_s, r.avg_7d_s,<br>       r.avg_7d_s / NULLIF(b.median_30d_s, 0) AS slowdown_ratio,<br>       b.runs_30d, r.runs_7d<br>FROM recent r JOIN baseline b USING (job_id, task_key);</pre><h3>Oversized clusters, from utilization</h3><p>For a first signal of oversizing, look at how busy the worker nodes actually are. The compute node timeline records CPU and memory use per node. I keep workers only, because a driver sitting idle is normal.</p><pre>CREATE TABLE IF NOT EXISTS main.finops.policy_thresholds (<br>  oversized_avg_cpu_pct DOUBLE,<br>  oversized_p95_cpu_pct DOUBLE,<br>  oversized_p95_mem_pct DOUBLE,<br>  slowdown_ratio_alert  DOUBLE,<br>  spike_ratio_alert     DOUBLE,<br>  spike_min_usd         DOUBLE<br>);<br>INSERT INTO main.finops.policy_thresholds VALUES (20.0, 50.0, 60.0, 1.5, 2.0, 50.0);</pre><pre>CREATE OR REPLACE VIEW main.finops.cluster_utilization_7d AS<br>SELECT<br>  n.cluster_id,<br>  COUNT(DISTINCT n.instance_id)                                     AS worker_nodes_seen,<br>  AVG(n.cpu_user_percent + n.cpu_system_percent)                    AS avg_cpu_pct,<br>  percentile_approx(n.cpu_user_percent + n.cpu_system_percent, 0.95) AS p95_cpu_pct,<br>  AVG(n.mem_used_percent)                                           AS avg_mem_pct,<br>  percentile_approx(n.mem_used_percent, 0.95)                       AS p95_mem_pct<br>FROM system.compute.node_timeline n<br>WHERE n.driver = false<br>  AND n.start_time &gt;= date_sub(current_timestamp(), 7)<br>GROUP BY n.cluster_id;<br><br>CREATE OR REPLACE VIEW main.finops.oversized_cluster_candidates AS<br>SELECT<br>  u.cluster_id,<br>  u.worker_nodes_seen, u.avg_cpu_pct, u.p95_cpu_pct, u.avg_mem_pct, u.p95_mem_pct,<br>  COALESCE(c.cost_7d_usd, 0) AS cost_7d_usd<br>FROM main.finops.cluster_utilization_7d u<br>LEFT JOIN (<br>  SELECT usage_metadata.cluster_id AS cluster_id, SUM(list_cost_usd) AS cost_7d_usd<br>  FROM main.finops.cost_daily<br>  WHERE usage_date &gt;= date_sub(current_date(), 7) AND usage_metadata.cluster_id IS NOT NULL<br>  GROUP BY 1<br>) c ON u.cluster_id = c.cluster_id<br>CROSS JOIN main.finops.policy_thresholds t<br>WHERE u.avg_cpu_pct &lt; t.oversized_avg_cpu_pct<br>  AND u.p95_cpu_pct &lt; t.oversized_p95_cpu_pct<br>  AND u.p95_mem_pct &lt; t.oversized_p95_mem_pct;</pre><p>These numbers are starting points, not recommendations. Tune them against a few clusters and workloads you know well. The two spike values mean “at least double its usual daily cost, and at least $50 above it”, so tiny workloads don’t generate noise. To add the cluster name, owner and configured worker count, join the latest row per cluster from system.compute.clusters, after checking its current schema. I&#39;ve left those columns out because I haven&#39;t confirmed their exact names.</p><h3>Which SKUs drive the bill</h3><p>A SKU summary shows where the money goes by product, such as the kind of compute or the serving type. Compare the last 30 days with the 30 before, so a rising SKU stands out.</p><pre>CREATE OR REPLACE VIEW main.finops.sku_cost_30d AS<br>WITH cur AS (<br>  SELECT sku_name, SUM(list_cost_usd) AS cost_usd<br>  FROM main.finops.cost_daily<br>  WHERE usage_date &gt;= date_sub(current_date(), 30) AND usage_date &lt; current_date()<br>  GROUP BY sku_name<br>),<br>prev AS (<br>  SELECT sku_name, SUM(list_cost_usd) AS cost_usd<br>  FROM main.finops.cost_daily<br>  WHERE usage_date &gt;= date_sub(current_date(), 60) AND usage_date &lt; date_sub(current_date(), 30)<br>  GROUP BY sku_name<br>)<br>SELECT<br>  COALESCE(cur.sku_name, prev.sku_name)               AS sku_name,<br>  COALESCE(cur.cost_usd, 0)                           AS cost_30d_usd,<br>  COALESCE(prev.cost_usd, 0)                          AS prior_30d_usd,<br>  COALESCE(cur.cost_usd, 0) - COALESCE(prev.cost_usd, 0) AS change_usd,<br>  COALESCE(cur.cost_usd, 0) / NULLIF(SUM(COALESCE(cur.cost_usd, 0)) OVER (), 0) AS share_of_total<br>FROM cur FULL OUTER JOIN prev ON cur.sku_name = prev.sku_name;</pre><h3>Spikes, and the resource behind them</h3><p>A spike is a resource whose cost yesterday was far above its own recent average. Usage records identify the resource through usage_metadata. I use the job, pipeline and cluster identifiers, which the billing documentation lists. Other workload types, such as SQL warehouses or serving endpoints, have their own identifiers, so check the usage metadata fields for the workloads you run and extend the view.</p><pre>CREATE OR REPLACE VIEW main.finops.cost_spikes AS<br>WITH daily AS (<br>  SELECT<br>    usage_date,<br>    CASE WHEN usage_metadata.job_id IS NOT NULL THEN &#39;job&#39;<br>         WHEN usage_metadata.dlt_pipeline_id IS NOT NULL THEN &#39;pipeline&#39;<br>         ELSE &#39;cluster&#39; END                                                   AS resource_type,<br>    COALESCE(usage_metadata.job_id, usage_metadata.dlt_pipeline_id, usage_metadata.cluster_id) AS resource_id,<br>    SUM(list_cost_usd)                                                        AS cost_usd<br>  FROM main.finops.cost_daily<br>  WHERE usage_date &gt;= date_sub(current_date(), 15)<br>    AND usage_date &lt;  current_date()<br>    AND COALESCE(usage_metadata.job_id, usage_metadata.dlt_pipeline_id, usage_metadata.cluster_id) IS NOT NULL<br>  GROUP BY 1, 2, 3<br>),<br>base AS (<br>  SELECT resource_type, resource_id, AVG(cost_usd) AS baseline_daily_usd<br>  FROM daily<br>  WHERE usage_date &lt; date_sub(current_date(), 1)<br>  GROUP BY resource_type, resource_id<br>),<br>latest AS (<br>  SELECT * FROM daily WHERE usage_date = date_sub(current_date(), 1)<br>)<br>SELECT<br>  l.usage_date, l.resource_type, l.resource_id,<br>  l.cost_usd                                         AS latest_day_usd,<br>  COALESCE(b.baseline_daily_usd, 0)                  AS baseline_daily_usd,<br>  l.cost_usd - COALESCE(b.baseline_daily_usd, 0)     AS excess_usd,<br>  l.cost_usd / NULLIF(b.baseline_daily_usd, 0)       AS spike_ratio,<br>  b.baseline_daily_usd IS NULL                       AS is_new_resource<br>FROM latest l<br>LEFT JOIN base b USING (resource_type, resource_id)<br>CROSS JOIN main.finops.policy_thresholds t<br>WHERE l.cost_usd - COALESCE(b.baseline_daily_usd, 0) &gt;= t.spike_min_usd<br>  AND (b.baseline_daily_usd IS NULL OR l.cost_usd / b.baseline_daily_usd &gt;= t.spike_ratio_alert);</pre><p>A resource that did not exist before has no baseline, so it appears as new. That is often exactly what you want to hear about.</p><h3>Recommendations from your own playbook</h3><p>This is the part that keeps the “recommended change” honest. If you leave the agent to improvise, it will give generic advice. Instead, write down what your team would actually check for each kind of finding, in a small table, and join it to the findings. The agent then looks the advice up and doesn’t invent it.</p><pre>CREATE TABLE IF NOT EXISTS main.finops.optimization_playbook (<br>  signal             STRING,<br>  what_to_check      STRING,<br>  recommended_change STRING<br>);<br><br>INSERT INTO main.finops.optimization_playbook VALUES<br> (&#39;spike_job&#39;,      &#39;Compare the latest run with earlier ones: input volume, retries, cluster size.&#39;,<br>                    &#39;Fix the cause of the change. Resize compute only if the workload is genuinely larger.&#39;),<br> (&#39;spike_pipeline&#39;, &#39;Look for a full refresh, a backlog replay, or a change from triggered to continuous.&#39;,<br>                    &#39;Avoid unplanned full refreshes. Use triggered runs if freshness allows.&#39;),<br> (&#39;spike_cluster&#39;,  &#39;Look for a cluster left running, or an auto-termination setting that was removed.&#39;,<br>                    &#39;Restore auto-termination and consider moving scheduled work to job compute.&#39;),<br> (&#39;oversized_cluster&#39;, &#39;Check utilization over a week that includes the busiest period.&#39;,<br>                    &#39;Lower the maximum workers or use a smaller node type, then re-check utilization.&#39;);<br><br>CREATE OR REPLACE VIEW main.finops.spike_findings AS<br>SELECT s.*, p.what_to_check, p.recommended_change<br>FROM main.finops.cost_spikes s<br>LEFT JOIN main.finops.optimization_playbook p<br>  ON p.signal = CONCAT(&#39;spike_&#39;, s.resource_type);</pre><p>The rows above are examples to replace with your own team’s guidance. They are not general rules for every workload. Add rows for the SKUs you care about, for example when a large share sits on all-purpose compute that runs scheduled work, but check your actual SKU names first.</p><h3>Step 3: Configure the Genie Agent</h3><p>Create a Genie Agent (what the API still calls a space) whose data is <strong>only</strong> the views above. Do not add the raw system tables. If the agent can reach system.billing.usage directly, it may bypass your price join and give you numbers that disagree with everyone else&#39;s.</p><p>Then do the work that makes an agent reliable:</p><ul><li><strong>Describe each view and column</strong> in business language. The comments in the SQL above are a start.</li><li><strong>Add instructions.</strong> Spell out the definitions and the rules of the road. For example:</li></ul><p>Cost always means list_cost_usd from cost_daily, in USD at list price, not invoiced price. &quot;Spend growth&quot; compares the current month to date against the same days of the previous month. &quot;Oversized&quot; means a cluster listed in oversized_cluster_candidates. A &quot;slow task&quot; is one in task_duration_drift whose slowdown_ratio is above the alert value in policy_thresholds. &quot;Top SKUs&quot; come from sku_cost_30d, ranked by cost_30d_usd, with their share_of_total. A &quot;spike&quot; is a row in spike_findings. For every spike, report the resource type and ID, the excess cost, and the what_to_check and recommended_change text from the playbook. For oversized clusters, use the oversized_cluster row of optimization_playbook the same way. Never invent a recommendation that is not in the playbook; if a finding has none, say so. Always show the supporting numbers. If a team is untagged, say so, and do not guess an owner.</p><ul><li><strong>Add certified example queries</strong> for the questions you will ask every day. These are the fixed set your job sends.</li><li><strong>Grant access carefully.</strong> The people and the service principal using the agent need read access to the views. Whether they need access to the underlying system tables depends on how your views are secured, so test with a real user before you rely on it.</li></ul><h3>Step 4: Run it every day</h3><p>Genie is an interactive tool, so you schedule a job that asks it questions. The Genie Conversation API supports this, and the Databricks SDKs wrap it. In the Python SDK, start_conversation_and_wait starts a conversation and returns the finished message, and get_message_attachment_query_result fetches the rows for a query attachment.</p><p>A few operating notes from the API documentation:</p><ul><li>Use a service principal with OAuth machine-to-machine authentication, since there is no browser in a scheduled job. It needs access to the data and CAN USE on a SQL warehouse.</li><li><strong>Start a new conversation for each question.</strong> Reusing a thread can reduce accuracy.</li><li>The API does not retry for you, so build in retries with backoff.</li><li>Conversations accumulate against a limit per agent, so delete old ones when you’re done.</li></ul><p>Here is a compact version of the job. Treat it as a starting point: confirm the message and attachment field names against your installed SDK version, because they have changed over time.</p><pre>import json, datetime as dt<br>from databricks.sdk import WorkspaceClient<br>from databricks.sdk.service.serving import ChatMessage, ChatMessageRole<br><br>w = WorkspaceClient()                          # runs as a service principal<br>SPACE_ID = &quot;&lt;your-genie-agent-space-id&gt;&quot;<br>LLM_ENDPOINT = &quot;&lt;your-chat-model-serving-endpoint&gt;&quot;<br>RUN_ID = dt.datetime.utcnow().strftime(&quot;%Y%m%dT%H%M%S&quot;)<br><br>QUESTIONS = {<br>  &quot;team_growth&quot;:  &quot;Which team&#39;s spend grew most this month versus the same days last month? Show the top 5.&quot;,<br>  &quot;top_workload&quot;: &quot;Which job or pipeline cost the most in the last 30 days? Show the top 5.&quot;,<br>  &quot;oversized&quot;:    &quot;Which clusters look oversized, ranked by their cost in the last 7 days? Show the top 5.&quot;,<br>  &quot;slow_tasks&quot;:   &quot;Which tasks are running much slower than their 30-day baseline? Show the top 5.&quot;,<br>  &quot;sku_mix&quot;:      &quot;Summarize cost by SKU for the last 30 days. Which SKUs contribute most, what share of the total is each, and which grew most versus the prior 30 days? Show the top 5.&quot;,<br>  &quot;spikes&quot;:       &quot;Which resources had a cost spike yesterday? For each, give the resource type and ID, the excess cost, what to check and the recommended change from the playbook.&quot;,<br>}<br><br>def ask(question):<br>    msg = w.genie.start_conversation_and_wait(SPACE_ID, question)<br>    sql, text, rows = None, None, None<br>    for att in (msg.attachments or []):<br>        if att.query:<br>            sql = att.query.query<br>            res = w.genie.get_message_attachment_query_result(<br>                SPACE_ID, msg.conversation_id, msg.message_id, att.attachment_id)<br>            rows = res.statement_response.result.data_array if res.statement_response.result else []<br>        elif att.text:<br>            text = att.text.content<br>    return {&quot;sql&quot;: sql, &quot;text&quot;: text, &quot;rows&quot;: rows, &quot;conversation_id&quot;: msg.conversation_id}<br><br>findings = {k: ask(q) for k, q in QUESTIONS.items()}</pre><h3>Validate before you believe it</h3><p>This is the step that keeps the brief trustworthy. For each finding, check two things. First, that the SQL Genie wrote actually used the governed views. Second, for the questions where you can compute the answer deterministically, that the top item matches.</p><pre>def uses_governed_view(sql):<br>    return bool(sql) and &quot;main.finops.&quot; in sql<br><br>TRUSTED_TOP = {<br>  &quot;team_growth&quot;: &quot;SELECT team AS item FROM main.finops.team_spend_growth ORDER BY growth_usd DESC LIMIT 1&quot;,<br>  &quot;top_workload&quot;: &quot;SELECT CAST(workload_id AS STRING) AS item FROM main.finops.workload_cost_30d ORDER BY cost_30d_usd DESC LIMIT 1&quot;,<br>  &quot;sku_mix&quot;:      &quot;SELECT sku_name AS item FROM main.finops.sku_cost_30d ORDER BY cost_30d_usd DESC LIMIT 1&quot;,<br>  &quot;spikes&quot;:       &quot;SELECT CAST(resource_id AS STRING) AS item FROM main.finops.cost_spikes ORDER BY excess_usd DESC LIMIT 1&quot;,<br>}<br><br>for key, f in findings.items():<br>    f[&quot;governed&quot;] = uses_governed_view(f[&quot;sql&quot;])<br>    f[&quot;verified&quot;] = None<br>    if key in TRUSTED_TOP:<br>        top = spark.sql(TRUSTED_TOP[key]).first()<br>        f[&quot;verified&quot;] = bool(top) and str(top[&quot;item&quot;]) in json.dumps(f[&quot;rows&quot;] or [])<br>    f[&quot;send&quot;] = f[&quot;governed&quot;] and f[&quot;verified&quot;] is not False</pre><p>A finding that fails either check is flagged for a person and kept out of the brief.</p><h3>Draft the brief and log everything</h3><p>Use a chat model to turn the validated findings into a short brief. Give it the numbers and tell it to use only those.</p><pre>validated = {k: {&quot;rows&quot;: v[&quot;rows&quot;], &quot;text&quot;: v[&quot;text&quot;]} for k, v in findings.items() if v[&quot;send&quot;]}<br><br>prompt = (<br>  &quot;You are a FinOps analyst. Using ONLY the data below, write a brief of at most 8 bullet points. &quot;<br>  &quot;For each item: what it is, the number, and one suggested next step for a human to check. &quot;<br>  &quot;Do not invent figures. Label every suggestion as a lead to verify.\n\n&quot;<br>  + json.dumps(validated, default=str)<br>)<br>resp = w.serving_endpoints.query(<br>    name=LLM_ENDPOINT,<br>    messages=[ChatMessage(role=ChatMessageRole.USER, content=prompt)],<br>)<br>brief = resp.choices[0].message.content<br><br># Log every finding, including the ones that failed validation<br>log = [{<br>    &quot;run_id&quot;: RUN_ID, &quot;question_key&quot;: k, &quot;question&quot;: QUESTIONS[k],<br>    &quot;generated_sql&quot;: f[&quot;sql&quot;], &quot;rows_json&quot;: json.dumps(f[&quot;rows&quot;], default=str),<br>    &quot;governed&quot;: f[&quot;governed&quot;], &quot;verified&quot;: f[&quot;verified&quot;], &quot;sent&quot;: f[&quot;send&quot;],<br>    &quot;conversation_id&quot;: f[&quot;conversation_id&quot;],<br>} for k, f in findings.items()]<br>spark.createDataFrame(log).write.mode(&quot;append&quot;).saveAsTable(&quot;main.finops.agent_findings&quot;)</pre><p>Schedule it as a daily job in Lakeflow Jobs, and send brief to Slack or email with whichever integration you already use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I6cLo_PXIdRWtKCbSP7MSw.png" /></figure><h3>What the brief looks like</h3><p>Here is an example of what lands in Slack or email. Every name and figure is invented, and the spike and slow-task details are the kind of thing a real run might surface.</p><p><strong>Daily FinOps brief</strong> (illustrative example, all names and figures are invented)</p><ol><li><strong>Top SKUs, last 30 days.</strong> Jobs compute is 41% of list-price spend ($182k), all-purpose compute is 22% ($97k) and serverless SQL is 14% ($62k). All-purpose compute grew $18.7k (+24%) versus the prior 30 days. <em>Lead to verify:</em> check how much of it runs scheduled work that could move to jobs compute.</li><li><strong>Spike, job 8841.</strong> $1,240 yesterday against a $310 daily baseline (4.0x, $930 excess). <em>What to check (playbook):</em> compare the latest run with earlier ones for input volume, retries and cluster size.</li><li><strong>Spike, new pipeline </strong><strong>clickstream_bronze.</strong> No baseline, $420 yesterday. <em>What to check (playbook):</em> look for a full refresh or a backlog replay.</li><li><strong>Team growth.</strong> marketing-analytics is up from $23.3k to $37.5k (+$14.2k, +61%) month to date versus the same days last month. untagged spend is $9.8k so far this month. <em>Lead to verify:</em> ask the team&#39;s owner what changed, and chase the untagged spend to an owner.</li><li><strong>Most expensive workload, 30 days.</strong> Pipeline orders_silver at $23.4k. No spike on it yesterday, so this looks like steady cost, not a surprise.</li><li><strong>Oversized cluster candidate.</strong> Cluster 0412-… shows average CPU 9%, p95 CPU 31%, p95 memory 38% over 7 days, and cost $2.1k in that time. <em>What to check (playbook):</em> confirm the week included the busiest period, then lower the maximum workers or use a smaller node type.</li><li><strong>Slow task.</strong> Task merge_customers in job 5520 averages 52 minutes over the last 7 days against a 28-minute median (1.9x). This shows <em>what</em> slowed down, not <em>why</em>: check the query profile for skew or spill before changing compute.</li></ol><h3>Guardrails that keep it trustworthy</h3><ul><li><strong>Start in report-only mode.</strong> Run it for a couple of weeks and read the briefs before anyone acts on them. Look for wrong numbers and noisy findings.</li><li><strong>Compare against baselines, not absolutes.</strong> “This task is 3x its own median” is far more reliable than “this task is slow.”</li><li><strong>Keep recommendations as leads.</strong> The numbers come from SQL. The “what to do about it” comes from a language model. Label it that way in every brief.</li><li><strong>Cap the output.</strong> Send the top few items a day. A brief with forty findings gets ignored.</li><li><strong>Support exemptions.</strong> Let teams mark a workload as intentionally expensive, with a reason, so it doesn’t reappear daily. A tag such as finops_exempt is enough, as long as the views honor it.</li><li><strong>Respect data freshness.</strong> System tables are not real-time, so this is a daily review tool, not a cost circuit breaker. For hard limits, use budgets and policies.</li><li><strong>Keep the agent read-only.</strong> It analyzes and recommends. Changes to compute go through people, or through separate rule-based jobs with their own approvals.</li><li><strong>Watch your own bill.</strong> Log the cost of the daily run itself. It is a small test of whether your FinOps practice works.</li></ul><h3>The takeaway</h3><p>An AI FinOps analyst isn’t a chatbot pointed at a billing table. It is three layers working together. <strong>Governed views</strong> decide what cost means. A <strong>Genie Agent</strong> answers questions in those terms. A <strong>scheduled, validated job</strong> asks the questions every day so nobody has to remember to. Keep a person between the recommendation and the change, log everything, and let the findings that people keep acting on graduate into rule-based automation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31f0e41104a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Genie Ontology Explained: The Business Context Layer Behind Enterprise AI Agents]]></title>
            <link>https://medium.com/@prantikg/genie-ontology-explained-the-business-context-layer-behind-enterprise-ai-agents-63de51614fec?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/63de51614fec</guid>
            <category><![CDATA[databricks-genie]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[genie-ontology]]></category>
            <category><![CDATA[context-layer]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Tue, 06 Oct 2026 21:12:04 GMT</pubDate>
            <atom:updated>2026-10-09T16:29:42.508Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Overview:</strong></p><p>Ask three analysts for “net sales” and you can get three different numbers. An AI agent has the same problem, only faster and with more confidence. Genie Ontology is Databricks’ answer: a continuously updated graph of your business terms, metric definitions and relationships, ranked by trust and filtered by permissions, that every Genie surface reads before it answers. This post breaks the ontology into its components, explains each one with a retail example, and then follows a single question through Genie One from Slack to action.</p><p><strong>What you’ll learn:</strong></p><ul><li>Why agents without business context give plausible but wrong answers, and what an ontology adds</li><li>The components of Genie Ontology: sources, business terms, metric definitions, entity relationships, OntoRank and permissions</li><li>How each component looks in a retail setting, with diagrams and working SQL</li><li>How the ontology differs from a semantic layer and from RAG</li><li>An end-to-end enterprise example: one question in Genie One, resolved, analyzed, answered and acted on</li><li>What to prepare in your own Databricks estate, and where the limits are</li></ul><p><strong>The problem: same word, different number</strong></p><p>Picture a retailer with a perfectly healthy lakehouse. Finance calculates net sales as gross sales minus returns minus discounts. A merchandising analyst wrote a query a year ago that ignores discounts. Someone on the e-commerce team wrote in the wiki that gift cards are excluded. All three are “right” inside their own context, and all three are sitting in the same estate.</p><p>A human analyst resolves this by asking around. An agent can’t. It will pick one, run the SQL, and hand back a clean-looking number. The SQL can be flawless and the answer still wrong, because the mistake happened one step earlier, at the point where a business word turned into a definition.</p><p>That gap is what an ontology is for. In data architecture terms, an ontology is a structured description of the things your business talks about, how they relate, and what the key words mean. Traditionally, someone had to write one by hand and keep it current, which is why most never got finished.</p><p><strong>What Genie Ontology is</strong></p><p>Genie Ontology is a context layer that Databricks builds and maintains automatically. It reads what your organization already produces, pulls out knowledge snippets (what a term means, how a metric is calculated, which tables relate), connects them into a graph, and ranks competing definitions by how much they should be trusted. Genie One, Genie Agents, Genie Code and external assistants connected through Genie One MCP all draw on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8QEOg29tD49krFuVZamT6Q.png" /></figure><p>Read the diagram left to right: sources go in, the ontology organizes and ranks them inside a permission boundary, and every Genie surface reads from the result. The rest of this post walks through each box using a retail business as the running example.</p><p><strong>Component 1: Sources, authored and inferred</strong></p><p>The ontology learns from two kinds of input.</p><p><strong>The authored layer</strong> is what your team deliberately curates: metric views, glossary terms, domains, and certified assets (like gold schema). This is the high-trust material. If you’ve read my earlier post on certifying a data model with View relationships (<a href="https://medium.com/@prantikg/how-to-certify-your-data-model-on-databricks-using-view-relationships-9a87976b90a1">See here</a>), this is where that work pays off: a certified, well-related model is exactly the kind of source the ontology leans on.</p><p><strong>The inferred layer</strong> is everything the platform can learn without being told: tables and query history, dashboards, pipelines, and connected business apps such as chat, wikis and document stores. Databricks describes this as covering a wide range of external applications, though exactly which connectors you have depends on your setup.</p><p><em>Retail example:</em> the certified finance metric view for net sales is authored. The merchandising analyst’s old query, the promo calendar page in the wiki, and a supplier-delay thread in chat are inferred. All of them feed the graph, but they do not carry equal weight.</p><p><strong>Component 2: Business terms</strong></p><p>Business terms are the vocabulary people actually use, mapped to something the data can answer. “Outerwear” is not a column. It is a group of product categories. “Comp store” means a store open long enough to compare year over year. “Active customer” means someone who bought within a window.</p><p>Without this layer, an agent guesses at what a word means by pattern-matching on column names. With it, the word resolves to a specific definition.</p><p><em>Retail example:</em> when a regional lead types “outerwear,” the ontology resolves it to the product category group your merchandising hierarchy defines, rather than every table with “outer” in a column name.</p><p><strong>Component 3: Metric definitions</strong></p><p>A metric definition is how a number is calculated, not just what it is called. This is the component most likely to rescue you from the “three analysts, three numbers” problem, because it records the formula and the source it came from.</p><p>The most reliable way to feed this component is a governed metric view. Here is a small retail example:</p><pre>CREATE OR REPLACE VIEW main.retail.sales_metrics<br>WITH METRICS<br>LANGUAGE YAML<br>AS $$<br>  version: 1.1<br>  comment: &quot;Certified retail sales KPIs owned by Finance&quot;<br>  source: main.retail.fact_sales<br><br>  joins:<br>    - name: store<br>      source: main.retail.dim_store<br>      &#39;on&#39;: source.store_id = store.store_id<br><br>  dimensions:<br>    - name: region<br>      expr: store.region<br>    - name: week<br>      expr: DATE_TRUNC(&#39;WEEK&#39;, source.sale_date)<br><br>  measures:<br>    - name: net_sales<br>      expr: SUM(source.gross_amount - source.return_amount - source.discount_amount)<br>      comment: &quot;Gross minus returns minus discounts. Excludes gift card sales.&quot;<br>$$;</pre><p>Then certify it, using <strong>Assign certification</strong> in Catalog Explorer as described in my earlier post, so the ontology gets a strong signal about which definition is official.</p><p>Metric view YAML evolves between versions, so confirm the current specification in the Databricks docs before copying this into production.</p><p><strong>Component 4: Entity relationships</strong></p><p>Entities are the nouns of the business: store, customer, product, promotion, supplier. Relationships say how they connect. This is what lets an agent join tables correctly without guessing, and what lets it answer a question that crosses several of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*FR4DpKzmxeaPZ21Pbuysxw.png" /></figure><p>The graph above is a simplified retail model. A “sale” connects to the store it happened in, the customer who bought, the promotion that applied, and the product sold. A store is part of a region, and a customer belongs to a loyalty tier.</p><p><em>Retail example:</em> “Why did outerwear drop in the Northeast?” touches product, region and promotion at once. The relationships tell the agent which joins are legitimate, so it doesn’t invent one.</p><p>Declared primary and foreign keys in Unity Catalog are one of the cleanest ways to make relationships explicit. They are informational rather than enforced, which is why reviewing them in the ERD before you certify matters.</p><p><strong>Component 5: OntoRank, the tiebreaker</strong></p><p><strong>What is OntoRank?</strong> It is the scoring step that decides which definition Genie should trust when your estate contains more than one for the same term. If you know PageRank, the idea is familiar: a web page ranks higher when credible pages point to it. OntoRank applies that logic to definitions. A definition ranks higher when credible people wrote it, many queries and dashboards depend on it, it is tied to certified assets, and it is recent.</p><p><strong>Why it matters in practice:</strong> it turns “which net sales formula should the agent use?” from a coin flip into a ranked decision, and it makes that decision repeatable across Genie One, Genie Agents, Genie Code and MCP-connected assistants. It also tells you where to act. You can’t edit the score directly, but you can influence it: certify the metric view you want trusted, give it a clear owner, connect it to governed datasets, and retire stale queries that compete with it.</p><p>When several definitions compete for the same term, something has to pick. Databricks calls this ranking OntoRank. The documented signals are:</p><ol><li><strong>Creator authority</strong> — who wrote it, and in what role</li><li><strong>Usage breadth</strong> — how many queries and dashboards depend on it</li><li><strong>Certified Asset </strong>— how tightly it connects to certified, governed assets</li><li><strong>Recency</strong> — how fresh it is</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*epjFmQq6YYucfEr3bx2K8A.png" /></figure><p>In the diagram, the certified finance metric view wins on all four signals. The old query and the wiki note remain in the graph as lower-ranked context. They are not silently chosen.</p><p><strong>Component 6: Permissions</strong></p><p>None of this works in an enterprise if the ontology leaks. Databricks states that permissions are enforced on every answer, through Unity Catalog or the permissions of the original source, so a user only sees context they are entitled to see.</p><p>In practice this means the same question from two people can yield different, correctly scoped answers. A row filter is the classic way to express it:</p><pre>CREATE OR REPLACE FUNCTION main.governance.region_filter(region STRING)<br>RETURN is_account_group_member(&#39;retail-admins&#39;)<br>    OR (region = &#39;Northeast&#39; AND is_account_group_member(&#39;merch-northeast&#39;))<br>    OR (region = &#39;Midwest&#39;   AND is_account_group_member(&#39;merch-midwest&#39;));<br><br>ALTER TABLE main.retail.fact_sales<br>SET ROW FILTER main.governance.region_filter ON (region);</pre><p><em>Retail example:</em> a Northeast merchandising lead and a national VP both ask about outerwear. The lead’s answer covers her region only; the VP’s covers all of them. Neither needed a custom prompt.</p><p><strong>A living layer, not a one-time build</strong></p><p>One property cuts across all six components: Genie Ontology is a dynamic system. It updates itself as new context appears, rather than waiting for someone to republish a glossary.</p><p>That matters because the things it describes never stand still. Business metrics get redefined, team structures change, and reporting dashboards are built, replaced and retired every quarter. A context layer that someone must refresh by hand starts going stale the day it ships, and an agent reading stale context fails the same way an agent with no context does, just less visibly.</p><p><strong>Where it fits in the enterprise AI stack</strong></p><p>It helps to see the ontology as one layer in a stack, not as a standalone product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*QLoR64l5utsrOGkOjefkjg.png" /></figure><p>Reading from the bottom: the lakehouse holds the raw operational data, transformation turns it into usable models, and governance decides who may see and do what. The semantic layer sits above that and holds your official business definitions, such as a certified net sales metric view. The context layer is the one this post is about: it reads from everything beneath it and gives agents the meaning they need before they act.</p><p>The practical lesson is that agents sit at the top and inherit every weakness below them. A brilliant agent over a messy model, loose permissions or conflicting definitions will still give you a confident wrong answer. That is why the preparation checklist later in this post is mostly about the lower layers, not about the agent.</p><p><strong>The end-to-end example: one question in Genie One</strong></p><p>Here is how the pieces work together for a fictional retailer. The flow below is illustrative: it shows how the capabilities fit together.</p><p>A regional merchandising lead is in Slack, where Genie One is available. She asks: <em>“Why did outerwear comp sales drop in the Northeast last week, and what should we do?”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5O_eTATfHRSAsGU1h_es9g.png" /></figure><ol><li><strong>User request.</strong> A regional merchandising lead types a question in plain language, in Genie One or in Slack: <em>“Why did outerwear comp sales drop in the Northeast last week, and what should we do?”</em> No SQL, no table names, no metric definitions.</li><li><strong>Genie One, the front door.</strong> The question lands in Genie One. It might be in the web chat, in Slack or Teams, on the mobile app or the desktop app, or in an external assistant connected through Genie One MCP. The surface doesn’t change the outcome, because every one of them uses the same context and the same permissions.</li><li><strong>Genie Ontology supplies the meaning.</strong> Before and while the agents work, they lean on the same context layer. “Comp sales” maps to the certified finance metric view because it won the OntoRank contest. “Outerwear” maps to a product category group, and “Northeast” to a region. Inside the ontology, OntoRank weighs creator authority, usage breadth, certified asset linkage and recency to pick the winning definition when several compete. This is what stops the agents from quietly picking the wrong definition of a metric.</li><li><strong>Permission check, as this user.</strong> Her access is applied to everything that follows. Unity Catalog privileges, row filters and column masks are evaluated as her, and connected apps apply their own source permissions, so no agent can touch data she is not entitled to see. A national VP asking the same question would get a wider answer from the same flow.</li><li><strong>Genie Agents work in parallel.</strong> Rather than one agent doing everything, the question fans out to focused workers, each doing one job:</li></ol><ul><li><strong>Sales agent:</strong> runs SQL against the certified net sales metric view, sliced by region, week and product line.</li><li><strong>Product agent:</strong> looks at category mix, stock levels and sell-through for the outerwear lines.</li><li><strong>External sources:</strong> tool connectors (MCP) read the supplier-delay thread in chat and the promo calendar in the wiki, each limited by her own access. These calls pass through Unity AI Gateway, which is where service policies and spend caps apply. My earlier post on Unity AI Gateway covers that layer in detail.</li><li><strong>Documents:</strong> vector search over unstructured material such as vendor notes, policies and past promotion reviews, for the context that never lived in a table.</li></ul><p>6. <strong>Analyze and aggregate data.</strong> The results from every agent are combined into one picture. In this example, the drop is concentrated in two product lines, and it traces back to two causes at once: stock-outs in the affected stores, and a promotion that never ran because of the supplier delay.</p><p>7. <strong>Generate results.</strong> Genie returns something she can use and check:</p><ul><li><strong>Insights:</strong> what happened and why, in business language.</li><li><strong>Visualization:</strong> the trend and the store-level breakdown.</li><li><strong>Summary:</strong> a short brief she can forward to her team.</li><li><strong>Sources:</strong> links back to every table, document and thread behind the numbers, so nothing has to be taken on trust.</li></ul><p>The division of labor is worth remembering: <strong>the ontology supplies meaning, Unity Catalog supplies permissions, and Unity AI Gateway supplies runtime control.</strong> Remove any one and the story gets worse. Without the ontology the answer is wrong. Without permissions it is unsafe. Without runtime control the action is unaccountable.</p><p>The same ontology is also available outside Genie One. Genie One MCP lets an external assistant ask business questions against Genie’s governed context, passing the end user’s identity so Unity Catalog privileges, row filters and column masks still apply. A finance leader can ask an assistant they already use about forecast-to-actual gaps and get an answer built on your definitions.</p><p><strong>What to prepare in your own data platform</strong></p><p>The ontology reads what you already have, so the quality of its output is bounded by the quality of your asset. If I were starting a retail rollout, I would do this in order:</p><ul><li><strong>Agree on the contested terms first.</strong> Get Finance and Merchandising to settle “net sales” and “active customer” before any tool ranks them.</li><li><strong>Model dimensionally with a clear grain</strong>, and declare primary and foreign keys so relationships are explicit.</li><li><strong>Author metric views for the KPIs that matter</strong> and certify them.</li><li><strong>Retire dead assets.</strong> Abandoned queries and stale dashboards are noise that competes with your good definitions.</li><li><strong>Name owners for the glossary and domains</strong>, and give them a review cycle.</li><li><strong>Build a test set of real questions</strong> with known answers, so you can see whether answers get better or worse as the ontology learns.</li></ul><p><strong>The takeaway</strong></p><p>Most “AI got the number wrong” incidents are definition problems wearing a technical disguise. Genie Ontology doesn’t remove the need for good data modeling or for people to agree on what their metrics mean. What it does is make that work count: the glossary you curate, the metric views you certify and the relationships you declare become the context every agent uses, under the permissions you already enforce. Invest in the sources, and the layer built on top of them gets smarter. Neglect them, and you have simply automated your inconsistencies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63de51614fec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks AI Platform Architecture: Making Sense of It All at Once]]></title>
            <link>https://medium.com/@prantikg/databricks-ai-platform-architecture-making-sense-of-it-all-at-once-2c09b58ed215?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c09b58ed215</guid>
            <category><![CDATA[databricks-ai]]></category>
            <category><![CDATA[agent-bricks]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai-architecture]]></category>
            <category><![CDATA[databricks-model-serving]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Mon, 28 Sep 2026 22:01:56 GMT</pubDate>
            <atom:updated>2026-09-28T22:01:56.490Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How AI Playground, Agent Bricks, Mosaic AI, Unity Gateway, MCP servers, skills and Unity Catalog fit together, in one picture.</em></p><h3>Overview</h3><p>If you have worked on Databricks over the last year, you have probably felt it too. Every few weeks there is a new AI feature, a renamed product, or a new “preview” toggle in the admin console. AI Playground, Agent Bricks, Mosaic AI Agent Framework, Model Serving, Unity Gateway, managed MCP servers, skills, AI Search. Each one makes sense when you read its own documentation page. The trouble starts when you try to explain how they all connect.</p><p>That was exactly my problem. A client would ask a simple question, such as “where do our agents actually call the model?” or “who controls which tools an agent can use?”, and I would find myself jumping between five tabs of docs to answer it. Each page explains its own feature well, but none of them shows the whole picture.</p><p>So I sat down and tried to put everything on one page. This post is the result: a single architecture diagram of the Databricks AI platform, and a plain-language walk through each piece. It is not a replacement for the official docs. It is the map I wish I had before reading them.</p><h3>What you will learn</h3><p>By the end of this post you should be able to:</p><p>• Explain the Databricks AI platform as four layers: <strong>Build</strong>, <strong>Unity Gateway</strong>, <strong>Models</strong> and <strong>Unity Catalog</strong>.</p><p>• Tell the difference between AI Playground, Agent Bricks and Mosaic AI, and know which one to reach for.</p><p>• Understand why Unity Gateway sits in the middle of everything, governing both model calls and tool calls.</p><p>• Know where serving endpoints, MCP servers and skills live, and how an agent uses them.</p><p>• See the three kinds of models you can use (Databricks-hosted, your own, and external providers) and why they all look the same to an agent.</p><p>• Understand why Unity Catalog is the foundation that makes all of this governable.</p><p>• Follow a single agent request from the user’s question all the way to the answer.</p><h3>The big picture: four layers</h3><p>Everything in this post hangs off one diagram. I built it to answer a single question: where does each new Databricks AI feature actually sit, and what does it talk to? Here it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*UeI2klkuGRRoBfz402biNw.png" /></figure><p><em>The Databricks AI platform as four numbered layers. The rest of this post walks through them from top to bottom.</em></p><p>The trick that made it work for me was to stop thinking in product names and start thinking in layers. Every AI feature Databricks has shipped fits into one of the four numbered rows:</p><p>1. <strong>01 Build</strong> (the three white cards at the top): where you create agents and AI apps. The line above them runs from no-code to pro-code, and AI Playground, Agent Bricks and Mosaic AI sit along it.</p><p>2. <strong>02 Govern &amp; Serve</strong> (the large orange block): Unity Gateway. The strip of controls along its top applies to everything inside it. Below that, the dark band holds the model serving endpoints, and the lower row holds the tool services: MCP servers and skills.</p><p>3. <strong>03 Models</strong> (the three cards below the gateway): the models doing the thinking, whether hosted by Databricks, built by you, or called from an external provider.</p><p>4. <strong>04 Foundation</strong> (the green band at the bottom): Unity Catalog, which governs every layer above it.</p><p>Read it from top to bottom. You build something in row 01, it calls models and tools through the gateway in row 02, the gateway routes model calls to row 03, and Unity Catalog in row 04 decides who is allowed to do what at every step. You may want to keep the diagram open beside you: each section below zooms into one numbered row.</p><h3>Layer 1: Build</h3><p><em>In the diagram: row 01, the three white cards across the top.</em></p><p>The top layer is where people actually create things. Databricks gives you three different ways in, and the easiest way to tell them apart is by how much code you want to write: no-code, low-code or pro-code. They are not competitors. Most teams end up using all three at different stages of a project.</p><h3>AI Playground: try things before you commit</h3><p>AI Playground is the chat window inside your workspace. You pick a model, type a prompt and see what comes back. You can put two or three models side by side and compare their answers to the same question, which is often the fastest way to settle an argument about which model to use.</p><p>It is also where you can sketch a simple agent. Give a model a couple of tools, such as a Unity Catalog function, and watch it decide when to call them. When the prototype looks promising, you can export it to code and carry on in a notebook.</p><p>Think of Playground as a whiteboard. Analysts, business users and architects use it to answer “is this even possible?” before anyone writes a line of code.</p><h3>Agent Bricks: production agents without the plumbing</h3><p>Agent Bricks is for when you know what you want the agent to do, but you do not want to hand-build the retrieval pipeline, the evaluation set and the tuning loop yourself. You describe the task, point it at your data, and Agent Bricks assembles the agent for you.</p><p>It is built around common business patterns: a knowledge assistant that answers questions from your documents, information extraction from unstructured files, and a multi-agent supervisor that coordinates several specialist agents. Behind the scenes it generates evaluations, measures quality and helps you tune for quality against cost.</p><p>The people who get the most out of Agent Bricks are domain experts. They know what a good answer looks like, even if they would never write a LangGraph state machine.</p><h3>Mosaic AI: the full developer toolkit</h3><p>Mosaic AI is the pro-code layer, and honestly the one I spend most of my time in. It is less a single product and more a toolbox for engineers who need full control.</p><p>• <strong>Agent Framework</strong> lets you write agents in the framework you already know, such as LangGraph or plain Python, and deploy them the Databricks way.</p><p>• <strong>AI Search</strong> (the new name for Vector Search) gives your agents retrieval over your own documents and tables.</p><p>• <strong>MLflow</strong> handles tracing, evaluation and observability, so you can see every step an agent took and why.</p><p>• <strong>AutoML and fine-tuning</strong> cover the classical ML and model customization side.</p><p>If Playground is the whiteboard and Agent Bricks is the assembly line, Mosaic AI is the workshop: slower to start, but nothing is off limits.</p><p>Whatever you build in this layer, the next step is the same. Your agent needs to call a model and some tools. That is where the gateway comes in.</p><h3>Layer 2: Govern &amp; Serve with Unity Gateway</h3><p><em>In the diagram: row 02, the large orange Unity Gateway block with its control strip, serving endpoints and tool services.</em></p><p>This is the layer that finally made the whole picture click for me. Unity Gateway is a single control plane that sits between everything you build and everything your agents call. Every model call and every tool call goes through it.</p><p>Why does that matter? Without a gateway, every team wires its agents directly to models and APIs. Each team handles keys, limits and logging its own way, and nobody can answer “how much did we spend on LLMs last month, and who spent it?” With a gateway, those answers live in one place.</p><p>I wrote a dedicated deep dive on this, including how it tracks AI spend and agent activity: <a href="https://medium.com/@prantikg/unity-ai-gateway-the-new-governance-backbone-for-ai-spend-and-agent-activity-e33f9d976cc1">Unity AI Gateway: The New Governance Backbone for AI Spend and Agent Activity</a>. Here I will keep to how it fits into the overall architecture.</p><h3>What the gateway controls</h3><p>The same set of controls applies to everything behind the gateway, whether it is a model or a tool:</p><p>• <strong>Access control</strong>: who can call what, granted with Unity Catalog privileges, just like tables.</p><p>• <strong>Traffic management</strong>: rate limits, traffic splits for A/B testing, failover to a backup model, and smart routing.</p><p>• <strong>Guardrails</strong>: policies that check requests and responses, for example for PII or unsafe content.</p><p>• <strong>Budgets and cost tracking</strong>: spend broken down by user, team or project.</p><p>• <strong>Usage and audit logs</strong>: every call recorded to Delta tables you can query like any other data.</p><p>Behind those controls sit two kinds of services: model services and tool services.</p><h3>Model services: serving endpoints</h3><p>Earlier diagrams, including my own first attempt, drew Model Serving as a separate box below the gateway. It is more accurate to think of serving endpoints as sitting <em>behind</em> the gateway. An endpoint is simply the address an agent calls to reach a model. There are three flavours:</p><p>• <strong>Foundation Model APIs</strong>: Databricks-hosted models, either pay-per-token or with provisioned throughput for predictable performance.</p><p>• <strong>Custom model and agent endpoints</strong>: your own MLflow models, and the agents you deploy, served as endpoints too.</p><p>• <strong>External model endpoints</strong>: a proxy to a third-party provider, so an agent can call Azure OpenAI or Bedrock through the same governed path.</p><p>The nice part is that all of them speak the same OpenAI-compatible API. Your agent code does not care which kind it is calling.</p><h3>Tool services: MCP servers and skills</h3><p>A model on its own can only talk. To be useful, an agent needs to <em>do</em> things: look up data, search documents, call an API. That is what tools are for, and on Databricks, tools are increasingly delivered through MCP, the Model Context Protocol.</p><p><strong>Managed MCP servers</strong> are hosted by Databricks and need no setup. There are four ready to use:</p><p>• <strong>Genie</strong>: ask questions of structured data in plain English, using the business definitions already set up in a Genie space.</p><p>• <strong>AI Search</strong>: search your vector indexes for relevant documents.</p><p>• <strong>Databricks SQL</strong>: run SQL against Unity Catalog tables.</p><p>• <strong>Unity Catalog functions</strong>: call your own Python or SQL functions as tools.</p><p><strong>External and custom MCP servers</strong> cover everything outside Databricks. An external MCP server connects through a Unity Catalog connection to services such as Slack, Jira or GitHub. A custom MCP server is your own tool code, deployed as a Databricks App. Either way, the gateway governs it like any other service.</p><p><strong>Skills</strong> are the newest piece, and still in Beta. A skill is a set of instructions, written as a SKILL.md file, that teaches an agent how to do one task well. Think of a runbook, your team’s SQL conventions, or how to analyse a particular table. On Databricks, a skill is a Unity Catalog object in its own right, so you share and secure it exactly like a table. Agents can load skills live over MCP.</p><p>The way I explain it to clients: <strong>tools give an agent hands, skills give it know-how, and the gateway decides what it is allowed to touch.</strong></p><h3>Layer 3: Models</h3><p><em>In the diagram: row 03, the three model cards below the gateway.</em></p><p>At the bottom of the request path are the models themselves. Databricks does not ask you to pick one family. You can mix three kinds, and because they all sit behind the same serving endpoints and the same gateway, your agent treats them the same way.</p><h3>Databricks-hosted models</h3><p>These are frontier and open models that Databricks runs for you, such as Claude, GPT, Gemini, Llama, Qwen and others. The key point is that they run inside the Databricks security perimeter, so your prompts and data do not leave the platform to reach a separate vendor account. For regulated industries that is often the deciding factor.</p><p>One practical warning: which models are available depends on your cloud and region. Always check the list in your own workspace before you promise a specific model to anyone.</p><h3>Custom and fine-tuned models</h3><p>This is everything you build or adapt yourself: a fine-tuned LLM, an embedding model, a classic ML model for churn or demand forecasting, or even a whole agent packaged as a model. You log it with MLflow, register it in Unity Catalog, and serve it on an endpoint. From that moment it is governed exactly like the hosted models.</p><h3>External providers</h3><p>Sometimes a model you need only lives with another provider, or your organisation already has an enterprise agreement with one. External model endpoints let you call providers such as Azure OpenAI, OpenAI, Anthropic, Google or Amazon Bedrock using your own API keys, while the gateway still applies the same limits, guardrails and logging.</p><p>This is what I like most about the design. Swapping a model becomes a configuration change on an endpoint, not a rewrite of your agent.</p><h3>Layer 4: Unity Catalog, the foundation</h3><p><em>In the diagram: row 04, the green Unity Catalog band along the bottom.</em></p><p>If you remember one thing from this post, make it this: <strong>on Databricks, AI governance is data governance.</strong> Unity Catalog started as the place to govern tables. Today it governs almost every AI object too: vector indexes, models, endpoints, functions, agent tools and now skills. The same permission model that stops an analyst reading a salary table also stops an agent calling a tool it should not use.</p><p>Here is what Unity Catalog does for the AI platform:</p><p>• <strong>Access control and permissions</strong>: one GRANT model for data, models, functions and skills.</p><p>• <strong>Row and column-level security</strong>: when an agent queries data through Genie or SQL, it only sees what the calling user is allowed to see.</p><p>• <strong>End-to-end lineage</strong>: trace an answer back through the model, the tool, the table and the source data.</p><p>• <strong>Audit logging</strong>: a record of who, or which agent, accessed what and when.</p><p>• <strong>Discovery, tags and classification</strong>: find existing assets and label sensitive ones before they end up in a prompt.</p><p>• <strong>A registry for models, functions and skills</strong>: one place to find, version and share what your teams have built.</p><p>This is why I put Unity Catalog at the bottom of the diagram rather than to the side. It is not an extra feature you add later. Every layer above depends on it, and if your Unity Catalog setup is messy, your agents will inherit the mess.</p><h3>How it all works together: one request, end to end</h3><p>Layers are easier to remember with a story, so here is one. Imagine a sales operations team has a support agent built with Mosaic AI Agent Framework. A user asks it: <em>“Why did returns spike in the Northeast last quarter, and what does our returns policy say about it?”</em></p><p>1. <strong>The agent receives the question.</strong> It was built in the Build layer, perhaps prototyped in AI Playground first, and is now deployed as an agent endpoint.</p><p>2. <strong>It asks a model to plan.</strong> The call goes through Unity Gateway to a serving endpoint. The gateway checks the agent is allowed to use that model, applies rate limits and guardrails, and logs the call.</p><p>3. <strong>The model decides it needs data.</strong> The agent calls the Genie MCP server, again through the gateway. Genie turns the question into SQL using the business definitions in its space.</p><p>4. <strong>Unity Catalog enforces access.</strong> The query runs with the user’s permissions, so row filters and column masks apply. If this user cannot see a region’s data, neither can the agent.</p><p>5. <strong>The model decides it needs the policy.</strong> The agent calls the AI Search MCP server to find the relevant section of the returns policy document.</p><p>6. <strong>A skill shapes the answer.</strong> If the team has published a skill for how to write returns analysis, the agent loads it and follows those instructions.</p><p>7. <strong>The model writes the final answer</strong>, again through the gateway.</p><p>8. <strong>Everything is recorded.</strong> Each model and tool call lands in the gateway’s usage tables, with cost attributed to the team. MLflow traces show every step, and Unity Catalog lineage links the answer back to the tables it used.</p><p>Notice that the user asked one question, but the request crossed every layer in the diagram, several times. That is the real reason the platform feels complicated. It is not that each feature is hard. It is that a single agent request touches all of them.</p><h3>Wrapping up</h3><p>Databricks has shipped a lot of AI capability in a short time, and it is easy to feel you are always one release behind. What helped me was stepping back and seeing that it all fits into four layers:</p><p>• <strong>Build</strong> it with Playground, Agent Bricks or Mosaic AI, depending on how much code you want to write.</p><p>• <strong>Govern and serve</strong> it through Unity Gateway, where models, MCP tools and skills all sit behind one set of controls.</p><p>• <strong>Power</strong> it with any mix of hosted, custom or external models.</p><p>• <strong>Ground</strong> all of it in Unity Catalog.</p><p>When the next new feature arrives, and it will, try placing it on this map first. In my experience, once you know which layer something belongs to, the documentation suddenly becomes much easier to read.</p><p>If this helped, follow me for more posts on Databricks and data and AI architecture. And if you see something I have placed in the wrong layer, tell me in the comments; this map is a work in progress, just like the platform.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c09b58ed215" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity AI Gateway: the New Governance Backbone for AI Spend and Agent Activity]]></title>
            <link>https://medium.com/@prantikg/unity-ai-gateway-the-new-governance-backbone-for-ai-spend-and-agent-activity-e33f9d976cc1?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e33f9d976cc1</guid>
            <category><![CDATA[ai-cost-management]]></category>
            <category><![CDATA[unity-ai-gateway]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[ai-governance]]></category>
            <category><![CDATA[llm-guardrails]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 01:02:17 GMT</pubDate>
            <atom:updated>2026-09-27T01:02:35.486Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Overview</strong></p><p>Unity Catalog governs what your data and AI assets <em>are</em> — who owns a table, who can query a model. Unity AI Gateway, which went GA on Databricks in August 2026, governs what they <em>do</em> at runtime — what an agent is allowed to call, what it’s allowed to spend, and what happens when a request or response crosses a line. This post walks through what Unity AI Gateway actually covers: service policies (guardrails), cost controls and hard spend caps, unified observability, and how it all sits on top of Unity Catalog rather than beside it.</p><p><strong>What you’ll learn:</strong></p><ul><li>Why agent governance is a genuinely different problem from data governance — and why access control alone doesn’t cover it</li><li>What Unity AI Gateway governs: models, model providers, MCPs, skills, and agents, all as Unity Catalog securables</li><li>How each of those five is actually registered and governed — with the specific privileges and grant syntax for each</li><li>How service policies work — SQL-based guardrails evaluated on every request and response, with a working code example</li><li>How cost governance works: spend attribution, hard caps, and Smart Routing (still in Beta)</li><li>What’s GA today versus still rolling out, so you know what to actually rely on</li></ul><p><strong>Why “who can access it” stopped being enough</strong></p><p>Unity Catalog has always answered a specific question well: who is allowed to see or use this data or model. That’s access control, and it works because the actor asking the question — a person, a service principal — is either permitted or it isn’t. One decision, made once, at the door.</p><p>Agents break that model in a specific way: an agent doesn’t just <em>access</em> things, it <em>acts</em> through them. It calls a model, invokes a tool, reads a file, maybe writes to one, often chaining several of those together in a single turn on a user’s behalf. Standard access control still answers “can this agent reach the GitHub MCP server at all” — but it has nothing to say about “should this specific agent, acting for this specific user, be allowed to push to this specific repo without a human confirming it first.” That’s a runtime question about the content and context of an interaction, not a static grant, and it’s exactly the gap Unity AI Gateway was built to close.</p><p><strong>What Unity AI Gateway actually is</strong></p><p>Unity AI Gateway (also referred to as Unity Gateway) is Databricks’ runtime governance layer for enterprise AI, built directly as an extension of Unity Catalog rather than as a bolt-on product. It reached general availability in August 2026, after entering the market roughly two years earlier under a narrower scope. The core idea: models, MCP services, agents, and skills are registered as Unity Catalog securable objects — the same way tables and volumes already are — and Unity AI Gateway is the control plane that intercepts every interaction with them and enforces policy in real time.</p><p>That gives it two distinct jobs, which map onto two distinct problems teams run into once agents are actually in production:</p><ol><li><strong>Content and action governance</strong> — service policies (guardrails) that decide whether a specific request or response should proceed, based on what it contains and who’s making the call.</li><li><strong>Cost governance</strong> — visibility into what’s actually being spent across every model and provider, plus the ability to cap it before a runaway agent turns into a surprise invoice.</li></ol><p><strong>Governing Models</strong></p><p>A <strong>model service</strong> is a Unity Catalog securable object representing a governed LLM endpoint — the thing an agent or application actually calls to get a completion. Databricks-hosted foundation models come ready to use as system-provided model services in the system.ai schema (for example, system.ai.databricks-claude-opus-5), queryable by every account user with no setup. To govern additional models — a custom fine-tuned model, or a specific configuration of an external model — you create your own model service, and it’s discoverable in Catalog Explorer and governed with ordinary Unity Catalog grants, exactly like a table:</p><pre>- Grant a team the ability to call a model service<br>GRANT EXECUTE ON MODEL_SERVICE main.ml.support_summarizer TO `data-team`;</pre><p>Because a model service lives in Unity Catalog rather than being scoped to one workspace, you define it once and reuse it from any workspace attached to the same metastore, with usage and cost tracked centrally in system tables rather than per-workspace. The same object also appears in the Unity AI Gateway UI, where you attach rate limits, inference tables, and guardrails on top of the access grant.</p><p>One gap worth calling out explicitly, because it’s easy to assume otherwise: a custom endpoint you create on the classic <strong>Serving Endpoints</strong> page — a custom MLflow model, an external-model endpoint, or a provisioned-throughput endpoint — is <strong>not</strong> automatically brought under Unity AI Gateway governance just because it exists. Serving Endpoints predates the Gateway and still operates as its own object; governance has to be switched on deliberately, either from the <strong>AI Gateway</strong> section of that endpoint’s creation/edit screen, or via the REST API (PUT /api/2.0/serving-endpoints/{name}/ai-gateway). Until you do that, the endpoint is reachable and callable, but none of the guardrails, rate limits, inference-table logging, or cost attribution described in this post apply to it — it’s simply running ungoverned, invisibly, right alongside endpoints that are. If you’re auditing what’s actually covered, checking every entry on the Serving Endpoints page for whether AI Gateway has been explicitly enabled is a step worth doing before you assume coverage is complete.</p><p><strong>Governing Model Providers</strong></p><p>A <strong>model provider service</strong> is a distinct, lower-level securable from a model service — it holds the actual connection to an external vendor: the provider type (OpenAI, Anthropic, Amazon Bedrock, a custom OpenAI-compatible endpoint), the base URL, and the encrypted API key, which Databricks stores but never returns on read. A model service can route to a model provider service, but the provider connection itself is governed and reusable independently — so the credential lives in exactly one governed place, rather than being copied into every model service or agent that needs to reach that vendor.</p><p>Creating one is a CLI/API operation rather than SQL DDL:</p><pre>databricks ai-gateway create-model-provider-service schemas/main.default openai_prod - json &#39;{<br>  &quot;comment&quot;: &quot;Shared OpenAI connection for the platform team&quot;,<br>  &quot;config&quot;: {<br>    &quot;provider_type&quot;: &quot;EXTERNAL_MODEL_PROVIDER_TYPE_OPENAI&quot;,<br>    &quot;openai&quot;: { &quot;api_key&quot;: { &quot;plaintext&quot;: &quot;sk-…&quot; } }<br>  }<br>}&#39;</pre><p>Access is then granted the same way as any other securable:</p><pre>GRANT EXECUTE ON MODEL_PROVIDER_SERVICE main.default.openai_prod TO `data-team`;</pre><p>Four privileges apply: CREATE SERVICE (who can register new provider connections in a schema), EXECUTE (who can actually route requests through it), READ METADATA (who can see its configuration without querying), and MANAGE (who can edit, delete, or change access on it). EXECUTE also requires USE CATALOG and USE SCHEMA on the provider’s parents — the same pattern every securable in this post follows.</p><p><strong>Governing MCPs</strong></p><p>MCP servers — whether Databricks-managed (Genie, Unity Catalog functions), external (a third-party MCP server you connect to), or custom (one you host yourself on Databricks Apps) — are registered as Unity Catalog securables called <strong>MCP Services</strong>, using the same three-level naming as everything else (catalog.schema.mcp_service). There’s no CREATE MCP SERVICE SQL statement; you create and manage them through the UI or REST API, but access is still governed through ordinary Unity Catalog permissions:</p><pre># Grant EXECUTE on the MCP Service itself<br>databricks api patch &quot;/api/2.1/unity-catalog/permissions/mcp_service/main.tools.github_mcp&quot; \<br>  --json &#39;{&quot;changes&quot;: [{&quot;principal&quot;: &quot;data-team&quot;, &quot;add&quot;: [&quot;EXECUTE&quot;]}]}&#39;</pre><p>Invoking an MCP Service actually needs three separate grants — EXECUTE on the service, plus USE CATALOG and USE SCHEMA on its parent catalog and schema — and Databricks is explicit that EXECUTE alone is not sufficient. On top of that access grant, <strong>tool selection</strong> lets you narrow what an MCP Service actually exposes: patterns like get_* allow-list read-style tools while leaving destructive ones out, though only prefix and exact-match patterns are supported — there’s no exclusion syntax like !delete_*, so filtering is allow-list-only by design. This is what makes an MCP-based service policy (the block_destructive_tool_calls example earlier) a second, complementary layer on top of tool selection rather than a replacement for it: tool selection controls what’s callable at all, a service policy controls what’s allowed to actually run given the specific request.</p><p><strong>Governing Skills</strong></p><p><strong>Skills</strong> — the packaged instructions that teach an agent how to do something correctly, such as following a specific runbook or applying an organization’s SQL style — are registered as their own Unity Catalog securable type (catalog.schema.skill), following the same SKILL.md format used elsewhere. Publishing a skill to Unity Catalog turns it into a single, governed source of truth: instead of five teams copy-pasting a slightly different version of the same skill into their own agent’s context, everyone references the one governed copy, shared “using the same permissions, tags, and audit that protect your tables.”</p><p>That means the same discovery and access story applies as for any other object: a skill is discoverable in Catalog Explorer alongside your data, access is controlled through Unity Catalog grants and tags rather than a separate skills-specific permission system, and changes to it are audited the same way a change to a table’s schema would be. Practically, this is what turns “the coding agent that knows our Databricks conventions” from a file living in one engineer’s home directory into an organizational asset the whole platform team can review, version, and revoke access to.</p><p><strong>Governing Agents</strong></p><p>An <strong>agent</strong> is registered in Unity Catalog as a model — the same object type used for any other served model — with the tools it’s allowed to call governed separately as MCP services, Unity Catalog functions, and connections. This is a deliberate design choice: an agent’s own identity and callability is one grant (EXECUTE on the agent’s model service, following the pattern from the Governing Models section above), and what that agent can actually <em>do</em> once invoked is a completely separate set of grants on the MCP services, functions, and model provider services it reaches into.</p><p>The practical effect is that governing an agent is really governing a graph, not a single object: who can call the agent, which tools the agent itself can reach (and with what tool-selection filters), which model provider it routes through, and which service policies apply at each of those hops. An agent inherits everything the calling user can access, so a service policy that requires approval before a destructive action, or a tool-selection filter that excludes delete_*, protects the agent’s user even when the agent’s own logic would have gone ahead. Reviewing an agent for production readiness, in practice, means walking that whole graph — the agent’s own grant, then every MCP service, function, and model provider it depends on — rather than checking one permission and calling it done.</p><p><strong>Service policies: guardrails that actually look at content</strong></p><p>A service policy is a SQL user-defined function registered in Unity Catalog, attached to a specific MCP service or model service. Databricks evaluates it at two points in every interaction: <strong>ON CALL</strong>, before the service is invoked (inspecting the request), and <strong>ON RESULT</strong>, after it responds (inspecting the response). A policy function takes a single event argument and returns a decision — branching on whether it’s looking at a request or a response:</p><pre>%sql<br>CREATE OR REPLACE FUNCTION main.governance.block_destructive_tool_calls(<br>event VARIANT<br>)<br>RETURNS VARIANT<br>LANGUAGE SQL<br>RETURN CASE<br>-- ON CALL: inspect the request before the tool actually runs<br>WHEN event:type::string = &#39;request&#39;<br>AND event:tool_name::string IN (&#39;delete_repo&#39;, &#39;force_push&#39;, &#39;drop_database&#39;)<br>THEN parse_json(to_json(named_struct(&#39;decision&#39;, &#39;DENY&#39;, &#39;reason&#39;, &#39;Destructive tool call blocked by policy&#39;)))<br>-- ON RESULT: inspect the response before it reaches the caller<br>WHEN event:type::string = &#39;response&#39;<br>AND contains(lower(event:content::string), &#39;ssn&#39;)<br>THEN parse_json(to_json(named_struct(&#39;decision&#39;, &#39;DENY&#39;, &#39;reason&#39;, &#39;Response appears to contain PII&#39;)))<br>ELSE parse_json(to_json(named_struct(&#39;decision&#39;, &#39;ALLOW&#39;, &#39;reason&#39;, CAST(NULL AS STRING))))<br>END;</pre><p>(Treat the exact shape of the returned decision object as illustrative — this is a Beta feature, so check the current field reference before shipping a policy like this.) Once written, the function is attached to a service through the Unity AI Gateway UI rather than by editing the agent’s code — which is the point: the same policy governs every caller of that service, and it’s enforced centrally, not something each agent’s developer has to remember to implement.</p><p>Two kinds of custom policies are worth distinguishing:</p><ul><li><strong>Deterministic SQL policies</strong> — exact, rule-based decisions: a specific tool name, an argument value, a keyword match, a length check. The example above is deterministic.</li><li><strong>LLM-as-a-judge policies</strong> — a natural-language classifier evaluated by a model, for checks that are semantic rather than exact (intent, tone, topic) and don’t reduce to a rule.</li></ul><p>You don’t have to write custom policies for the most common cases — Databricks ships <strong>built-in guardrails</strong> you attach the same way: system.ai.block_pii, system.ai.block_unsafe_content, system.ai.block_jailbreak, and system.ai.block_hallucination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*4M6LkxPuZbXOvkdqXclVVw.png" /></figure><p>And for genuinely sensitive actions, a policy can return ASK instead of ALLOW/DENY — pausing the interaction for a human to approve, which is how a human-in-the-loop approval step gets enforced for something like a destructive database operation, without hand-building that workflow into every agent that might attempt one.</p><p>Worth knowing before you rely on this: policy evaluation is <strong>fail-closed</strong>. If a policy function errors — a bug, a timeout, a missing field — the interaction is denied, not silently allowed through. That’s the right default for a guardrail, but it does mean a broken policy can take down a service, which is a good reason to test policies thoroughly before attaching them broadly.</p><h3>Cost governance: visibility first, hard caps second</h3><p>AI spend is easy to lose track of once it’s spread across multiple model providers, multiple teams, and agents that each make several model calls per user request. Unity AI Gateway’s cost controls are built around a fairly obvious but often-skipped sequence: see it, attribute it, then cap it.</p><ul><li><strong>Unified spend visibility</strong> — tracking usage across Databricks-hosted models, external frontier models, coding agents, and custom agents from one view, instead of stitching together separate provider invoices.</li><li><strong>Granular cost attribution</strong> — spend broken down by user, team, tool, and use case, using service tags and request tags, so “which team’s agent is burning the budget” is a query, not a guess.</li><li><strong>Hard spend caps</strong> — budgets that actually stop requests once exceeded, rather than just alerting after the fact. This is the detail that changes the risk profile of an autonomous agent: a caught bug or a runaway loop gets stopped by policy before it produces an unexpected bill, not after someone notices it in next month’s invoice.</li><li><strong>Smart Routing</strong> (still in Beta as of GA) — recommending and automatically routing a request to the most appropriate model based on task complexity, quality needs, and cost, so cheaper models handle the steps that don’t need a frontier model’s reasoning.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lShzaey1j4bnzMrMEUyYFw.png" /></figure><h3>Observability tying it together</h3><p>Every interaction through the gateway is traceable end to end — usage, cost, access, and lineage in one place, queryable through system tables the same way you’d query billing or audit data elsewhere in Unity Catalog. That consistency matters: it means a security or platform team investigating an incident isn’t hunting across five different providers’ dashboards, they’re running a query against tables that live in the same catalog as everything else.</p><p>Databricks has also opened this up as a platform rather than a closed system — announcing partner integrations with security and identity vendors including CrowdStrike, Palo Alto Networks, Zscaler, Okta, SailPoint, and Cyera, so runtime AI activity can feed into the security tooling teams already run, instead of requiring a parallel, AI-specific monitoring stack.</p><h3>What’s actually production-ready today</h3><p>Worth being precise about this, since a lot of what’s genuinely new here shipped fast: as of GA in August 2026, the <strong>core platform, cost attribution, runtime guardrails, multi-provider model access, and Unity Catalog integration are generally available</strong>. <strong>Smart Routing remains in Beta.</strong> Service policies themselves are also still Beta-labeled in Databricks’ own documentation as of this writing, which is worth checking before you build a compliance story around them.</p><p>It’s also worth treating Unity AI Gateway as a moving target rather than a finished product, even post-GA. The set of securable types it governs, the coverage of built-in guardrails, and which classic Serving Endpoints behaviors get folded into it automatically versus require opt-in have all shifted since the feature’s preview, and there’s no reason to expect that to stop now. GA removes the “should I build on this at all” question, but it doesn’t remove the “check the current docs before you rely on a specific detail” habit — particularly for anything still Beta-labeled, and for exactly the kind of gap described above, where a classic endpoint sits outside Gateway governance until someone deliberately turns it on.</p><h3>The takeaway</h3><p>The shift Unity AI Gateway represents is real and overdue: agents are the most privileged actors in most enterprise stacks right now, and “can this account reach this system” was never going to be a sufficient control once the thing making decisions inside that access is a model, not a human following a runbook. But a gateway is infrastructure, not a governance strategy by itself — someone still has to decide what the policies should actually say, who owns changing them, and who’s accountable when a hard cap fires or a policy denies something it shouldn’t have. The tooling can now enforce those decisions in real time. It can’t make them for you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e33f9d976cc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Certify Your Data Model on Databricks Using View Relationships]]></title>
            <link>https://medium.com/@prantikg/how-to-certify-your-data-model-on-databricks-using-view-relationships-9a87976b90a1?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a87976b90a1</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[data-architecture]]></category>
            <category><![CDATA[databricks-unity-catalog]]></category>
            <category><![CDATA[data-lakehouse]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Sat, 19 Sep 2026 19:40:54 GMT</pubDate>
            <atom:updated>2026-10-16T12:52:44.193Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Overview</strong></p><p>Certification in Unity Catalog is a one-click tag, but the trust it’s supposed to signal has to come from somewhere. That “somewhere” is the primary key and foreign key relationships declared on your tables — and the Entity Relationship Diagram (ERD), accessible via <strong>View relationships</strong> in Catalog Explorer, is how you actually see whether those relationships form a coherent model before you tell everyone downstream it’s safe to build on.</p><p><strong>What you’ll learn:</strong></p><ul><li>What the certified tag actually does in Unity Catalog, and why it&#39;s a signal rather than a guarantee</li><li>Why primary/foreign key constraints matter even though Databricks doesn’t enforce them — including what RELY changes for the query optimizer</li><li>How to declare PK/FK constraints on tables, with working SQL</li><li>How to open and read the Entity Relationship Diagram (ERD) via <strong>View relationships</strong> in Catalog Explorer, and what to look for in it</li><li>How to assign certification through the UI and SQL, plus how to automate it at scale with tag automation</li></ul><p><strong>Certification is a signal, not a guarantee</strong></p><p>Unity Catalog lets you mark a table, view, dashboard, or Genie space as <strong>certified</strong> — a system-governed tag (system.certification_status) that puts a check mark next to the asset in Catalog Explorer and steers tools like Genie toward it over uncertified alternatives. It’s a genuinely useful feature: in a catalog with hundreds of tables, certification is what tells a consumer “this one has been reviewed, build on it with confidence” instead of leaving them to guess.</p><p>The part that’s easy to skip past is <em>what</em> should be reviewed before you certify something. A single table can be well-formed on its own — clean columns, sensible types, no nulls where they shouldn’t be — and still be part of a data model that’s incoherent, with a foreign key pointing at the wrong grain, or a relationship that was never declared at all. Certifying a broken model just means people now trust it <em>more</em> while it’s still wrong. The fix is making relationships the thing you check first.</p><p><strong>Why relationships need to be declared explicitly</strong></p><p>Unity Catalog supports primary key and foreign key constraints on Delta tables (and materialized views), but it’s worth being precise about what kind of constraint this is: they’re <strong>informational</strong>, not enforced. Databricks won’t stop you from inserting a duplicate primary key or a foreign key that points at a row that doesn’t exist. So why declare them at all?</p><p>Two reasons, and both matter for certification specifically:</p><ol><li><strong>The query optimizer can use them — if you tell it to.</strong> Declaring a constraint with the RELY option tells Databricks you’re guaranteeing the constraint actually holds (because your ETL pipeline enforces it, for example), and Photon will use that guarantee to skip unnecessary work — like turning a SELECT DISTINCT into a plain SELECT when it knows the key is already unique. Get this wrong — mark something RELY when it isn’t actually clean — and queries can silently return incorrect results, which is exactly the kind of thing certification is supposed to prevent.</li><li><strong>Metric views and Genie need them to join correctly.</strong> A metric view built on top of your tables relies on declared relationships to know how to join dimension and fact tables without guessing. An agent like Genie, answering a natural-language question over your catalog, is doing the same thing under the hood. Undeclared or incorrect relationships don’t just risk a wrong join in a notebook somewhere — they risk a wrong join that ships as a confident, natural-language answer.</li></ol><p><strong>Let’s try this</strong></p><p>Declaring fact and dimension tables with primary and foreign keys:</p><p>Declare dim_date with primary key</p><pre>CREATE TABLE IF NOT EXISTS learning_catalog.test.dim_date (<br>  date_key       INT          NOT NULL,<br>  full_date      DATE         NOT NULL,<br>  day_of_week    STRING       NOT NULL,<br>  day_of_month   INT          NOT NULL,<br>  month          INT          NOT NULL,<br>  month_name     STRING       NOT NULL,<br>  quarter        INT          NOT NULL,<br>  year           INT          NOT NULL,<br>  is_weekend     BOOLEAN      NOT NULL,<br>  CONSTRAINT pk_dim_date PRIMARY KEY (date_key)<br>);</pre><p>Declare dim_customer with primary key</p><pre>CREATE TABLE IF NOT EXISTS learning_catalog.test.dim_customer (<br>  customer_key   INT          NOT NULL,<br>  customer_id    STRING       NOT NULL,<br>  first_name     STRING       NOT NULL,<br>  last_name      STRING       NOT NULL,<br>  email          STRING,<br>  phone          STRING,<br>  city           STRING,<br>  state          STRING,<br>  country        STRING,<br>  segment        STRING,<br>  CONSTRAINT pk_dim_customer PRIMARY KEY (customer_key)<br>);</pre><p>Declare dim_product with primary key</p><pre>CREATE TABLE IF NOT EXISTS learning_catalog.test.dim_product (<br>  product_key    INT          NOT NULL,<br>  product_id     STRING       NOT NULL,<br>  product_name   STRING       NOT NULL,<br>  category       STRING,<br>  subcategory    STRING,<br>  brand          STRING,<br>  unit_cost      DECIMAL(12,2),<br>  unit_price     DECIMAL(12,2),<br>  CONSTRAINT pk_dim_product PRIMARY KEY (product_key)<br>);</pre><p>Declare dim_store with primary key</p><pre>CREATE TABLE IF NOT EXISTS learning_catalog.test.dim_store (<br>  store_key      INT          NOT NULL,<br>  store_id       STRING       NOT NULL,<br>  store_name     STRING       NOT NULL,<br>  city           STRING,<br>  state          STRING,<br>  country        STRING,<br>  region         STRING,<br>  store_type     STRING,<br>  open_date      DATE,<br>  CONSTRAINT pk_dim_store PRIMARY KEY (store_key)<br>);</pre><p>Declare dim_promotion with primary key</p><pre>CREATE TABLE IF NOT EXISTS learning_catalog.test.dim_promotion (<br>  promotion_key  INT          NOT NULL,<br>  promotion_id   STRING       NOT NULL,<br>  promotion_name STRING       NOT NULL,<br>  discount_pct   DECIMAL(5,2),<br>  start_date     DATE,<br>  end_date       DATE,<br>  promotion_type STRING,<br>  CONSTRAINT pk_dim_promotion PRIMARY KEY (promotion_key)<br>);</pre><p>Declare fact_sales with primary and foreign keys</p><pre>CREATE TABLE IF NOT EXISTS learning_catalog.test.fact_sales (<br>  sale_id        BIGINT       NOT NULL,<br>  date_key       INT          NOT NULL,<br>  customer_key   INT          NOT NULL,<br>  product_key    INT          NOT NULL,<br>  store_key      INT          NOT NULL,<br>  promotion_key  INT,<br>  quantity        INT          NOT NULL,<br>  unit_price     DECIMAL(12,2) NOT NULL,<br>  discount_amount DECIMAL(12,2) DEFAULT 0,<br>  sales_amount   DECIMAL(12,2) NOT NULL,<br>  cost_amount    DECIMAL(12,2) NOT NULL,<br>  profit_amount  DECIMAL(12,2) NOT NULL,<br>  CONSTRAINT pk_fact_sales PRIMARY KEY (sale_id),<br>  CONSTRAINT fk_fact_sales_date FOREIGN KEY (date_key) REFERENCES cgms.test.dim_date(date_key),<br>  CONSTRAINT fk_fact_sales_customer FOREIGN KEY (customer_key) REFERENCES cgms.test.dim_customer(customer_key),<br>  CONSTRAINT fk_fact_sales_product FOREIGN KEY (product_key) REFERENCES cgms.test.dim_product(product_key),<br>  CONSTRAINT fk_fact_sales_store FOREIGN KEY (store_key) REFERENCES cgms.test.dim_store(store_key),<br>  CONSTRAINT fk_fact_sales_promotion FOREIGN KEY (promotion_key) REFERENCES cgms.test.dim_promotion(promotion_key)<br>)<br>TBLPROPERTIES (&#39;delta.feature.allowColumnDefaults&#39; = &#39;supported&#39;);</pre><p><strong>Seeing the model: the Entity Relationship Diagram</strong></p><p>Declaring constraints table by table is necessary, but it’s hard to eyeball whether the <em>whole model</em> hangs together from a list of ALTER TABLE statements. This is what the ERD is for.</p><p>In Catalog Explorer, open any table that has a foreign key defined — primary key and foreign key columns show a small pill icon next to them — and click <strong>View relationships</strong> in the Overview tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*rFCikTMyeWuE5LhU0wTJjA.png" /></figure><p>That opens a graph view showing exactly how that table connects to others through declared primary and foreign keys: which tables reference it, which tables it references, and the columns involved in each relationship.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eh5QlXLQukss3kEcnDBWSw.png" /></figure><p>This is the step that turns certification from a formality into an actual review. Reading through the ERD before certifying something, you’re specifically looking for:</p><ul><li><strong>Missing relationships</strong> — a foreign-key-shaped column (like customer_id on an orders table) that was never actually declared as a foreign key, so it doesn’t show up in the graph at all and won’t help Genie or a metric view join correctly.</li><li><strong>Relationships pointing at the wrong grain</strong> — a foreign key referencing a table’s primary key when the actual join should happen at a different level of detail (order line vs. order header, for instance).</li><li><strong>Orphaned tables</strong> — a table sitting in the domain with no declared relationships to anything else, which is either a sign it doesn’t belong in this model, or a sign someone forgot to wire it in.</li></ul><p>None of this is visible from looking at one table’s schema in isolation — it only becomes obvious once you can see the graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VR68CpblKoejrmW-DPR8Zg.png" /></figure><h3>Certifying once the model checks out</h3><p>Once the ERD shows a coherent model — every relationship that should exist is declared, nothing points at the wrong grain, no orphaned tables — certifying is the easy part. Through the UI, open the kebab menu on the object in Catalog Explorer, select <strong>Assign certification</strong>, choose <strong>Certified</strong>, and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ls2i7xdTtpb71WB3NipW2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*5L7v6pZn1an5hHpMnZTicw.png" /></figure><p>You can also certify by adding the <strong>system.certification_status </strong>tag. To do this, scroll down the overview tab. Click on Add Tag button, then select the key <strong>system.certification_status</strong>, select the value certified and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/136/1*2fLYh_22npikezhir2mbRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcTQEzhqHUigfE-0Ixif4Q.png" /></figure><p>The same thing can be done via SQL as well:</p><pre>SET TAG ON TABLE learning_catalog.test.fact_sales `system.certification_status` = `certified`;<br>SET TAG ON TABLE learning_catalog.test.dim_date `system.certification_status` = `certified`;<br>SET TAG ON TABLE learning_catalog.test.dim_customer `system.certification_status` = `certified`;<br>SET TAG ON TABLE learning_catalog.test.dim_product `system.certification_status` = `certified`;<br>SET TAG ON TABLE learning_catalog.test.dim_store `system.certification_status` = `certified`;<br>SET TAG ON TABLE learning_catalog.test.dim_promotion `system.certification_status` = `certified`;</pre><p>Both approaches require the APPLY TAG privilege on the object (or ownership), plus USE SCHEMA and USE CATALOG on its parents — worth checking up front if you’re certifying assets you don’t own yourself.</p><p>For a catalog with more than a handful of tables, doing this one object at a time doesn’t scale. Databricks supports <strong>tag automation</strong>, where you describe your certification criteria — for Genie, in plain language — and it applies the certified tag across every matching asset on a schedule, with a dry run first so you can review what would be tagged before it actually happens. This matters for keeping certification honest over time: a table that was certified six months ago but hasn’t been reviewed since is exactly the kind of stale trust signal certification is supposed to prevent.</p><p><strong>The takeaway</strong></p><p>Certification is one click; making that click mean something is the actual work, and that work is declaring and visually verifying relationships, not just eyeballing a single table’s column list. Treat the ERD as a required checkpoint rather than an optional nicety: open <strong>View relationships</strong> before certifying anything, confirm the model is coherent — no missing links, no wrong-grain joins, no orphaned tables — and only then apply the tag. Do that consistently, and “certified” on your catalog actually means what Genie, metric views, and the next engineer reading your schema will assume it means.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a87976b90a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vector-DB-Less RAG on Databricks: Building Retrieval with AI Search Instead of a Separate Vector…]]></title>
            <link>https://medium.com/@prantikg/vector-db-less-rag-on-databricks-building-retrieval-with-ai-search-instead-of-a-separate-vector-f33e27c0fd51?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f33e27c0fd51</guid>
            <category><![CDATA[mosaic-ai-vector-search]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[ai-search]]></category>
            <category><![CDATA[vectorless-rag]]></category>
            <category><![CDATA[rags]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 01:50:47 GMT</pubDate>
            <atom:updated>2026-09-10T01:56:45.014Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Vector-DB-Less RAG on Databricks: Building Retrieval with AI Search Instead of a Separate Vector Store</strong></h3><p><strong>What you’ll learn</strong></p><p>RAG doesn’t have to mean standing up a vector database. Databricks’ AI Search now supports full-text keyword search directly on a Delta table — no embeddings, no separate vector index. This post walks through both architectures side by side, with working code for each, so you can pick the right one based on how your users actually search instead of defaulting to the heavier setup</p><p><strong>The question worth asking before you provision a vector database</strong></p><p>Retrieval-Augmented Generation has become the default answer for “how do I get an LLM to answer questions using my own data.” And for the last couple of years, the default architecture for RAG has come with an assumption baked in: you’ll need a vector database. Chunk your documents, embed them, store the vectors somewhere, and do similarity search at query time.</p><p>That assumption is worth re-examining. Not every retrieval problem is actually a semantic-similarity problem, and running a vector database is real operational weight — another system to provision, secure, sync, and pay for. On Databricks, AI Search (the renamed and expanded version of what used to be called Vector Search) now supports full-text keyword search directly against a Delta table, with no embeddings and no separate vector store involved at all. This post walks through both architectures — the standard vector-DB approach and the vector-DB-less alternative — so you can actually decide which one a given use case needs, rather than defaulting to the heavier one out of habit.</p><p><strong>How RAG works with a vector database</strong></p><p>The standard RAG pipeline has two distinct phases: an offline ingestion pipeline that prepares your data, and an online query pipeline that runs every time a user asks a question.</p><p><strong>Ingestion</strong>, done once and refreshed as source data changes:</p><ol><li>Raw documents (PDFs, wiki pages, support tickets, whatever your knowledge base is) get pulled in and chunked into passages small enough to embed meaningfully and fit in an LLM’s context window.</li><li>Each chunk is passed through an embedding model, which turns the text into a dense numeric vector — a point in high-dimensional space where semantically similar text ends up near other semantically similar text.</li><li>Those vectors, along with the original text and any metadata, get written into a vector store, which builds an index (commonly an approximate nearest-neighbor, or ANN, structure) to make similarity search fast even across millions of vectors.</li></ol><p><strong>Query time</strong>, on every user request:</p><ol><li>The user’s question gets embedded using the same embedding model used during ingestion.</li><li>The vector store runs an ANN search to find the stored vectors closest to the query vector — the chunks whose <em>meaning</em> is closest to what was asked, not necessarily chunks that share exact keywords.</li><li>The retrieved chunks are stuffed into the LLM’s prompt as context, and the LLM generates an answer grounded in that retrieved text.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*V2gh_esQ7w1Oxifou9CYPA.png" /></figure><p>This is a genuinely solid architecture, and for a lot of RAG use cases — especially ones where users ask questions in their own words, using synonyms or paraphrases the source documents don’t contain verbatim — semantic similarity search is exactly the right tool. The trade-off is what it costs to run: an embedding model has to process every chunk (and every query), the vector index adds its own compute and storage footprint, and you’re relying on the embedding model’s notion of “similar” being the right notion for your domain.</p><p><strong>Building RAG without a vector database</strong></p><p>On Databricks, this whole pipeline maps onto AI Search’s Delta Sync Index, which handles the embedding and indexing step automatically and keeps itself in sync with a source Delta table.</p><p>Not every retrieval problem needs semantic similarity. If someone searches for an exact error code, a product SKU, a policy number, or a specific person’s name, what they want is an exact or near-exact keyword match — and embeddings can actually work <em>against</em> you here, since a vector model optimized for semantic meaning can rate a document about a similar-sounding but wrong error code as “close enough,” while a plain keyword search would never make that mistake.</p><p>AI Search now supports a <strong>dedicated full-text search index</strong> — a Delta Sync Index created with no embedding columns at all, built for keyword-only retrieval. There’s no embedding model in the loop, no vector index to maintain, and nothing running outside of Unity Catalog and the AI Search service itself — which is really the core of the “vector-DB-less” idea: you’re not standing up a separate system, you’re querying a Delta table through a governed index that happens to do the searching for you.</p><p><strong>Ingestion</strong> looks almost the same as before, minus the embedding step entirely:</p><ol><li>Documents are still chunked (full-text search still benefits from reasonably sized passages, though it’s less sensitive to chunk size than embeddings are).</li><li>Chunks land in a Delta table — no embedding model call, no vector generation.</li><li>AI Search builds a full-text index directly off that table, tokenizing the text and keeping itself in sync as rows change.</li></ol><p><strong>Query time:</strong></p><ol><li>The user’s question (or the specific term extracted from it) is sent straight to the index — no query embedding step.</li><li>The index runs keyword-based matching and returns the chunks that actually contain the relevant terms.</li><li>Retrieved chunks go to the LLM exactly as they would in the vector-based pipeline.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LY0U1xQ4QpvtqTpw5ktECA.png" /></figure><p><strong>Let’s do this on our own:</strong></p><ol><li>Create your catalog — rag_catalog</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/202/1*YzC9nQ1yQE9jrYj3YudjpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*ly85d3cZ07v0476dIx_hzw.png" /></figure><p>2. Create new schema — rag_schema</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*xETOTe3Gc26pEdZantNzSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*jQsJJARtC8pcAB4wSqmfbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*0U1HFXiBGycsORqmVJxegw.png" /></figure><p>3. Create a new volume and upload your document</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*Gyh_fLtL9Z1JyUpn1-Fntw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*jFx1grBNjkJv6SNzuP1Cbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*iPKnWMMPYjQA0PvkutVyjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*0MlVh-3ZrHyDANbyJd1RfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*qYAzs8j-c04thGjiYEq3bg.png" /></figure><p>4. Go to compute on the left menu and go to AI Search tab -&gt; Click on Create endpoint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*9gBlVh2xZEAvxK8N7eGC2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*Y0bOL6D_4ko18lPbhWDzHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*5Tx9gUq-sH-qezpwNIYOAg.png" /></figure><p>5. Run below code in your notebook to create a search index</p><pre>%pip install databricks-vectorsearch<br>dbutils.library.restartPython()</pre><pre>from databricks.vector_search.client import VectorSearchClient<br><br># Enable Change Data Feed required by Vector Search<br>spark.sql(&quot;ALTER TABLE rag_catalog.rag_schema.document_chunks SET TBLPROPERTIES (&#39;delta.enableChangeDataFeed&#39; = &#39;true&#39;)&quot;)<br><br>client = VectorSearchClient()<br><br>index = client.create_delta_sync_index(<br>    endpoint_name=&quot;rag_endpoint&quot;,<br>    source_table_name=&quot;rag_catalog.rag_schema.document_chunks&quot;,<br>    index_name=&quot;rag_catalog.rag_schema.rag_index&quot;,<br>    pipeline_type=&quot;TRIGGERED&quot;,<br>    primary_key=&quot;chunk_id&quot;,<br>    embedding_source_column=&quot;chunk_text&quot;,<br>    embedding_model_endpoint_name=&quot;databricks-qwen3-embedding-0-6b&quot;,<br>    columns_to_sync=[&quot;source_path&quot;, &quot;page_numbers&quot;]<br>)</pre><p>Wait for the index to finish its initial sync before querying</p><p>Verify the index has been created and the status is Online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*5pnIOQ-1Pd2NshTcoJafmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*pjX1-3y6FRVdXttbNOxXSA.png" /></figure><p>6. Time to query our index and summarize using LLM</p><pre>from openai import OpenAI<br>import os<br><br># --- Configuration ---<br>DATABRICKS_TOKEN = dbutils.notebook.entry_point.getDbutils().notebook().getContext().apiToken().get()<br>DATABRICKS_HOST = spark.conf.get(&quot;spark.databricks.workspaceUrl&quot;)<br><br># --- Step 1: Retrieve relevant docs from Vector Search ---<br>from databricks.vector_search.client import VectorSearchClient<br><br>vsc = VectorSearchClient()<br>index = vsc.get_index(<br>    endpoint_name=&quot;rag_endpoint&quot;,<br>    index_name=&quot;rag_catalog.rag_schema.rag_index&quot;<br>)<br><br>query = &quot;what is Medallion Lakehouse Architecture?&quot;<br><br># Delta Sync Index with embeddings computed by Databricks<br>results = index.similarity_search(<br>    query_text=query,<br>    columns=[&quot;chunk_text&quot;],<br>    num_results=5,<br>)<br><br># Extract retrieved documents<br>docs = [row[0] for row in results[&quot;result&quot;][&quot;data_array&quot;]]<br>context = &quot;\n\n---\n\n&quot;.join(docs)<br><br>print(f&quot;Retrieved {len(docs)} relevant chunks.\n&quot;)<br><br># --- Step 2: Call LLM to summarize docs based on the prompt ---<br>client = OpenAI(<br>    api_key=DATABRICKS_TOKEN,<br>    base_url=f&quot;https://{DATABRICKS_HOST}/serving-endpoints&quot;<br>)<br><br>system_prompt = &quot;&quot;&quot;You are a helpful assistant. Based on the provided context documents, <br>provide a clear and concise summary that answers the user&#39;s question. <br>Only use information from the provided context. If the context does not contain <br>enough information, say so.&quot;&quot;&quot;<br><br>user_prompt = f&quot;&quot;&quot;Context documents:<br>{context}<br><br>---<br><br>Question: {query}<br><br>Please summarize the relevant information from the documents above to answer the question.&quot;&quot;&quot;<br><br>response = client.chat.completions.create(<br>    model=&quot;databricks-claude-sonnet-5&quot;,<br>    messages=[<br>        {&quot;role&quot;: &quot;system&quot;, &quot;content&quot;: system_prompt},<br>        {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: user_prompt}<br>    ],<br>    max_tokens=1024<br>)<br><br>summary = response.choices[0].message.content<br><br>print(&quot;=&quot; * 60)<br>print(f&quot;Query: {query}&quot;)<br>print(&quot;=&quot; * 60)<br>print(f&quot;\nSummary:\n{summary}&quot;)</pre><p>Output:</p><pre>============================================================<br>Query: what is Medallion Lakehouse Architecture?<br>============================================================<br><br>Summary:<br># Medallion Lakehouse Architecture<br><br>Based on the provided documents, the **Medallion Lakehouse Architecture** is a **multi-layered design pattern** used within a Data Lakehouse to organize and progressively refine data, ultimately creating a **single source of truth**.</pre><p><strong>The takeaway</strong></p><p><strong>Databricks AI Search</strong> (formerly Mosaic AI Vector Search) offers significant architectural, operational, and governance advantages over standalone vector databases (like Pinecone, Milvus, or Qdrant) by being natively integrated into the data lakehouse platform.</p><ul><li><strong>Native Data Lakehouse Integration:</strong> Eliminates complex ETL pipelines by automatically syncing vectors directly from your existing Databricks Delta Tables.</li><li><strong>Unified Security and Compliance:</strong> Governed completely by Unity Catalog, inheriting your existing data lineage, access controls, and enterprise-grade security rules.</li><li><strong>Serverless Cost Efficiency:</strong> Scales dynamically using a decoupled storage-and-compute architecture, cutting costs by up to 7x for massive datasets.</li><li><strong>Production-Ready Retrieval:</strong> Provides native hybrid search (combining keyword and vector results) and built-in reranking without requiring external search engines.</li><li><strong>Zero Infrastructure Overhead:</strong> Removes the operational burden of manually provisioning clusters, balancing shards, or managing memory-bound infrastructure.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f33e27c0fd51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Production grade AI Agent Observability in Databricks using MLflow]]></title>
            <link>https://medium.com/@prantikg/build-production-grade-ai-agent-observability-in-databricks-using-mlflow-6ea8a8a73001?source=rss-60b32ec7f7d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ea8a8a73001</guid>
            <category><![CDATA[databricks-ai]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[agent-observability]]></category>
            <category><![CDATA[ai-agent-observability]]></category>
            <category><![CDATA[ai-observability]]></category>
            <dc:creator><![CDATA[Prantik Gachhayat]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 15:21:32 GMT</pubDate>
            <atom:updated>2026-09-09T00:16:13.495Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What you’ll learn</strong></p><p>AI agents don’t fail like normal software — they can look perfectly healthy while quietly giving wrong answers, and there’s no equivalent of a unit test for “was that a good response.” This post walks through how MLflow closes that gap on Databricks: tracing to see what an agent actually did at each step, human feedback and LLM-as-a-judge to catch when it’s wrong (and automate that detection at scale), prompt optimization to fix issues without endless manual tweaking, and an AI gateway to govern cost, fallback, and access once it’s all live in production. Same tooling in dev and prod — the only thing that changes is whose traffic it’s watching.</p><p><strong>Why traditional software delivery model will not work for AI Agents</strong></p><p>Software engineering has a well-worn playbook. Write code locally, cover it with unit tests, run it through QA, add production telemetry, ship it, and watch for stack traces when something breaks. It’s not glamorous, but it’s predictable, and most teams can execute it in their sleep.</p><p>AI agents break that playbook. Teams write an agent, run it against a handful of examples, ship it to production, and then quietly hope it holds up. There’s no equivalent of a unit test for “did the agent give a good answer,” so issues surface only after users start complaining — by which point the agent has already been exposed to every risk it was going to create.</p><p>This is the gap MLflow’s newer capabilities are built to close, and it’s worth understanding both <em>why</em> the gap exists and <em>how</em> to close it if you’re building agents on Databricks.</p><p><strong>A quick word on MLflow</strong></p><p>MLflow started as an MLOps tool roughly eight years ago, aimed at getting classical ML models — classifiers, regressors — packaged and into production cleanly. Since then it has grown through the LLM era into what is now, by download numbers, the most widely used open-source AI operations platform, with tracing support across dozens of Python and TypeScript libraries. Databricks also ships it as a managed offering inside the Data Intelligence Platform, layering on governance, Unity Catalog integration, and enterprise-scale trace storage on top of the open-source core.</p><p>For agent development specifically, MLflow now covers four things that used to require stitching together separate tools: <strong>tracing/observability</strong>, <strong>evaluation</strong>, <strong>prompt management</strong>, and <strong>an AI gateway</strong> for governing access to models and tools. Together they turn “hope for the best” into something closer to a real engineering discipline.</p><p>Just as important as any single feature is that none of it assumes you’ll standardize on one framework, one model provider, or one language. Tracing works across dozens of Python and TypeScript authoring libraries and speaks OpenTelemetry, so it doesn’t lock you into a particular agent framework; the gateway is provider-agnostic by design. That matters because agent tooling changes fast — teams are picking up new frameworks and swapping models constantly — and a platform that only works with today’s stack becomes dead weight the moment the stack shifts.</p><p><strong>Why agents are genuinely harder to operate than software</strong></p><p>It helps to be specific about what makes agents different, rather than just asserting that they’re “harder”:</p><ul><li><strong>Outputs are non-deterministic.</strong> Send the same query to the same agent five times and you can get five different answers. A test suite built around exact-match assertions simply doesn’t work.</li><li><strong>Quality is subjective and needs domain expertise.</strong> Whether an answer is “good” often depends on business context that the developer doesn’t have and the end user didn’t explain. This forces collaboration between engineers and domain experts in a way conventional software rarely requires.</li><li><strong>Every deployment carries new categories of risk</strong> — PII leakage, offensive or unsafe responses, and other failure modes that don’t show up as a crash or an exception.</li><li><strong>Cost, latency, and quality trade off against each other constantly.</strong> Swapping in a cheaper or faster model can quietly degrade quality well past an acceptable threshold, and nobody notices until it’s a problem.</li><li><strong>Step-level behavior is invisible by default.</strong> When an agent gives a wrong answer, the question is rarely “did it crash” — it’s “where did retrieval go wrong, which knowledge source did it pull from, and what context actually got passed to the model at that step?” None of that is visible from a normal application log.</li><li><strong>Feedback and quality detection have to be built, not assumed.</strong> There’s no built-in way to know whether an agent is actually meeting users’ needs. Someone has to design how domain experts and end users give feedback, and then find a way to detect quality issues automatically across far more traffic than anyone could read by hand.</li><li><strong>Prompts need the same discipline as code, and rarely get it.</strong> Prompts drive most of an agent’s behavior, but without a way to register, version, and share them, teams end up with prompt logic scattered across notebooks and Slack threads, and no record of what changed between a version that worked and one that didn’t.</li><li><strong>The tooling underneath keeps changing.</strong> Developers are adopting new frameworks, models, and libraries constantly because the field moves too fast to stand still — which means whatever platform handles tracing, evaluation, and prompt management has to work across that whole moving landscape (multiple languages, multiple model providers, multiple authoring frameworks) rather than locking a team into one stack. That compatibility requirement alone is a big part of why building this kind of platform well is hard.</li></ul><p>Put those together and it’s easy to see why “write it, test it a bit, ship it” leaves so much exposure on the table. Three problems in particular tend to catch teams off guard once an agent is actually carrying production traffic.</p><p><strong>Reliability and error handling look completely different</strong></p><p>A conventional service is either up or down, and monitoring is built around that binary. An agent can be perfectly “up” — 200 status codes, normal latency, no exceptions in the logs — while quietly giving wrong answers, calling the wrong tool, or getting stuck in a reasoning loop. Traditional infrastructure monitoring simply doesn’t see this class of failure, because nothing actually crashed.</p><p>Multi-step agents make this worse: a small error early in a chain — a bad retrieval, a misread tool result — compounds as it flows through later steps, so the final answer can look confidently wrong. Error handling has to happen at two levels: infrastructure resilience (timeouts, retries, and fallback to another model when a provider is slow or down, which is exactly what an AI gateway is for) and behavioral resilience (catching bad outputs before they reach a user, which needs evaluation and guardrails, not just uptime checks). Real incidents from the last couple of years — agents deleting data they were told to leave alone, or making purchases without the confirmation they were supposed to require — are reminders that “the model didn’t crash” is a very low bar for reliability once an agent can actually take actions.</p><p><strong>Cost-effectiveness is a moving target, not a one-time decision</strong></p><p>Every agent run has a real, metered cost, and that cost isn’t fixed the way a server’s hourly price is. Longer conversations mean more tokens in context on every turn; a multi-step agent might call a model five or ten times to answer one user question; and it’s easy to default to the most capable (and most expensive) model for every step, including the simple ones that a cheaper model would handle just as well. None of this shows up as a problem until usage scales — a demo that costs a few cents to run can turn into a real budget line once it’s serving real traffic.</p><p>Keeping this in check is less about cutting corners and more about routing spend deliberately: sending simple classification or retrieval steps to smaller/cheaper models and reserving the expensive model for the steps that actually need its reasoning, caching repeated context instead of resending it on every call, and — as covered below — actually being able to see where the money is going by team, model, or feature, rather than finding out at the end of the month.</p><p><strong>“Continuous improvement” isn’t optional — it’s the job</strong></p><p>Perhaps the least intuitive part of running agents in production: launch is not the finish line. User behavior shifts, people find new ways to phrase requests, upstream data changes shape, and a prompt that was 95% correct against last quarter’s test set can quietly degrade as the traffic it sees in production drifts away from that test set. Industry surveys on production agents consistently point to quality regressions — not infrastructure failures — as the top reason agent projects stall or get pulled back after launch.</p><p>The practical implication is that evaluation can’t be a pre-launch checkbox. It needs to run continuously, against real traffic, with a fast path from “we noticed a regression” back to “we shipped a fix and confirmed it worked” — which is precisely the loop the rest of this post walks through: tracing to see what happened, human feedback and LLM judges to catch when it’s wrong, and prompt optimization to fix it without a slow manual guessing process each time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*2O5AqwRR-HR8RCpeS3ekYA.png" /></figure><p><strong>A more disciplined agent development lifecycle</strong></p><p>Instead of prototype-then-pray, a more reliable pattern looks like this:</p><ol><li>Build a working prototype that passes basic sanity checks</li><li>Get it in front of real testers or domain experts</li><li>Identify quality issues and turn them into reproducible test cases</li><li>Fix the issues — in prompts, agent code, or the underlying model</li><li>Re-test against those same cases to confirm the fix actually worked</li><li>Get stakeholder sign-off</li><li>Deploy to production and keep monitoring quality continuously</li></ol><p>The loop between steps 2 and 5 repeats as many times as needed before anything reaches production, and it keeps running — using the same tooling — after deployment. What makes this practical rather than aspirational is having the right infrastructure at each step, which is exactly what MLflow’s tracing, evaluation, and prompt management components are built for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*vdBHovCrxGk_v9U8GZkejg.png" /></figure><p><strong>Step 1: Observability through tracing</strong></p><p>The foundation of all of this is tracing. With a single line of code you can enable automatic tracing for most common agent-authoring libraries:</p><pre>import mlflow<br># Enable tracing for supported libraries (LangGraph, OpenAI SDK, etc.)<br>mlflow.langchain.autolog()<br><br># Point tracking at your Databricks workspace<br>mlflow.set_tracking_uri(&quot;databricks&quot;)<br>mlflow.set_experiment(&quot;/Shared/agent-observability-demo&quot;)</pre><p>Because MLflow tracing is OpenTelemetry-compatible, it isn’t locked to a single language or framework — you can stream traces in from whatever your team is already using.</p><p>Once tracing is on, every query your agent handles produces a step-by-step execution record: which sub-component handled the request, what context was retrieved, what tools were called, and what the model returned at each stage. Instead of guessing why an answer was wrong, you can open the trace and see exactly where the logic went off the rails — for example, a query getting routed to the wrong specialist sub-agent. For complex agents with hundreds of steps per trace, this kind of structured record is the difference between a five-minute root-cause and an afternoon of guesswork. MLflow also now offers an AI assistant that can read a trace and propose a likely root cause directly, which shortens that debugging loop even further.</p><p><strong>Step 2: Bringing humans into the loop</strong></p><p>Tracing tells you <em>what happened</em>. It doesn’t tell you <em>whether it was good</em>. That’s where feedback collection comes in.</p><p>MLflow provides a built-in review app: send a set of traces to a domain expert (just their email address is enough), and they get a simple chat-style interface where they can thumbs-up or thumbs-down a response and leave an explanation. That feedback gets stored right alongside the trace, so as a developer you can filter directly for “traces with negative feedback” and go straight to the interesting cases.</p><p>Sometimes a thumbs-down with no explanation isn’t enough to act on. For that, MLflow supports labeling sessions — a more structured way to route specific traces to a colleague and ask for a written explanation of <em>why</em> something was wrong, not just whether it was.</p><p><strong>Step 3: Scaling judgment with LLM-as-a-judge</strong></p><p>Finding one bad trace is useful, but it raises an obvious question: is this a one-off, or does it affect a meaningful chunk of your traffic? Nobody wants to manually read a thousand traces to find out.</p><p>This is where automated evaluation — LLM-as-a-judge — comes in. You describe the issue you’re checking for (e.g., “was this query routed to the correct specialist?”), and MLflow uses an LLM to apply that check consistently across any number of traces. MLflow also ships a set of built-in judges covering common concerns: response correctness, relevance and safety, chatbot-specific issues like knowledge retention or user frustration, tool-call relevance, and retrieval sufficiency, alongside compatibility with community frameworks.</p><p>A simplified version of running a judge against a batch of traces looks like this:</p><pre>import mlflow<br>from mlflow.genai.scorers import Correctness, Safety<br><br>results = mlflow.genai.evaluate(<br>    data=recent_traces,       # a DataFrame or list of traces<br>    scorers=[Correctness(), Safety()],<br>)</pre><p>Running this across, say, the last 200 traces might reveal that only 79% were routed correctly — turning a vague hunch (“something feels off”) into a concrete, quantified problem worth fixing. From there, the traces that failed can be exported directly into an evaluation dataset, which becomes your regression suite going forward.</p><p><strong>Step 4: Fixing issues without endless manual prompt tweaking</strong></p><p>Prompts still drive most of an agent’s behavior, so they’re usually the first place to look for a fix. MLflow’s prompt registry keeps versioned prompts for each part of an agent (routing logic, specialist sub-agents, and so on), which makes it easy to see exactly what instructions the agent is currently operating under. Because prompts are registered centrally rather than living in a notebook or a config file only one person touches, the rest of the team can find, reuse, and build on them too — with a version history that shows what changed and why, instead of a prompt that quietly drifted with no record of it.</p><p>Manually tweaking a prompt and re-running it to see if it helped is slow and doesn’t guarantee progress. MLflow’s prompt optimization takes the evaluation dataset and judge you already built, feeds them along with the current prompt into an optimization routine, and lets an LLM iteratively propose and test new prompt versions until the judge is satisfied. In practice this can turn a vague debugging session into a measurable before/after comparison — for instance, moving from 79% to 100% routing accuracy on a held-out test set, verified by re-running the exact same evaluation you used to catch the problem in the first place.</p><p><strong>Step 5: Production observability</strong></p><p>Nothing about this setup changes much when you actually deploy. The same tracing, the same feedback hooks, and the same judges keep running — they just start operating on real user traffic instead of internal test queries. That consistency is the point: the same judge that caught a routing problem in testing can be turned on for live monitoring with a single toggle, sampled at whatever rate makes sense for cost, and filtered to specific user segments if needed.</p><p><strong>Governing it all with AI Gateway</strong></p><p>Layered on top of tracing and evaluation is the AI gateway, which matters more with every additional team building agents inside the same organization. Instead of each agent calling OpenAI, Anthropic, or Gemini directly with its own credentials, every request goes through one gateway sitting between your applications and the model providers. The agent talks to the gateway using a standard interface; the gateway takes care of where the request actually goes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*u6wzmjABS7bhA02Xi7COTw.png" /></figure><p><strong>Monitoring cost and usage.</strong> Every request and response passes through the gateway, so it’s a natural place to log usage. In practice that means a dashboard showing request counts, token counts, and error rates broken down by model, team, or API key — the same view whether five people or five hundred are building agents against it. If a team’s routing prompt is quietly burning through a much pricier model than it needs to, this is where you’d see it, without having to instrument every individual agent to report its own spend. Payload logging alongside the usage numbers also gives you an audit trail: what was actually sent to a model and what came back, which matters both for debugging and for compliance.</p><p><strong>Fallback and load balancing.</strong> Because every request already flows through a single point, the gateway can also decide <em>where</em> a request goes without the agent’s code needing to know or care. Two patterns matter most:</p><ul><li><strong>Traffic splitting</strong> distributes requests across multiple models by percentage weight — useful for A/B testing a new model version, or gradually migrating traffic from one provider to another without a hard cutover.</li><li><strong>Automatic fallback</strong> detects when a model endpoint is erroring, rate-limited, or responding slowly, and reroutes those requests to a backup model or provider instead of surfacing the failure to the end user. This is what keeps an agent available during a provider outage without every team having to hand-write their own retry logic.</li></ul><p>Both are configured centrally, once, at the gateway — not inside every agent that happens to call an LLM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*jzBdgJs7l0EPUKEY-IcNCw.png" /></figure><p><strong>The takeaway</strong></p><p>The core shift here isn’t really about a new tool — it’s about applying the same rigor to agents that software engineering already applies to code, adapted for the fact that agent outputs are unpredictable and quality is subjective. Tracing gives you visibility, human feedback grounds your evaluation in real judgment, LLM judges let that judgment scale, and prompt optimization turns “iterate and hope” into something measurable. Put together, they replace “ship it and hope for the best” with an actual feedback loop — which, if you’ve operated agents in production, is exactly the loop that’s usually missing.</p><p>If you’re building agents on Databricks, none of this requires bolting together a separate observability stack — it’s the same platform you’re likely already using for tracking and governance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ea8a8a73001" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>