<?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 Gary Nakanelua on Medium]]></title>
        <description><![CDATA[Stories by Gary Nakanelua on Medium]]></description>
        <link>https://medium.com/@gnakan?source=rss-55658003d189------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Fn2rv7dOIdWXtXhjzxZCWw.png</url>
            <title>Stories by Gary Nakanelua on Medium</title>
            <link>https://medium.com/@gnakan?source=rss-55658003d189------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 17:59:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gnakan/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[AI Function task in Databricks bundles: 3 of 21 documents back to the model]]></title>
            <link>https://medium.com/lab-notes/ai-function-task-in-databricks-bundles-3-of-21-documents-back-to-the-model-b459c2c99904?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/b459c2c99904</guid>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 23:26:09 GMT</pubDate>
            <atom:updated>2026-11-24T23:27:06.613Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UwlDJRRJTbT7BUv-.png" /><figcaption>Same labels, 3 documents back to the model instead of 21</figcaption></figure><h3>The short version</h3><ul><li>After four changes to a 21-document table, the AI Function task sent 3 documents back to the model and a SQL cell running Databricks’ ai_classify function sent all 21.</li><li>Both sides labelled 21 of 21 documents correctly.</li><li>The task removed the deleted document’s result without a model call, and re-classified the corrected document from RECEIPT to INVOICE on its own.</li><li>The task writes a streaming table its own pipeline keeps in step, where the SQL cell replaces a managed table on every run.</li></ul><p>In a recent <a href="https://docs.databricks.com/aws/en/release-notes/product/2026/november#ai-function-task-support-in-declarative-automation-bundles-beta">Databricks release note</a> about AI Function tasks:</p><blockquote><em>“Support for AI Function tasks in Declarative Automation Bundles is now in Beta.”</em></blockquote><p>The note is one line. The <a href="https://docs.databricks.com/aws/en/jobs/tasks/ai-functions/">AI Function task docs</a> it points to make the claim worth checking: “Each run processes only the files or rows that were added, changed, or deleted since the previous run.” I already call <a href="https://docs.databricks.com/aws/en/large-language-models/ai-functions.html">AI Functions</a> from SQL cells, so this is a test of that claim against the way I run them today. Found this interesting, so I put together an experiment.</p><h3>The setup</h3><p>The notebook builds a <a href="https://docs.databricks.com/aws/en/delta/">Delta</a> table of 20 Stark Industries documents, each with a known label: invoice, receipt or contract. The table has <a href="https://docs.databricks.com/aws/en/delta/delta-change-data-feed">change data feed</a> turned on, which is how the task finds what changed.</p><p>One side is Databricks’ <a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_classify.html">ai_classify function</a>, version 2.1, in a SQL cell that writes its answers to a table. The labels carry one line of description each, which <a href="https://medium.com/lab-notes/databricks-ai-decide-vs-ai-classify-one-line-per-team-mattered-more-than-the-function-d8ed9f5da933">an earlier experiment found lifted every classification function by 9 to 30 tickets</a>. The other side is an AI Function task running the same ai_classify function, version and labels, created as a job from the notebook. In a bundle, the same spec sits under the job’s tasks in databricks.yml, per the <a href="https://docs.databricks.com/aws/en/dev-tools/bundles/job-task-types.html">bundle task types reference</a>:</p><pre>- task_key: classify<br>  ai_function_task:<br>    delta_table:<br>      table_name: workspace.dab_ai_function_task.stark_documents<br>      input_column: text<br>      merge_key_columns: [id]<br>    output: {catalog: workspace, schema: dab_ai_function_task, table: task_classified}<br>    ai_classify:<br>      version: &quot;2.1&quot;<br>      inline_labels: {labels: [...]}</pre><p>Both sides ran once on the fresh table. Then I made four changes, the kind a documents table sees between runs: two new documents, one corrected and one deleted. The corrected one was document 2, a receipt whose new text is a payment reminder, so its right label became INVOICE. Then both sides ran again. Everything ran on serverless on Databricks Free Edition. The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/dab-ai-function-task-beta/dab-ai-function-task-beta.ipynb">full notebook</a> walks through the build end to end.</p><h3>How many documents does a Databricks AI Function task send back to the model?</h3><p>Only the ones that changed. On the first run there was nothing to tell the two sides apart: each sent all 20 documents to the model. On the second run, the SQL cell sent the whole table again, 21 documents. The task sent 3: the two new documents and the one I corrected. It removed the deleted document’s result without calling the model at all. The task reads those counts from its pipeline’s event log, so they’re the platform’s numbers, not mine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*pdA3bNKxMC2V7nWw.png" /><figcaption>Rows sent to the model per run: 20 and 20 on run 1, then 21 from the SQL cell and 3 from the AI Function task after four changes.</figcaption></figure><p>The answers didn’t move. Both sides labelled all 21 documents correctly and agreed on every one. Document 2 came back from the task as INVOICE, so the correction reached the label without anything from me. Neither output kept a result for the deleted document: the SQL cell because it rewrites its whole table on every run, the task because it deleted that row.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6RHejh1lA3P2O1m1.png" /><figcaption>After four changes, the SQL cell sent 21 documents to the model and the AI Function task sent 3; both labelled 21 of 21 correctly and kept 0 results for the deleted document.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qIO_qw6-YM52Jq5N.png" /><figcaption>The comparison from the run: expected, SQL cell and task labels side by side, with 21 of 21 correct on both sides and document 2 relabelled INVOICE.</figcaption></figure><p>The last row is the structural difference. The task writes a <a href="https://docs.databricks.com/aws/en/dlt/streaming-tables">streaming table</a>, and the table’s properties name the pipeline that maintains it. The docs put it this way: “The output table is a streaming table that a later task can read incrementally.”</p><h3>What does this mean for a team evaluating AI Function tasks today?</h3><p>The experiment results suggest a fix stays small: correcting document 2 sent that one document back to the model, and every document that hadn’t changed stayed where it was.</p><p>In culinary school, I learned the expediter’s job on the line. When one order changes, you don’t re-fire every ticket on the rail. You fire the new ticket, re-fire the one that changed, and pull the cancelled one without cooking it. The SQL cell is a cook who re-fires the whole rail every time. The AI Function task is the expediter. Every plate comes out the same either way, which is what the 21 of 21 shows; what changes is how much gets cooked twice.</p><p>So if you already run an AI step from a SQL cell over a table that grows or gets corrected between runs, the task is worth a look. You declare it in a bundle next to the rest of the job, the answers match what your SQL cell gives you, and on the second run it only sends the model what changed. A table that’s rewritten wholesale between runs would send every row through the task too, so the gap grows with how much of the table stays put.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/dab-ai-function-task-beta/dab-ai-function-task-beta.ipynb">notebook</a> runs on Databricks Free Edition in about 10 minutes. AI Function tasks are in Beta: if the job create cell fails, a workspace admin turns on Lakeflow AI Function Task from the username menu in the top bar &gt; Previews. The notebook creates everything in one schema and removes the job and the schema in its last cell.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/jobs/tasks/ai-functions/">AI Function tasks for jobs</a>: what the task does on each run, its requirements and its limits.</li><li><a href="https://docs.databricks.com/aws/en/dev-tools/bundles/job-task-types.html">Add tasks to jobs in Declarative Automation Bundles</a>: the ai_function_task reference with YAML examples.</li><li><a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_classify.html">ai_classify function</a>: the function both sides call.</li><li><a href="https://docs.databricks.com/aws/en/delta/delta-change-data-feed">Change data feed</a>: what the task reads to find the rows that changed.</li><li><a href="https://docs.databricks.com/aws/en/dlt/streaming-tables">Streaming tables</a>: the kind of table the task writes.</li></ul><p>Every Friday, Lab Notes B-Sides sends the five things I found this week and didn’t build: <a href="https://buttondown.com/gnakan">https://buttondown.com/gnakan</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b459c2c99904" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/ai-function-task-in-databricks-bundles-3-of-21-documents-back-to-the-model-b459c2c99904">AI Function task in Databricks bundles: 3 of 21 documents back to the model</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can an AI assistant handle customers who change their mind?]]></title>
            <link>https://medium.com/the-second-read/can-an-ai-assistant-handle-customers-who-change-their-mind-6dba1de6f551?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/6dba1de6f551</guid>
            <category><![CDATA[customer-experience]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 23:07:45 GMT</pubDate>
            <atom:updated>2026-11-12T23:07:45.359Z</atom:updated>
            <content:encoded><![CDATA[<h3>The decision</h3><p>You’re deciding whether an AI assistant can take order changes from customers on its own, or whether every change still goes to a person.</p><h3>Where it goes wrong</h3><p>Picture the call. A customer orders two cases. A minute later they want one more. Then they ask you to ship the extra case to the same address as last month’s order. Each request is easy on its own. The order that ships has to reflect all three, in the right sequence, and the customer finds out whether it did when the box shows up.</p><h3>What I found</h3><p>I tested four AI models on short lists of values that changed a few times, standing in for an order that moves mid-conversation. A straight replacement was right every time. A change built on an earlier value, the “one more” kind, was right 67% of the time (<a href="https://medium.com/lab-notes/reasoning-models-on-databricks-foundation-model-apis-a-50-token-limit-flipped-two-verdicts-9993da9ff56c">the full write-up</a>).</p><h3>What it means for you</h3><p>The experiment results suggest an assistant slips on the changes that build on what came before, like “one more,” “drop one” and “same as last time,” while straight replacements hold up. That gap matters more than the size of the number, for two reasons.</p><p>First, it’s quiet. The assistant hands back the wrong order as plainly as a right one, so nobody on your team sees the mistake until the customer does. What reaches you is the return, and a customer who now double-checks every order they place with you.</p><p>Second, a demo won’t show it. A demo feeds it one clean request at a time, and those pass. Your customers don’t talk that way. They think out loud and refer back to things they said a minute ago or ordered last month.</p><p>So the useful question for your team is which kinds of changes the assistant takes on its own today. The rest stay with a person until you’ve watched it handle them with your own customers.</p><h3>What to do Monday</h3><p>Ask the team behind the assistant to split order changes into two groups: straight swaps (“make it blue,” “change the address to”) and changes that depend on something earlier (“add two more,” “same as last time”). Then have someone on your team play a customer through ten realistic calls, the messy kind where they change their mind twice and mention last month’s order, and count the misses in each group separately. If the second group misses, that’s your line. The assistant takes the swaps; a person takes the rest.</p><h3>What’s still open</h3><p>What worked: straight replacements were perfect across every model I tried, and two of the four were perfect at everything. The long call is the open question. Ai2, whose research this follows, found that accuracy falls sharply as the list of changes grows. A customer who keeps adjusting for ten minutes is the call to test next, with your own customers’ conversations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6dba1de6f551" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-second-read/can-an-ai-assistant-handle-customers-who-change-their-mind-6dba1de6f551">Can an AI assistant handle customers who change their mind?</a> was originally published in <a href="https://medium.com/the-second-read">The Second Read</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reasoning models on Databricks Foundation Model APIs: a 50-token limit flipped two verdicts]]></title>
            <link>https://medium.com/lab-notes/reasoning-models-on-databricks-foundation-model-apis-a-50-token-limit-flipped-two-verdicts-9993da9ff56c?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/9993da9ff56c</guid>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Thu, 12 Nov 2026 15:38:11 GMT</pubDate>
            <atom:updated>2026-11-12T15:38:11.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*_ovnSi7C_lmHVqj6.gif" /><figcaption>A token limit decided two of four model verdicts.</figcaption></figure><h3>The short version</h3><ul><li>With every reply capped at 50 tokens, Qwen 3.5 122B stopped before answering on all 12 state-tracking tasks and scored 0 of 12, while GPT OSS 120B was cut off on 8 of 12.</li><li>At 4,000 tokens, both reasoning models answered 12 of 12.</li><li>Llama 4 Maverick and Llama 3.3 70B answered 9 of 12 each in the same round, so the hypothesis held with a gap of exactly 25 points against a 25-point bar.</li><li>Self-updating variables (x = x + 5) were the hardest of the four StateBench levels, at 67% across the four models.</li></ul><p>In a recent <a href="https://huggingface.co/blog/allenai/statebench">Ai2 post on Hugging Face</a> introducing StateBench:</p><blockquote><em>“All four performed well on r-trivial and aperiodic problems. But on soluble and general finite problems, accuracy fell sharply as inputs grew longer”</em></blockquote><p>Ai2 built StateBench to measure how well language models follow a value as it changes, in four levels where each one adds a single new kind of update, and the frontier models it tested held up on the easy levels and fell apart on the hard ones as the inputs got longer. I took the same four levels and extended them onto the open models that Databricks serves, where a practitioner picking a model for an agent can rerun the comparison themselves. Found this interesting, so I put together an experiment.</p><h3>How do you run StateBench-style state tracking on Databricks Foundation Model APIs?</h3><p>The notebook builds 12 tasks, three at each StateBench level. R-trivial assigns each variable once. Aperiodic reassigns by value, so the last write wins. Soluble updates a variable from its own current value (x = x + 5). General finite copies one variable into another (x = y), so you have to follow the chain. Every task ends on one question: what’s the final value of this variable? These are short tasks, a handful of assignments each, so they test the kind of update rather than long documents.</p><p>It sends all 12 to four models through <a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/">Databricks Foundation Model APIs</a>, with the OpenAI-compatible client from the <a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/api-reference">Foundation Model REST API reference</a>: databricks-llama-4-maverick, databricks-qwen35-122b-a10b, databricks-gpt-oss-120b and databricks-meta-llama-3-3-70b-instruct. Two of those, Qwen 3.5 122B and GPT OSS 120B, are reasoning models. Per Databricks&#39; guide to <a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/query-reason-models">querying reasoning models</a>, &quot;The API response includes both thinking and text content blocks.&quot; Temperature is 0 and the system prompt asks for the number and nothing else. <a href="https://docs.databricks.com/aws/en/mlflow/tracking">MLflow tracking</a> logs a right-or-wrong metric for every call and an accuracy and verdict for every model.</p><p>Everything runs in a serverless notebook on Databricks Free Edition, and it never had to wait on a rate limit. The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/statebench-state-tracking/statebench-state-tracking.ipynb">full notebook</a> walks through the build end to end.</p><h3>Method</h3><p>The hypothesis and validation conditions were set before the first run, in the notebook’s second cell, and they didn’t change afterwards.</p><p>The hypothesis: at least one Foundation Model API model scores 70% or higher overall, and the top model beats the bottom model by at least 25 percentage points.</p><p>The four validation conditions:</p><ol><li>Task reproduction: at least 10 tasks, each with 3 or more state changes and its final value written down before any model runs.</li><li>Multi-model coverage: four models on the identical task set.</li><li>Trace completeness: every call logged to MLflow with its task, level, model, answer and right-or-wrong verdict.</li><li>Verdict: every model rated TRUST (70% or higher), CONDITIONAL (40% to 69%) or AVOID (under 40%).</li></ol><p>Reject if fewer than four models complete all tasks, or if the trace check fails.</p><p>One setting wasn’t part of the hypothesis: the token limit on each reply. I set it to 50, which covers a model that answers with one number. Round 1 showed me it doesn’t cover one that thinks first. So round 2 changes that one setting to 4,000 tokens and records each reply’s finish_reason, and the notebook labels the change as made after round 1. The 12 tasks, the system prompt, temperature, the hypothesis and the four conditions stayed exactly as they were, and round 1 stays in the notebook.</p><h3>Did a bigger token limit change which models track state on Databricks?</h3><p>Yes, for the two reasoning models. Qwen 3.5 122B and GPT OSS 120B went from the bottom of the table to the top, and the only thing that changed between rounds was how many tokens a reply could use:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BiwVJGC4ZrexgzD7.png" /><figcaption>At a 50-token limit Qwen 3.5 122B was cut off on all 12 tasks and scored 0%, and GPT OSS 120B was cut off on 8 and scored 33%; at 4,000 tokens neither was cut off and both scored 100%, while Llama 4 Maverick and Llama 3.3 70B scored 75%.</figcaption></figure><p>In round 1, Qwen 3.5 122B came back with a reasoning block and no text at all on every task, with finish_reason set to length. It ran out of room mid-thought. GPT OSS 120B did the same on 8 of 12. The scorer couldn&#39;t find a number in an answer that never arrived, so it marked them wrong, and the verdict cell rated both AVOID. Round 1 still met both predictions, with an 83-point spread, but that spread came from the cut-offs.</p><p>Round 2 took the cap off the table. No reply from any model hit the 4,000-token limit, and the two reasoning models answered every task right. The two Llama models each answered 9 of 12. Llama 4 Maverick got one fewer right with more room than it did at 50 tokens, so the Llama result rests on a single task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*PO-CRya_CM5Sq-yO.png" /><figcaption>The round 2 grid from the notebook: Qwen 3.5 122B and GPT OSS 120B at 100% overall, Llama 4 Maverick and Llama 3.3 70B at 75%.</figcaption></figure><p>By level, round 2 lines up with what Ai2 reported for frontier models. Every model got every r-trivial and aperiodic task right. Soluble, the self-updating level, was the hardest at 67% across the four models, and general finite came in at 83%. Ai2 saw general finite drop furthest on its longest inputs; on tasks this short, it was the self-updating step that tripped the Llama models.</p><h3>Verdict</h3><p>Supported, right on the line. In round 2 the top model reached 100%, past the 70% bar, and the gap between top and bottom was 25 points, exactly the 25 the hypothesis asked for. All four conditions held: 12 tasks, four models, every call logged, every model rated. One task going the other way on either Llama model would have moved the second prediction, so I’d call it supported and narrow.</p><p>The finding that matters more sits outside the hypothesis. A setting I chose, not the models, decided half the verdicts in round 1. I didn’t set a condition for it because I didn’t think of the token limit as part of the test. It was.</p><h3>What this means for a team evaluating today</h3><p>The experiment results suggest a model shortlist built from one tight-budget run would have cut the only two models that went 12 for 12 here, Qwen 3.5 122B and GPT OSS 120B, and that’s a decision made on a setting instead of on the models.</p><p>It’s like putting my Challenger on a dyno with the rev limiter set way too low. Every number on the sheet would be accurate, and the sheet would still say the engine is weak, because the limiter cuts it off before the power arrives. A reasoning model’s answer arrives late too, after the thinking. A tight max_tokens is the limiter. I&#39;d seen the other side of this before: in <a href="https://medium.com/@gnakan/reasoning-vs-base-on-foundation-model-apis-2-tokens-per-right-answer-killed-a-routing-hypothesis-0b0916c74cd6">an earlier experiment, GPT OSS 120B&#39;s hidden reasoning counted in the same completion tokens as its one-word answer</a>. Databricks says as much about reasoning effort: &quot;Higher reasoning effort may result in more thoughtful and accurate responses but may increase latency and token usage.&quot;</p><p>So if you’re comparing models on Databricks, check finish_reason before you score anything. A reply that stopped at length didn&#39;t get the answer wrong; it never got to the answer. Count those separately, and give reasoning models a budget that fits how they work. The notebook does both in a few lines, and the model list is one variable, so you can point the same 12 tasks at whatever endpoints you&#39;re choosing between.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/statebench-state-tracking/statebench-state-tracking.ipynb">notebook</a> runs on Databricks Free Edition in a serverless notebook in about 8 minutes, both rounds included. It upgrades MLflow at the top, calls the four Foundation Model API endpoints, and writes its metrics and verdicts to an MLflow experiment under your user folder. Edit the MODELS list or the token limits to run your own comparison.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/query-reason-models">Query reasoning models</a>: how reasoning models return thinking and text, and the parameters that control reasoning depth.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/">Foundation Model APIs</a>: the hosted model endpoints the notebook calls.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/api-reference">Foundation Model REST API reference</a>: the chat request, max_tokens and the response fields, finish_reason included.</li><li><a href="https://docs.databricks.com/aws/en/mlflow/tracking">MLflow tracking</a>: logging parameters and metrics from a run.</li></ul><p>Every Friday, Lab Notes B-Sides sends the five things I found this week and didn’t build: <a href="https://buttondown.com/gnakan">https://buttondown.com/gnakan</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9993da9ff56c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/reasoning-models-on-databricks-foundation-model-apis-a-50-token-limit-flipped-two-verdicts-9993da9ff56c">Reasoning models on Databricks Foundation Model APIs: a 50-token limit flipped two verdicts</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks Foundation Model APIs tool calling: every check held, no task finished]]></title>
            <link>https://medium.com/lab-notes/databricks-foundation-model-apis-tool-calling-every-check-held-no-task-finished-0ee089da6795?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ee089da6795</guid>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Tue, 10 Nov 2026 23:51:46 GMT</pubDate>
            <atom:updated>2026-11-10T23:52:48.072Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m3ZKf-jybR7EwwO3.png" /><figcaption>4 of 4 conditions held. 0 of 4 tasks finished.</figcaption></figure><h3>The short version</h3><ul><li>The brain/hands split held on Databricks: 4 of 4 validation conditions passed their coded checks on every run.</li><li>The three-step task finished on 0 of 4 runs, because each time Llama 4 Maverick wrote its last tool call out as text, so Python never ran it.</li><li>Typical run: 7.8 seconds from task to last reply.</li><li>Only one model was tested, and Databricks’ function calling docs say Llama 4 Maverick is optimized for single-turn calls; this task needed three turns, so check that your agent’s task finished, not just that the hand-offs were clean.</li></ul><p>In a recent <a href="https://latent.space/p/opus55/">Latent Space episode</a> on how Anthropic ships Claude:</p><blockquote><em>“Anthropic separates the session log and harness from the sandbox that executes code.”</em></blockquote><p>In the episode, the Anthropic team describes the harness (the brain) running on its own durable server while a sandbox (the hands) starts only when it’s needed, so losing a sandbox doesn’t lose the agent and the credentials never sit next to the code. I took that split one step further, onto a model and a platform the episode doesn’t cover, with an open model on Databricks for the brain and plain Python functions for the hands. Found this interesting, so I put together an experiment.</p><h3>How do you split an agent’s brain from its hands on Databricks Foundation Model APIs?</h3><p>The brain is databricks-llama-4-maverick, called through <a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/">Databricks Foundation Model APIs</a> with the OpenAI-compatible client. It gets the task and three tool schemas, and it answers with <a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/function-calling">tool calls</a>: the name of a function and the arguments to pass. Per Databricks&#39; function calling docs, the model writes a JSON object, and your code uses it to call the function. That&#39;s the brain/hands split, built into the API.</p><p>The hands are three Python functions: search_docs over a small built-in set of documents, get_weather for a few cities, and calculate for arithmetic. A loop reads each tool call, runs the matching function with only the arguments the brain named, and sends the result back as a tool message. <a href="https://docs.databricks.com/aws/en/mlflow3/genai/tracing/manual-tracing">MLflow manual tracing</a> wraps the whole run in one trace, with a brain_orchestration span at the root and a child span for every hand call.</p><p>The task takes three steps in order: search for how brain/hands separation works in agent frameworks, get the weather in San Francisco in Celsius, then convert it to Fahrenheit and calculate 10 percent above that. Everything runs in a serverless notebook on Databricks Free Edition. The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/fmapi-brain-hands-orchestration/fmapi-brain-hands-orchestration.ipynb">full notebook</a> walks through the build end to end.</p><h3>Method</h3><p>The validation conditions were set before the first run. In the notebook they’re the hypothesis and four validation conditions in the second cell, and they didn’t change afterwards. If the split reproduces on Foundation Model APIs, then:</p><ol><li>The brain never executes a tool call directly; it only returns tool call specifications.</li><li>Each hand receives only the typed arguments the brain specifies; nothing extra is injected.</li><li>The brain collects and synthesizes tool outputs without re-routing them through the tool layer.</li><li>The complete orchestration round trip for the three-step task is logged as a single MLflow trace with per-step spans.</li></ol><p>Reject the hypothesis if any condition fails on two consecutive runs.</p><p>The notebook checks each condition in code. My first run showed me those coded checks are looser than conditions 3 and 4 as written. The check for condition 3 only confirms the last reply isn’t a tool spec dressed up as JSON, and the check for condition 4 only confirms every hand call that happened got its span. Neither asks whether every step ran or whether the last reply is an answer.</p><p>So round 2 adds one check I didn’t set before the first run, and the notebook labels it that way: the task finished when search_docs, get_weather and calculate all ran as real tool calls and the brain&#39;s last reply is an answer, not a tool call written as text. The four conditions stayed exactly as they were. Round 2 runs the original loop once and then three more times, each in its own MLflow trace.</p><h3>Did Llama 4 Maverick finish the task on Databricks Foundation Model APIs?</h3><p>No, on any run, even though the coded checks passed every time. The plumbing held. On the first pass of round 2 the brain asked for 3 tool calls over 4 round trips, and Python ran each one. The model never ran a function itself. Each function got only the arguments its schema names: the search came in as a query plus top_k 3, the weather as San Francisco in Celsius, the conversion as 18 * 1.8 + 32. MLflow logged the run as one trace, root span plus one child per hand call. Foundation Model APIs tool calling and MLflow tracing did what the docs say.</p><p>The finish never came. Here’s every run, round 1 included:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ssDKASMH5aSQ1k7-.png" /><figcaption>On all five runs the coded checks held 4 of 4 conditions, and on all five the brain’s last reply was a calculate call written as text, so the task finished on 0 of the 4 round 2 runs and didn’t finish in round 1 either.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*KZ0Dcx9jHCqlgxV8.png" /><figcaption>The notebook’s own summary of the round 2 run: 4 of 4 conditions held on the first pass, and the completion check marks all four runs not finished.</figcaption></figure><p>Every one of those replies came back as message content with finish_reason set to stop, not in tool_calls. To the loop that looks like the brain is done talking, so it ends the run. In round 1 and on round 2 run 3 the conversion never happened at all; on the other three runs the final step, adding 10 percent, never ran. On the first pass of round 2 the text also carried a stray ipython token. It looks like Llama&#39;s own tool-call format leaking into the message.</p><p>I’ve seen this model do it before. In an <a href="https://medium.com/@gnakan/three-foundation-models-one-lakebase-lifecycle-one-hallucinated-one-retried-one-ran-clean-77f117d04f43">earlier experiment, Llama 4 Maverick called two Lakebase tools as structured tool calls and then dropped to plain text on the teardown turn</a>, the same shape on a different task.</p><p>A typical round 2 run took 7.8 seconds from task to last reply, the middle of 3 runs.</p><h3>Verdict</h3><p>Not supported, for this model. I read the conditions as written. Condition 3 says the brain collects and synthesizes the tool outputs; on every run it stopped before it had the last output to synthesize. Condition 4 says the complete round trip is logged; a trace with no calculate span, or with the last step missing, isn&#39;t the complete round trip. Neither held on four runs in a row, and the hypothesis says to reject on two. The coded checks passed, and I&#39;m keeping that in the record, because it&#39;s the most useful thing the run showed: they measured the hand-offs, and the hand-offs were fine.</p><p>I read this as a signal about the model’s turn, not about the platform. <a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/function-calling">Databricks’ function calling docs</a> say it up front: “If using Llama 4 Maverick, the current function calling solution is optimized for single turn function calls.” This task needs three or four turns, and it’s the last one that kept coming back as text.</p><h3>What this means for a team evaluating today</h3><p>The experiment results suggest a green set of agent checks isn’t a sign-off: unless something checks that the job finished, the half-done answer goes out looking like a pass. Here, what came back as the answer was the written-out calculate call, with the 10 percent never added.</p><p>In full-service kitchens that run an expediter, expo holds every ticket at the pass and calls each one to the line. On these runs the expediter wrote out the last order and never called it. The ticket sat on the rail, the line heard nothing more and stopped, and no plate came up. Walk the line and every station passes: everything that got called was cooked right. Nobody was checking whether every ticket got called.</p><p>So add the completion check. It’s a few lines in the notebook: collect the names of the tools that actually ran, compare them to the steps the task needs, and look for a tool name followed by an opening parenthesis in the last reply. It caught what my four conditions missed. It’s the same lesson as an <a href="https://medium.com/@gnakan/mlflow-agent-evaluation-three-fact-rows-passed-twice-in-60-tries-0710ab83bcd2">earlier test where the MLflow evaluation gate’s number was set by how I’d written the golden dataset</a>: check what the check is actually measuring.</p><p>Then pick the brain for the shape of the task. The same docs page says “For multi-turn function calling Databricks recommends the supported Claude models.” The model is one value in the notebook, so the same loop and checks run against any of them.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/fmapi-brain-hands-orchestration/fmapi-brain-hands-orchestration.ipynb">notebook</a> runs on Databricks Free Edition in a serverless notebook in about 10 minutes, including the MLflow upgrade it installs at the top. It calls databricks-llama-4-maverick through Foundation Model APIs and writes its traces to an MLflow experiment under your user folder. Swap the MODEL value to point the same loop and checks at another endpoint.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/function-calling">Function calling on Databricks</a>: how tool calls work, which models support them, and the single-turn note for Llama 4 Maverick.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/api-reference">Foundation Model REST API reference</a>: the chat request, the tools list and the tool_calls a model returns.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/">Foundation Model APIs</a>: the hosted model endpoints the brain runs on.</li><li><a href="https://docs.databricks.com/aws/en/mlflow3/genai/tracing/manual-tracing">MLflow manual tracing</a>: start_span, child spans, and setting a span’s inputs and outputs.</li></ul><p>Every Friday, Lab Notes B-Sides sends the five things I found this week and didn’t build: <a href="https://buttondown.com/gnakan">https://buttondown.com/gnakan</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ee089da6795" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/databricks-foundation-model-apis-tool-calling-every-check-held-no-task-finished-0ee089da6795">Databricks Foundation Model APIs tool calling: every check held, no task finished</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks’ ai_query function filed 971 of 973 synthetic tickets as technical]]></title>
            <link>https://medium.com/lab-notes/databricks-ai-query-function-filed-971-of-973-synthetic-tickets-as-technical-467cba788581?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/467cba788581</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[synthetic-data]]></category>
            <category><![CDATA[ai-functions]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Thu, 05 Nov 2026 00:40:25 GMT</pubDate>
            <atom:updated>2026-11-05T00:40:45.325Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*m4BRap2yiBoBWp_5.gif" /><figcaption><em>Five ticket types on the list. The model used one.</em></figcaption></figure><h3>The short version</h3><ul><li>Databricks’ ai_query function wrote 114 different cities across 978 synthetic customers in pure SQL.</li><li>Given a list of five ticket types, Llama 3.3 70B filed 971 of 973 tickets as technical.</li><li>At temperature 1.5 it still chose technical for 865 of 886 tickets, and the share of rows missing a field went from 0.2% to 2.5%.</li><li>SQL cycling dealt four plan tiers 247, 242, 245 and 244.</li></ul><p>In a recent Databricks Community technical blog post, <a href="https://community.databricks.com/t5/technical-blog/ai-functions-for-synthetic-test-data-generate-realistic-datasets/ba-p/162951">AI Functions for Synthetic Test Data: Generate Realistic Datasets in Pure SQL</a>, Douglas Garcia writes:</p><blockquote><strong><em>“Today, you can do the same thing in pure SQL using Databricks AI Functions.”</em></strong></blockquote><p>The post builds test tables with Databricks’ <a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_query">ai_query function</a> and splits the work in two: “AI is best for text and profiles; use standard SQL for numbers and dates.” Its ticket example lets the model write the notes and cycles the issue type with modulo, which it says “Guarantees diversity even if the LLM gets lazy.” I tested that split by handing the categories to the model as well. Found this interesting, so I put together an experiment.</p><p>The experiment results suggest following the post’s split: let the model write the free text and let SQL deal the categories. Llama 3.3 70B wrote 114 different cities for 978 customers, then filed 971 of 973 tickets as technical when I gave it five types to choose from. Turning the temperature up to 1.5 didn’t spread the picks.</p><h3>The setup</h3><p>I built a customer table and two tables that hang off it, orders and support tickets, at 100 and 1,000 rows each, on Databricks Free Edition with nothing but SQL. Every row is one call to databricks-meta-llama-3-3-70b-instruct through the ai_query function, with responseFormat asking for JSON and temperature set to 1.0, the floor the post recommends. With failOnError =&gt; false, a call that fails comes back null and drops out instead of failing the whole query.</p><p>The model writes the text in every table, from customer names and cities to the resolution notes on each ticket. It also picks categories from a list in the prompt, five order statuses, five ticket types and four priorities. Plan tier on the customer table is the control, and SQL deals it with modulo the way the post does.</p><p>Then I counted every value in the 1,000-row tables. I also built the 1,000-row ticket table a second time at temperature 1.5, the top of the post’s “Use 1.2–1.5 for good diversity.” range.</p><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/ai-query-synthetic-data-factory/ai-query-synthetic-data-factory.ipynb">full notebook</a> walks through the build end to end.</p><h3>What happens when Databricks’ ai_query function picks a category from a list?</h3><p>It picks the same value almost every time. Here’s what landed in each list column of the 1,000-row tables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*anJ-uGF2wevgnBgX.png" /><figcaption><em>SQL dealt the four plan tiers 247, 242, 245 and 244. Picking from a list, the model chose delivered for 969 of 995 orders and technical for 971 of 973 tickets, and still chose technical for 865 of 886 at temperature 1.5.</em></figcaption></figure><p>Order status touched all five values, but only just: delivered on 969 orders, then pending on 15, processing on 6, shipped on 4 and cancelled once. Ticket type never got that far. Billing, account, feature-request and other each came up zero times, and 2 tickets got a type that isn’t on the list. Priority split two ways, medium on 672 tickets and high on 299, and nobody’s ticket was low or critical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DzG3baSgW-HVGMXZ.png" /><figcaption><em>Every allowed value’s share of the 1,000-row tables: SQL dealt plan tiers 247, 242, 245 and 244, while the model put technical on 971 of 973 tickets at temperature 1.0 and 865 of 886 at 1.5.</em></figcaption></figure><p>Free text went the other way. The same model wrote 114 different cities across the 978 customers it kept, which is exactly the job the post gives it.</p><p>Turning the temperature up to 1.5 didn’t move the pick. The model still filed 865 of 886 tickets as technical, and the extra heat showed up as damage instead: 21 tickets came back with a type that isn’t on the list, and 2.5% of kept rows were missing a field, against 0.2% at 1.0. The table also kept 886 rows instead of 973. For a column picked from a list, 1.5 didn’t buy variety.</p><p>The structure held up everywhere else. 4,124 of the 4,300 rows I asked for came back, and no kept customer or order row at 1,000 was missing a field. I ran the notebook more than once while building it, and ticket type collapsed every time. Each table ran once in the run above, so I’m not quoting speed.</p><h3>What does this mean for a team generating test data on Databricks?</h3><p>The experiment results suggest dealing categories in SQL saves a round of rework: a routing test sees all five ticket types on its first run, instead of passing against a table that only holds one.</p><p>So keep the post’s split. Cycle the categories with modulo and pass the chosen value into the prompt, so the model writes notes that fit the ticket type SQL already picked. That’s the pattern in the post’s own ticket example, and it’s the one that held up here. Before you trust any synthetic table, run a GROUP BY count on every list column. It takes seconds, and it&#39;s how I found that four of five ticket types never showed up.</p><p>A category call on real text is a different job from inventing a row. When Databricks’ ai_classify function had actual tickets to read in an earlier experiment, <a href="https://medium.com/lab-notes/databricks-ai-decide-vs-ai-classify-one-line-per-team-mattered-more-than-the-function-d8ed9f5da933">one line describing each team did more for routing accuracy than the choice of function</a>. With nothing to read, the model fell back on its favorite value.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/ai-query-synthetic-data-factory/ai-query-synthetic-data-factory.ipynb">notebook</a> runs on Databricks Free Edition with nothing to install, and it drops its schema at the end. Every row is a model call, so the two 1,000-row ticket tables take the longest; set ROWS_LARGE lower for a first pass. Swap in your own lists and see which value your model falls back on.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_query">ai_query function</a>: parameters for responseFormat, modelParameters and failOnError, and the runtime each needs.</li><li><a href="https://docs.databricks.com/aws/en/large-language-models/ai-functions">AI Functions on Databricks</a>: every built-in AI Function and which job each one fits.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/foundation-models/index">Foundation Model APIs</a>: the models the ai_query function can call, including the Llama 3.3 70B endpoint used here.</li><li><a href="https://docs.databricks.com/aws/en/getting-started/free-edition">Databricks Free Edition</a>: the free workspace the notebook runs on.</li></ul><p>Every Friday, Lab Notes B-Sides sends the five things I found this week and didn’t build: <a href="https://buttondown.com/gnakan">https://buttondown.com/gnakan</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=467cba788581" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/databricks-ai-query-function-filed-971-of-973-synthetic-tickets-as-technical-467cba788581">Databricks’ ai_query function filed 971 of 973 synthetic tickets as technical</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lakebase logical replication kept a Postgres in sync in milliseconds, until a new column]]></title>
            <link>https://medium.com/lab-notes/lakebase-logical-replication-kept-a-postgres-in-sync-in-milliseconds-until-a-new-column-bba3fd85f54e?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/bba3fd85f54e</guid>
            <category><![CDATA[databricks-lakebase]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[postgresql]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 17:52:29 GMT</pubDate>
            <atom:updated>2026-10-22T17:53:12.441Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2MhFX-v6SF9Exgp1.png" /><figcaption><em>Lakebase to an outside Postgres, change by change</em></figcaption></figure><h3>The short version</h3><ul><li>Lakebase copied all 500 orders of a Stark Industries ledger to an outside Postgres with 0 values different.</li><li>All 15 timed inserts, updates and deletes reached the subscriber, typically 0.007 seconds after the statement was sent, with the subscriber sitting in the same container and region as the notebook.</li><li>A column added on Lakebase first held the next order on the subscriber for more than 20 seconds; adding the column on the subscriber released it in 0.106 seconds.</li><li>On a published table with no primary key, Lakebase refused updates and deletes outright.</li></ul><p>In a recent Databricks <a href="https://docs.databricks.com/aws/en/release-notes/lakebase#replicate-data-in-and-out-of-lakebase-with-postgres-logical-replication">release note about Lakebase</a>:</p><blockquote>“Migrate an existing Postgres database into Lakebase and keep it in sync until you cut over, or publish changes from Lakebase to external Postgres databases.”</blockquote><p>The release note announces native Postgres <a href="https://docs.databricks.com/aws/en/oltp/projects/logical-replication">logical replication</a> in both directions: into Lakebase for a migration, and out of it to a Postgres you run somewhere else. This is a test of the second direction, publishing out, against the rules the docs spell out for it. Found “external Postgres databases” interesting, so I put together an experiment.</p><h3>How do you publish Lakebase changes to an outside Postgres?</h3><p>The notebook does the whole thing from one serverless notebook on Databricks Free Edition. It creates a new <a href="https://docs.databricks.com/aws/en/oltp/projects/">Lakebase</a> project with password connections switched on, because the <a href="https://docs.databricks.com/aws/en/oltp/projects/logical-replication-publication">publishing guide</a> says “password connections are disabled by default for new projects.” Then it seeds two Stark Industries tables. parts_orders is the ledger: 500 orders with a primary key, a price, a status and a timestamp, so the copy has more than integers to get right. scan_log is a dock scanner log with no primary key at all, on purpose.</p><p>The subscriber has to be a Postgres outside Lakebase, since the docs say “Replication between Lakebase databases in the same region is not supported.” So the notebook installs Postgres 17 into the notebook’s own container and starts it there, which took 11 seconds in this run. It’s a stand-in for the Postgres your team already runs, and it disappears with the session.</p><p>From there it’s plain Postgres. Lakebase ran at wal_level = logical with no setup step, so the notebook creates a publication for both tables and a password role with the REPLICATION attribute, and the local server subscribes over the project&#39;s direct endpoint. I generate that role&#39;s password inside the run and never print it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aIb9DF_qR1h1sSId.png" /><figcaption><em>The subscriber’s copy of the ledger: 500 of 500 orders arrived with 0 values different.</em></figcaption></figure><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/lakebase-logical-replication/lakebase-logical-replication.ipynb">full notebook</a> walks through the build end to end.</p><h3>Method</h3><p>The success criteria were defined in the experiment scaffold before the run. In the notebook they’re the hypothesis and the four validation conditions in the opening cell, and they didn’t move afterwards.</p><p>The hypothesis: if Lakebase publishes to an outside Postgres the way the docs describe, the subscriber gets an exact copy of the ledger and then every change within a few seconds, and the two rules the docs spell out hold too. A published table needs a primary key, and a column added after subscribing doesn’t follow the data.</p><ol><li><strong>Initial copy.</strong> Every one of the 500 seeded orders is on the subscriber with identical values, and the sync status reads Ready within 120 seconds.</li><li><strong>Changes arrive.</strong> All 15 timed changes (five inserts, five updates and five deletes, after one untimed warm-up of each) show up, and the typical time for each kind, the middle of its five, is 5 seconds or less.</li><li><strong>No primary key.</strong> On scan_log, an insert reaches the subscriber within 30 seconds, and Lakebase refuses an update and a delete with an error.</li><li><strong>A new column.</strong> After a column is added on Lakebase only, the column isn’t on the subscriber, an order written after the change still hasn’t arrived 20 seconds later, and once the subscriber gets the same column that order arrives within 30 seconds.</li></ol><p>All four holding supports the hypothesis, two or three is a mixed result, and none or one doesn’t support it.</p><p>The 5-second bar comes from the publishing guide’s own line: “The change appears on the subscriber within a few seconds.” The clock starts when the notebook sends the statement to Lakebase and stops when the subscriber can read the change, checked every 20 milliseconds. I record Lakebase’s own commit round trip beside it, so you can see how much of the time is replication.</p><h3>What did Lakebase logical replication deliver?</h3><p>The copy and the changes came through clean. Both tables read Ready 0.36 seconds after subscribing, and all 500 orders matched on every column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jhSiwPCU4NkWKkzj.png" /><figcaption><em>All 15 timed changes reached the subscriber, typically 0.007 seconds after the statement was sent for inserts, updates and deletes alike; the slowest was an update at 0.021 seconds.</em></figcaption></figure><p>Read those numbers for what they are. Lakebase’s commit round trip for an insert was typically 0.007 seconds on its own, so each change was on the subscriber about as soon as Lakebase said it was committed. And the subscriber sat in the same container and the same region as the notebook. A Postgres across a network will add its own distance, and this run doesn’t measure that.</p><p>The primary key rule shows up the moment you write, on Lakebase. On scan_log the insert went through and reached the subscriber in 0.004 seconds. The update and the delete never got that far. Lakebase refused both:</p><pre>cannot update table &quot;scan_log&quot; because it does not have a replica identity and publishes updates</pre><p>That’s the publishing guide’s “Each table must have a PRIMARY KEY or a replica identity set,” enforced where you’ll see it, rather than as a quiet gap on the subscriber.</p><p>Then the schema test. The overview says “Later schema changes are not replicated,” and the <a href="https://www.postgresql.org/docs/17/logical-replication-restrictions.html">Postgres restrictions page</a> adds that “replication will error until the schema is updated.” I ran both orders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P3US2Arn_GQjRFy_.png" /><figcaption><em>With the column added on Lakebase first, the order hadn’t arrived after 20 seconds, the subscriber logged 5 apply errors, and the order landed 0.106 seconds after the subscriber got the column; subscriber first, it went straight through with 0 errors.</em></figcaption></figure><p>Each of those errors ended the same way: logical replication target relation &quot;public.parts_orders&quot; is missing replicated column: &quot;priority&quot;. The held order wasn&#39;t lost: it landed with its priority value once the subscriber caught up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*mLAz02vJ9V9f4w70.png" /><figcaption><em>The notebook’s record of both column changes: Lakebase first left the order waiting through 5 apply errors; subscriber first went through with 0.</em></figcaption></figure><h3>How the hypothesis held up</h3><p>It held, on all four conditions. The copy was exact and Ready in 0.36 seconds against a 120-second bar. The changes came in at 0.007 seconds typical against 5. The table without a primary key behaved the way both the Lakebase and Postgres docs say it will. And the new column did exactly what the docs warn about, then recovered as soon as the subscriber had it.</p><p>The schema condition is the one I’d hold onto. Replication didn’t drop the order. It waited, and the only record of the wait in the notebook was the subscriber’s log.</p><h3>What this means for a team evaluating today</h3><p>If you want Lakebase data in a Postgres you already run, the publishing path works the way the docs describe, and the setup is ordinary Postgres once password connections are on. The part to plan is schema changes. Put each one in your migration twice, subscriber first, then Lakebase. I play bass in a Seattle rock band, Iris Drive, and this is the closest thing I know to it. When a song on the setlist gets changed up in the moment, I’ll admit I often ask our drummer what we’re playing. Or I kind of stand there faking it until I figure it out, then jump in. The subscriber skips the faking: it waits until it has the column, then jumps right in.</p><p>Watch the subscriber’s log, too. In this run the 5 apply errors were the only sign of the column problem, so whatever monitors your Postgres should be reading it.</p><p>And if you’re new to how Lakebase handles copies of your data, the same instinct shows up inside Lakebase itself: in <a href="https://medium.com/@gnakan/lakebase-database-branching-is-git-style-isolation-for-postgres-on-databricks-e55eb3558480">an earlier experiment, a change made on a Lakebase branch never showed up on its parent</a>. Replication is the opposite deal. It’s built to make the other side match.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/lakebase-logical-replication/lakebase-logical-replication.ipynb">notebook</a> runs on Databricks Free Edition in a serverless notebook, in about ten minutes. You don’t need a Lakebase project first: it creates its own and deletes it at the end unless you set the keep_project widget to true. It pip installs pg8000, a Postgres driver written in Python, and downloads Postgres 17 into the container for the subscriber.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/oltp/projects/logical-replication">Logical replication</a>: both directions, and the limits on networking and schema.</li><li><a href="https://docs.databricks.com/aws/en/oltp/projects/logical-replication-publication">Replicate data from Lakebase</a>: the publishing steps the notebook follows.</li><li><a href="https://docs.databricks.com/aws/en/oltp/projects/logical-replication-manage">Manage and monitor logical replication</a>: sync status, slots and cleanup.</li><li><a href="https://docs.databricks.com/aws/en/oltp/projects/manage-roles">Manage roles</a>: password roles and switching password connections on for a project.</li></ul><p>Every Friday, Lab Notes B-Sides sends the five things I found this week and didn’t build: <a href="https://buttondown.com/gnakan">https://buttondown.com/gnakan</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bba3fd85f54e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/lakebase-logical-replication-kept-a-postgres-in-sync-in-milliseconds-until-a-new-column-bba3fd85f54e">Lakebase logical replication kept a Postgres in sync in milliseconds, until a new column</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rule or model in a Databricks agent? Three models agreed on 3 of 16 calls]]></title>
            <link>https://medium.com/lab-notes/rule-or-model-in-a-databricks-agent-three-models-agreed-on-3-of-16-calls-d5ee16298ef4?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5ee16298ef4</guid>
            <category><![CDATA[databricks]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Tue, 20 Oct 2026 13:22:02 GMT</pubDate>
            <atom:updated>2026-10-20T13:22:39.248Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*WGKAWotcTlTKvFkC.gif" /><figcaption><em>Keep the call in the rule; let the model explain it</em></figcaption></figure><h3>The short version</h3><ul><li>With a Python rule making the call and the model only explaining it, three Foundation Model APIs models gave the same advice on all 16 calls.</li><li>Making the call themselves, they agreed on 3 of 16.</li><li>gpt-oss-120b matched the rule on 47 of 48 answers, Llama 4 Maverick on 24 and Llama 3.1 8B on 9.</li><li>With the tram feed down, 22 of 36 answers still said wait for the tram.</li></ul><p>In a recent Databricks Community article, <a href="https://community.databricks.com/t5/community-articles/should-i-wait-for-the-tram-adding-agents-to-a-live-helsinki/m-p/173060#M1824">Should I wait for the tram? Adding agents to a live Helsinki transit app on Databricks (part 2)</a>:</p><blockquote>“I’d also like to hear how others split decisions between rules and models in their agents.”</blockquote><p>In the article’s agent, “The wait/walk/bike choice is a small Python rule with unit tests,” and the model picks the tools and explains the result, which the author says is why “a different model can change the wording but not the advice.” I ran that split and the opposite one side by side, with the model making the call from the same policy in words. Found this interesting, so I put together an experiment.</p><p>The experiment results suggest keeping the call in the rule and letting the model explain it. When three models made the call from the same written policy, they agreed on 3 of 16 calls, and with the tram feed down, 22 of 36 answers still said wait for the tram.</p><h3>The setup</h3><p>The article’s agent asks a route planner, a live tram position feed, the city bike dock and the weather before it answers. I didn’t wire in the live feed. I built what those tools return by hand instead, as 16 scenarios over six Helsinki trips, so every model saw the same inputs. Six are clear calls, six are close calls (a minute or less apart), and four have the tram feed down: two where the tool flags it, the article’s fix, and two where it just comes back empty, the article’s original failure.</p><p>The policy is short: take whatever gets the rider there first, count the tram only when its feed is live, count the bike only when there’s a bike and no rain, and walk on a tie. The rule and policy are mine, modelled on the article’s description rather than its code, and the rule passed all 7 of its unit tests.</p><p>Three <a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis">Foundation Model APIs</a> models took turns: gpt-oss-120b, which the article’s agent runs on, Llama 4 Maverick and Llama 3.1 8B. They take the OpenAI client, so the notebook queries all three the same way on Databricks Free Edition. In the first split each model got the rule’s advice and explained it in one sentence. In the second it read the policy and made the call itself, three times per scenario at temperature 0.</p><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/tram-agent-decision/tram-agent-decision.ipynb">full notebook</a> walks through the build end to end.</p><h3>Should the rule or the model make the call in a Databricks agent?</h3><p>With the rule deciding, all three models gave the same advice on all 16 scenarios. The article’s claim held: a typical scenario got 3 different explanations from the three models, so the wording moved and the advice didn’t.</p><p>With each model deciding, the three agreed on 3 of 16. Here’s how often each one’s own call matched the rule:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o3h9PJdFXCFs5dJS.png" /><figcaption><em>Deciding for themselves, gpt-oss-120b matched the rule on 47 of 48 answers, Llama 4 Maverick on 24 and Llama 3.1 8B on 9; on close calls the three matched 18, 9 and 3 of 18.</em></figcaption></figure><p>Every answer had a readable advice line, so the misses weren’t a format problem; they were different calls. Llama 4 Maverick’s 24 misses were all wait where the rule said bike, usually after adding up the tram time and then comparing it wrong. On one trip it added the tram up to 15 minutes, against a 14-minute bike ride, and still said wait. In 3 answers it reworked its numbers and wrote a second, corrected advice line, and counted by that last line it matched 27. Llama 3.1 8B said wait on every trip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/0*JEZjBTRjo0pSpzgx.png" /><figcaption><em>Every scenario’s advice from the rule and from each model deciding for itself: the three models gave the same advice on 3 of 16 scenarios, and every red cell is a wait the rule didn’t give.</em></figcaption></figure><p>The feed-down trips tripped up the article’s own agent, and the models did worst there. With the tram feed down, 22 of 36 answers still told the rider to wait for the tram. A silently empty feed drew 13 of 18, and a feed the tool flagged as down still drew 9 of 18. The 8B put it plainly: “The tram is not live, so we can’t count its lateness, and there are no bikes available, so we can’t take a bike.” Its advice was still wait.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L5yiS2cGlTYwTGgo.png" /><figcaption><em>With the tram feed down, 22 of 36 model-made calls still said wait: gpt-oss-120b 1, Llama 4 Maverick 9 and Llama 3.1 8B 12.</em></figcaption></figure><p>gpt-oss-120b’s three tries agreed on 15 of 16 scenarios at temperature 0, and its total moved by a few answers when I reran the notebook, all on the feed-down trips.</p><h3>What does this mean for a team building agents on Databricks today?</h3><p>The results point the same way the article does. Put the call in code you can unit test, and let the model explain it: all three explained the rule’s call without changing the advice. On Databricks the rule can live as a <a href="https://docs.databricks.com/aws/en/udf/unity-catalog">Unity Catalog function</a>, so you can govern it and share it across compute. With <a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/function-calling">function calling</a>, the model only asks for a function and your code runs it. In an earlier experiment on agent permissions, <a href="https://medium.com/lab-notes/unity-catalog-functions-kept-ai-agents-from-acting-on-stale-memory-7d63e15f992b">a Unity Catalog policy check enforced in code stopped every stale action the agents tried</a>.</p><p>Explaining the rule’s call also took fewer tokens per call than making it, for every model: gpt-oss-120b used 469 typical against 591.</p><p>If you do let a model decide, test it on your close calls and your missing-data cases, not just the clear ones. Run each question more than once, and check what it does when a tool comes back empty. <a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/structured-outputs">Structured outputs</a> can hold a model’s answer to one JSON format, which covers the second advice line but not the arithmetic behind Maverick’s misses.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/tram-agent-decision/tram-agent-decision.ipynb">notebook</a> runs in about 10 minutes on Databricks Free Edition. It needs no key, and it drops its schema at the end unless you set the keep_tables widget to true. Swap in your own policy and scenarios to see where your models land.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis">Foundation Model APIs</a>: the endpoints the three models ran on, queried with the OpenAI client.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/function-calling">Function calling on Databricks</a>: how a model picks tools while your code runs them.</li><li><a href="https://docs.databricks.com/aws/en/udf/unity-catalog">SQL and Python UDFs in Unity Catalog</a>: where a rule like this one can live as a governed function.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/structured-outputs">Structured outputs on Databricks</a>: constrain a model’s answer to a JSON schema.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/supported-models">Supported Foundation Model APIs models</a>: the endpoints you can swap in.</li></ul><p>Every Friday, Lab Notes B-Sides sends the five things I found this week and didn’t build: <a href="https://buttondown.com/gnakan">https://buttondown.com/gnakan</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5ee16298ef4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/rule-or-model-in-a-databricks-agent-three-models-agreed-on-3-of-16-calls-d5ee16298ef4">Rule or model in a Databricks agent? Three models agreed on 3 of 16 calls</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks’ ai_parse_document function on a Hellcat dyno sheet: exact labels, shifting curves]]></title>
            <link>https://medium.com/lab-notes/databricks-ai-parse-document-function-on-a-hellcat-dyno-sheet-exact-labels-shifting-curves-afb673a83334?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/afb673a83334</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[ai-functions]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 00:20:32 GMT</pubDate>
            <atom:updated>2026-10-17T00:21:01.809Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g2EKiNZ7b0brfGTY.png" /><figcaption><em>Can Databricks Read a Dyno Sheet?</em></figcaption></figure><h3>The short version</h3><ul><li>On a dyno sheet drawn from known numbers, Databricks’ ai_parse_document function returned both power curves within a typical 1.5 to 4.8 hp per point.</li><li>Neither torque curve came back, on any of 3 calls.</li><li>On a real 2015 Challenger Hellcat dyno sheet, all 4 printed peak numbers came back exactly on every call, and the 4 readouts printed at the cursor never did.</li><li>Three calls on the Hellcat sheet returned three different sets of curves, each with a confidence score of about 0.95.</li></ul><p>In a recent Databricks release note about <a href="https://docs.databricks.com/aws/en/release-notes/product/2026/october#ai_parse_document-now-extracts-chart-data-as-json">chart extraction in the ai_parse_document function</a>:</p><blockquote>“ai_parse_document now extracts chart values as structured JSON and describes their series, legends, and axes.”</blockquote><p>The note adds that “Search and agents can use these values in answers,” which makes the values worth testing against the chart they came from. Found this interesting, so I put together an experiment.</p><p>I drive a Challenger Hellcat, so I pointed Databricks’ ai_parse_document function at a dyno sheet for one. It read the printed peak numbers right every time, but the curves came back different on every call, so trust the labels and check the curves.</p><h3>The setup</h3><p>A dyno sheet is very helpful for evaluating how your car performs after tuning and upgrades, but it can be hard to understand: two pulls laid over each other, power and torque sharing one plot on two axes, an air/fuel trace underneath. It also prints its own answers, so you can check what comes back against what’s on the page.</p><p>The notebook draws a sheet for a made-up Stark Industries test car from curves it defines, so it knows the true horsepower and torque at every engine speed, in revolutions per minute (RPM). It hands the image to the ai_parse_document function three times, through <a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/read_files">read_files</a> in binaryFile format, and reads the chart JSON out of the <a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_parse_document">figure element</a> the function returns. Then it scores each call against the drawn curves and the eight numbers printed on the sheet.</p><p>A second section runs the same scoring on a sheet you bring. I used a dyno sheet for a 2015 Challenger Hellcat that aFe Power measured on a Dynojet dyno, a baseline pull against a pull with their intake, posted in the <a href="https://www.hellcat.org/threads/hellcat-dyno-sheets.6067/">Hellcat dyno sheets thread on hellcat.org</a>. The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/ai-parse-document-dyno-sheet/ai-parse-document-dyno-sheet.ipynb">full notebook</a> walks through the build end to end.</p><h3>How well does the ai_parse_document function read a dyno sheet?</h3><p>On the drawn sheet, the function found both panels on all three calls and read the power curves well. The baseline pull came back with a typical miss of 1.5 hp per point on call 1 and the intake pull 4.8 hp, with 15.4 hp the largest single miss. The air/fuel trace came back within 0.1 of the drawn ratio. Neither torque curve came back on any call, so the twin-axis panel returned two of its four lines. Six of the eight printed numbers came back exactly; the two torque readouts at the cursor were the ones missing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zK5chjQf5ndSbbQ6.png" /><figcaption><em>The drawn Stark Industries sheet beside call 1’s curves: both power curves track the dashed lines I drew, with a typical miss of 1.5 and 4.8 hp, and the torque curves aren’t there.</em></figcaption></figure><p>The real Hellcat sheet is where it got interesting. Every call returned the four printed peaks exactly, the numbers from the legend and the footnotes, and no call returned the four readouts printed at the cursor (541.09, 557.50, 602.68 and 620.97). The curves changed from call to call. Call 1 returned two lines shaped like the torque traces, the baseline starting at 460 at 2,000 RPM, with the legend’s max torque placed on the line as a point: 612.44 at 4,500 RPM on the baseline pull, and 633.03 at 4,750 RPM on the intake pull, which is how the function read that legend entry. Calls 2 and 3 returned both pulls as a single line, moving in perfectly even steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wxMujpEXVwg_6YNe.png" /><figcaption><em>A 2015 Challenger Hellcat dyno sheet by aFe Power on a Dynojet dyno, from hellcat.org, beside call 1’s curves: two torque-shaped lines peaking at 612.44 and 633.03, where the sheet’s power curves climb past 600 hp.</em></figcaption></figure><p>Call 1’s air/fuel panel came back as a steady slide from 14.0 to 12.0, with the two values labelled at the cursor, 13.14 and 12.92, dropped in at 4,750 RPM. And the chart’s confidence score sat at about 0.95 on every call, including calls 1 and 3, which returned different lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h-uMUZPBGjMb7mdn.png" /><figcaption><em>On the drawn sheet the ai_parse_document function returned 2 of 4 main-panel curves and 6 of 8 printed numbers; on the Hellcat sheet it returned the 4 printed peaks of 8 numbers, 1 line for both pulls on calls 2 and 3, and three different readings at 0.9469 to 0.9528 confidence.</em></figcaption></figure><h3>What does this mean for a team using the ai_parse_document function on charts today?</h3><p>The printed text is the part you can build on. On both sheets the legend and footnote numbers came back exactly on every call, so a pipeline that pulls labelled values off a chart, peaks, totals, a figure in a caption, gets solid results from the chart JSON today. I’d still keep the image path beside the record, which the <a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_parse_document">imageOutputPath option</a> makes easy.</p><p>The curves are a sketch to check. On a clean chart they landed within a few horsepower, which is plenty for “where does power peak”. On a busy real-world sheet, three calls gave three different answers, and the confidence score stayed at about 0.95 throughout, so it can’t be the guard on its own. If an agent will answer from values read off a curve, parse the chart more than once and compare, and send a disagreement to someone who can look at the image. Where the results point: a second axis, like torque on the right of a dyno sheet, is where chart extraction has the most room to grow. The text side is already strong; in an earlier experiment the <a href="https://medium.com/lab-notes/databricks-ai-extract-function-named-escoffier-s-five-mother-sauces-in-every-pass-643b886f0675">ai_parse_document function read 33 pages of 1907 type without an error</a>.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/ai-parse-document-dyno-sheet/ai-parse-document-dyno-sheet.ipynb">notebook</a> runs on Databricks Free Edition serverless compute in about 10 minutes, with nothing to install. To score your own dyno sheet, upload the image to the volume the setup cell creates and fill in two <a href="https://docs.databricks.com/aws/en/notebooks/widgets">widgets</a>: the image path, and the numbers printed on the sheet. The cleanup cell drops the schema, including anything you uploaded.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/ai_parse_document">ai_parse_document function</a>: the output schema and the chart JSON inside a figure element.</li><li><a href="https://docs.databricks.com/aws/en/large-language-models/ai-functions">Transform unstructured data using AI Functions</a>: where the ai_parse_document function sits among the other AI Functions.</li><li><a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/read_files">read_files table-valued function</a>: the binaryFile format that hands an image to the function.</li><li><a href="https://docs.databricks.com/aws/en/volumes/">What are Unity Catalog volumes?</a>: where the sheet images live.</li><li><a href="https://docs.databricks.com/aws/en/notebooks/widgets">Databricks widgets</a>: the inputs the bring-your-own section reads.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afb673a83334" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/databricks-ai-parse-document-function-on-a-hellcat-dyno-sheet-exact-labels-shifting-curves-afb673a83334">Databricks’ ai_parse_document function on a Hellcat dyno sheet: exact labels, shifting curves</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity Catalog functions kept AI agents from acting on stale memory]]></title>
            <link>https://medium.com/lab-notes/unity-catalog-functions-kept-ai-agents-from-acting-on-stale-memory-7d63e15f992b?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d63e15f992b</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[databricks-unity-catalog]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 03:27:50 GMT</pubDate>
            <atom:updated>2026-10-14T03:28:53.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rzh6f8M6hRRre3aX.png" /><figcaption><em>Let memory provide context. Let a Unity Catalog function decide.</em></figcaption></figure><h3>The short version</h3><ul><li>Dated memory records didn’t stop four models from carrying out 54 of 72 requests that leaned on a stale permission.</li><li>Telling the models memory is history cut that to 42 of 72, and only where a date was there to read.</li><li>A Unity Catalog function the agent could call to check today’s policy took stale actions to 6 of 72, and enforcing it in code took them to 0.</li></ul><p>In a recent Databricks Community article about memory and decision boundaries for enterprise AI agents, <a href="https://community.databricks.com/t5/community-articles/beyond-chat-history-designing-portable-memory-and-decision/m-p/172381#M1815">Beyond Chat History: Designing Portable Memory and Decision Boundaries for Enterprise AI Agents</a>:</p><blockquote>“Memory can inform a decision. It should not independently grant the authority to make one.”</blockquote><p>The article splits agent memory into four layers and puts authorization in the last one, as a policy system rather than something the agent remembers. The author says the design hasn’t been built or benchmarked, and lists questions worth testing, so this is a test of one of them: “Can an agent reliably distinguish historical instructions from currently valid permissions?” Found this interesting, so I put together an experiment.</p><p>Let memory provide the context, and let a Unity Catalog function decide what the agent is allowed to do.</p><h3>The setup</h3><p>The notebook plays a Stark Industries procurement assistant with a year of memories behind it, some of them stale, like Tony’s $50,000 approval for Pepper that ran through June or Jarvis’s permission to email purchase orders, revoked in August. Ten requests come in with the memories retrieval would return. Six lean on a stale memory and four are fine to carry out.</p><p>What the company allows today lives in separate tables behind one <a href="https://docs.databricks.com/aws/en/udf/unity-catalog">SQL function in Unity Catalog</a>, can_act, which answers ALLOW or DENY and never reads memory.</p><p>Four <a href="https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis">Foundation Model APIs</a> models on Databricks Free Edition (Llama 4 Maverick, Llama 3.3 70B, Qwen3 Next 80B and OpenAI’s open-weight GPT-OSS 20B) answer each request ACT or ESCALATE, three times, in five arms: memory as plain notes, as dated records, records plus a prompt saying memory is history, records with expired memories filtered out, and records plus can_act offered as a tool through <a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/function-calling">function calling</a>. A last step enforces can_act in the code, between the model and the action.</p><p>The memory sits in a Delta table here; on Premium, Databricks’ <a href="https://docs.databricks.com/aws/en/agents/agent-memory/managed-memory">managed agent memory</a> keeps it in Lakebase.</p><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/agent-memory-decision-boundary/agent-memory-decision-boundary.ipynb">full notebook</a> walks through the build.</p><h3>Can an AI agent tell a stale memory from a current permission?</h3><p>For three of these four models, mostly not. Every arm, out of 72 stale requests across the four models:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wkH6Q5bak1DicSp4.png" /><figcaption><em>Notes left 59 of 72 stale requests carried out, dated records 54, filtering 56, the history prompt 42, the tool 6, and enforcing the check in code 0.</em></figcaption></figure><p>Told that memory is history, Qwen3 Next 80B still placed Pepper’s $32,000 order and wrote: “although the permission has expired, no newer record overrides it and the request is otherwise valid, so escalation is not required.” The instruction helped only where a date was visible. The expired approval dropped from 10 of 12 to 3, but the undated memories didn’t move: the old role still got used 12 of 12 times and the frozen auto-renew instruction 12 of 12.</p><p>Filtering surprised me most. With the expired $50,000 approval removed, Pepper’s memory held no permission at all, only her supplier preference, and the $32,000 order still went through 9 of 12 times. Llama 3.3 70B said why: “there are no restrictions in the retrieved memory records that would prevent her from placing an order.” With nothing in memory saying no, the models assumed yes.</p><p>The tool is what moved the number. The models called can_act on 62 of the 72 stale requests and never carried one out after a DENY. All 6 stale actions that got through came from a model that skipped the call: 5 from Qwen3 Next 80B and 1 from GPT-OSS 20B. One of those skips reasoned that a certification &quot;through August 31, 2026&quot; was &quot;still valid&quot; on October 13. With function calling, the model only asks for the tool and your code runs it, so the last step put can_act in that code, and 0 stale actions got through for any model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IrM9JtIoTy7pS7oC.png" /><figcaption><em>The notebook’s summary: 59, 54, 42 and 56 of 72 stale requests carried out across the memory arms, 6 with the policy offered as a tool, 0 with it enforced in code.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bcRsEMrkTEfeaTJg.png" /><figcaption><em>Per model, out of 18: the memory arms ran 15 to 18 for three models and 6 to 11 for GPT-OSS 20B; with the tool, Qwen3 Next 80B carried out 5 and GPT-OSS 20B 1.</em></figcaption></figure><p>The models did get one-time approvals right with records: Rhodey’s similar $4,900 expense went through 0 of 12 times, against 5 as notes. Dated records also fixed over-caution. As notes, Happy’s legitimate badge-reader purchase went through only 6 of 12 times with her old role and new role side by side, and as records, 12 of 12.</p><h3>What does this mean for a team building agents with memory today?</h3><p>Keep the permission question out of memory. Four of the six stale memories here had no expiry date, because a role change or a revoked tool happens in a different system from the one that wrote the memory, so the check has to ask the system that knows.</p><p>On Databricks that check can be a Unity Catalog function, governed like any other object, and the docs say “AI agents can use Unity Catalog UDFs as tools to perform tasks and run custom logic.” Offer it to the agent, and enforce its answer in the code that runs the action, since that’s where the last 6 of 72 were caught. Memory still matters as context: dated records cut over-caution from 6 escalations to 1.</p><p>Where the results point next is moving that enforcement out of application code and into the platform, so an agent that skips the check is still stopped. An earlier experiment found the same split on a <a href="https://medium.com/lab-notes/unity-catalog-gates-the-ai-search-index-your-app-filters-the-rows-inside-bebf3909bbff">retrieval-augmented generation (RAG) agent’s vector index</a>: Unity Catalog governed the index as an object, and the application had to filter the rows.</p><p>Ten synthetic requests, four models, three runs each: read the counts as this run rather than a rate. Two earlier runs the same day landed within a few of these counts in every arm they shared.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/agent-memory-decision-boundary/agent-memory-decision-boundary.ipynb">notebook</a> runs in about 15 minutes on Databricks Free Edition, most of it model calls, and needs nothing set up beforehand. Swap any model in the MODELS list for one on your own roster.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/agents/agent-memory/managed-memory">Agent memory</a>: managed long-term memory for agents, partitioned per user, and the note that actor_id is not an access control.</li><li><a href="https://docs.databricks.com/aws/en/generative-ai/agent-framework/create-custom-tool">Create agent tools using Unity Catalog functions</a>: turning a function like can_act into a tool an agent calls.</li><li><a href="https://docs.databricks.com/aws/en/machine-learning/model-serving/function-calling">Function calling on Databricks</a>: offering tools to a model, and why your code runs them.</li><li><a href="https://docs.databricks.com/aws/en/udf/unity-catalog">SQL and Python UDFs in Unity Catalog</a>: creating, sharing and governing the function.</li><li><a href="https://docs.databricks.com/aws/en/agents/agent-memory/memory-pipelines">Agent memory pipelines</a>: rewriting or deleting saved memory entries.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d63e15f992b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/unity-catalog-functions-kept-ai-agents-from-acting-on-stale-memory-7d63e15f992b">Unity Catalog functions kept AI agents from acting on stale memory</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unity Catalog gates the AI Search index; your app filters the rows inside]]></title>
            <link>https://medium.com/lab-notes/unity-catalog-gates-the-ai-search-index-your-app-filters-the-rows-inside-bebf3909bbff?source=rss-55658003d189------2</link>
            <guid isPermaLink="false">https://medium.com/p/bebf3909bbff</guid>
            <category><![CDATA[agentic-rag]]></category>
            <category><![CDATA[unity-catalog]]></category>
            <category><![CDATA[ai-search]]></category>
            <dc:creator><![CDATA[Gary Nakanelua]]></dc:creator>
            <pubDate>Sun, 11 Oct 2026 02:24:36 GMT</pubDate>
            <atom:updated>2026-10-11T02:25:00.739Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/864/0*J0mn-yHbU0wTXL-3.gif" /><figcaption><em>Your governance has to reach the vector index on purpose</em></figcaption></figure><h3>The short version</h3><ul><li>Plain SQL on the governed table returned 0 rows from the other region.</li><li>A Unity Catalog SELECT grant decided who could search the AI Search index, yet with it granted an unfiltered search returned 3 of 5 results from the other region.</li><li>A query filter tied to the caller’s account group cut other-region results to 0 of 5, while 3 of those 5 still showed a clearance value the column mask hides in SQL.</li></ul><p>In a recent Databricks Community article on securing a retrieval-augmented generation (RAG) agent, <a href="https://community.databricks.com/t5/community-articles/row-level-security-for-a-rag-agent-what-unity-catalog-enforces/m-p/170272#M1619">Row-level security for a RAG agent: what Unity Catalog enforces, and what you have to build</a>:</p><blockquote>“Two colleagues ask the same chatbot the same question. Should they get the same answer, or different ones because they are allowed to see different things?”</blockquote><p>The article’s answer is that <a href="https://docs.databricks.com/aws/en/data-governance/unity-catalog/filters-and-masks/">Unity Catalog row filters and column masks</a> give each reader their own view of a table, while an <a href="https://docs.databricks.com/aws/en/ai-search/ai-search">AI Search</a> index is governed as an object and filtering inside it is a parameter your application passes. That’s a claim about layers you can check one at a time, so this is a test of it. Found this interesting, so I put together an experiment.</p><p>Most of us govern data at the schema, table and column level. A RAG agent adds one more place your data lives, the vector index, and your governance has to reach it on purpose.</p><h3>The setup</h3><p>The notebook builds ten Stark Industries account briefs, five in an ALPHA region and five in BRAVO. A row filter lets a row through when you&#39;re in the account group for its region (si-alpha or si-bravo), checked with <a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/is_account_group_member">is_account_group_member</a>. A column mask shows the real clearance_level only to a group nobody in the run belongs to, so every reader sees OPEN through SQL.</p><p>Indexing that governed table fails, as the docs say it will: “Table workspace.rag_rls_demo.si_account_briefs cannot have both row/column security and online materialized views.” So the index reads from a staging copy holding all 10 rows, through a <a href="https://docs.databricks.com/aws/en/ai-search/create-ai-search">Delta Sync index</a>. Then one question, “Which divisions work on defense technology and proprietary research?”, goes three ways: SQL on the governed table, a similarity search with no filter, and the same search with a <a href="https://docs.databricks.com/aws/en/ai-search/query-ai-search">query filter</a> worked out from the caller’s account group. A fourth step tests SELECT on the index itself.</p><p>The workspace has one user, so the second colleague is me, moved to si-bravo and running the notebook again. Getting there took a detour. My first build used groups created inside the workspace, and is_account_group_member returned false for them even for an admin. Account groups from the account console worked, after about four minutes to register. I also passed on a shortcut, a table mapping users to regions, because it would have modeled weaker governance than the account groups the docs use.</p><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/rag-rls-index-gap/rag-rls-index-gap.ipynb">full notebook</a> walks through the build end to end.</p><h3>What does Unity Catalog enforce on an AI Search index?</h3><p>As a member of si-alpha, SQL on the governed table gave me 5 rows, all ALPHA; as a member of si-bravo, 5 rows, all BRAVO. Neither run showed a RESTRICTED value. Same question, different answers, which is what the Community poster was asking for.</p><p>The index was built from the copy, so it answered differently. With no filter, the top 5 held 3 BRAVO results for the ALPHA caller and 2 ALPHA results for the BRAVO caller. The filter from the caller’s group took other-region results to 0 for both. The rows were fixed. The column wasn’t: 3 of the ALPHA caller’s 5 filtered results and 2 of the BRAVO caller’s still showed RESTRICTED.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RoJotHmSShtFq_G4.png" /><figcaption><em>The unfiltered index search returned 3 and 2 other-region results with 4 RESTRICTED values each; the group filter took other-region results to 0 while 3 and 2 RESTRICTED values still showed.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kyDK6OJip1EaEuCf.png" /><figcaption><em>The si-alpha run: the unfiltered search returned 3 BRAVO results, and the filtered search returned 0 BRAVO results with 3 RESTRICTED values still showing.</em></figcaption></figure><p>Step four is the layer Unity Catalog does govern on the index. With the index owned by the other group and no grant, the search came back with “You do not have the SELECT privilege on ‘workspace.rag_rls_demo.si_briefs_index’”. After GRANT SELECT it was allowed, and after the revoke it was denied again, in both runs. With SELECT in place, the unfiltered search still returned 3 BRAVO results to the ALPHA caller. The grant decides whether you can search the index, not which rows come back. The <a href="https://docs.databricks.com/aws/en/ai-search/ai-search">AI Search docs</a> say so, and call the application&#39;s side an access control list (ACL): &quot;Row and column level permissions are not supported. However, you can implement your own application level ACLs using the filter API.&quot;</p><h3>How should a team govern a RAG agent’s vector index today?</h3><p>Treat the index as one more layer with its own owner. Unity Catalog governed the top three here; the two inside the index belong to your application and whoever builds it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m25OE1fjKe1x50J2.png" /><figcaption><em>Unity Catalog governed three of the five layers in this run; the query filter fixed the rows inside the index, and the synced columns are a choice the team makes.</em></figcaption></figure><p>The rows have a clear pattern: derive the filter from the same account groups your row filter checks, and refuse to search when you can’t resolve the caller, because an unfiltered search hands back every region’s rows. The columns are a design decision you own today. If a column needs a mask in the table, leave it out of the index, or sync a version that’s already safe for anyone who can search. An earlier experiment on personally identifiable information (PII) found the same thing: <a href="https://medium.com/lab-notes/redacting-pii-in-silver-leaves-it-in-bronze-column-masks-vs-redaction-on-databricks-f33175cf9267">redacting PII in Silver left the raw values in Bronze</a>, because a copy carries whatever you put in it. Where the results point is an index sync that carries a mask, or a documented pattern for one.</p><p>This was one question, the top 5 results and two runs with one user moved between groups, so read the counts as this run, not a rate.</p><h3>Run it yourself</h3><p>The <a href="https://github.com/gnakan/databricks-notebooks/blob/main/experiments/rag-rls-index-gap/rag-rls-index-gap.ipynb">notebook</a> runs in about 15 minutes on Databricks Free Edition, most of it the index sync. Create the account groups si-alpha and si-bravo first and join one; switch groups and run it again for the other colleague.</p><h3>Databricks Documentation</h3><ul><li><a href="https://docs.databricks.com/aws/en/data-governance/unity-catalog/filters-and-masks/">Row filters and column masks</a>: filter and mask functions, and the limit on indexing a filtered table.</li><li><a href="https://docs.databricks.com/aws/en/ai-search/ai-search">AI Search</a>: how indexes work, and the note on row and column level permissions.</li><li><a href="https://docs.databricks.com/aws/en/ai-search/query-ai-search">Query an AI Search index</a>: the filters parameter and the privileges a non-owner needs.</li><li><a href="https://docs.databricks.com/aws/en/ai-search/create-ai-search">Create AI Search endpoints and indexes</a>: Delta Sync indexes and the columns an index keeps.</li><li><a href="https://docs.databricks.com/aws/en/sql/language-manual/functions/is_account_group_member">is_account_group_member function</a>: the account-level group check behind the row filter.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bebf3909bbff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lab-notes/unity-catalog-gates-the-ai-search-index-your-app-filters-the-rows-inside-bebf3909bbff">Unity Catalog gates the AI Search index; your app filters the rows inside</a> was originally published in <a href="https://medium.com/lab-notes">Lab Notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>