<?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 CommBank Innovation &amp; Technology Blog on Medium]]></title>
        <description><![CDATA[Stories by CommBank Innovation &amp; Technology Blog on Medium]]></description>
        <link>https://medium.com/@CommBankTechnology?source=rss-8809ccabadac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KfSDO-38jaULdBigLp7LRw.jpeg</url>
            <title>Stories by CommBank Innovation &amp;amp; Technology Blog on Medium</title>
            <link>https://medium.com/@CommBankTechnology?source=rss-8809ccabadac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 09:56:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@CommBankTechnology/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[The Missing Layer in Fine-Tuning: What the Teacher Model Needs to See]]></title>
            <link>https://medium.com/commbank-technology/the-missing-layer-in-fine-tuning-what-the-teacher-model-needs-to-see-2c4723547095?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c4723547095</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[synthetic-data]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Wed, 09 Sep 2026 03:52:52 GMT</pubDate>
            <atom:updated>2026-09-09T03:55:52.133Z</atom:updated>
            <content:encoded><![CDATA[<p><em>When a fine-tuned model gets a knowledge-heavy task wrong, the problem often isn’t the model, it’s the data prepared before training.</em></p><p>This article explores the role of knowledge representation in fine-tuning, and why the quality of synthetic training data often depends on what the teacher model is shown before generation begins.</p><p>Our AI Labs team has been experimenting with this preparation layer: how raw material can be broken into reusable atomic units, then assembled into task-ready generation units that give a teacher model the right knowledge, in the right form, at the right time.</p><p>Imagine this scenario: you’re testing a conference support chatbot the day before a demo. The source material looks complete: a registration policy, an invoice policy, a short FAQ, and a set of past support replies. You ask a realistic question:</p><blockquote>“I can’t attend anymore. Can I transfer my registration to a colleague, and can you also fix the company name on my invoice?”</blockquote><p>The chatbot answers confidently and gets it wrong.</p><p>It says the transfer can happen any time before the event, even though transfers close fourteen days before the event. It produces the wrong invoice details. It invents a one-business-day turnaround.</p><p>The uncomfortable reality was that the source documents were accurate, but the answer wasn’t. The failure didn’t begin with the model. It began with the way the knowledge was captured. The model had access to the data, but not in a form it could effectively work with.</p><h3>Knowledge representation</h3><p><strong>Knowledge representation</strong> is the process of converting raw source material into a form the model can use for a given task. It determines how knowledge is structured, connected and presented to the model. It decides what the model actually sees.</p><p>Think of a student preparing for an exam. Handing them every textbook does not guarantee a good answer. What helps is clear notes, the key rules, and worked examples, the right knowledge, in the right form, at the right time. AI systems work the same way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XTVl9MF15SBYJgWKEKnkg.png" /></figure><p>Raw data is rarely task-ready. A rule might be buried in one document, while the condition that determines when it applies is buried in another. Sources often overlap without providing a complete picture. A transcript may capture the outcome but not the reasoning behind it. As a result, the problem is rarely access to information. More often, it’s the way that information is organised.</p><p>A better design starts before the model call: break raw material into reusable pieces of knowledge, then assemble the right pieces into a task-ready input.</p><p>Synthetic data for fine-tuning makes this decision difficult to ignore. When a model only reads an input, poor representation produces a poor answer. When the same input is used for training, the effects of that representation become baked into the model’s weights.</p><h3>Atomic units: the reusable pieces of knowledge</h3><p>Before knowledge can be organised, it must be broken into reusable units. What those units look like depends on the use case: a rule, customer preference, product attribute, workflow step, constraint, relationship or exception.</p><p><strong>For the conference chatbot it might include:</strong></p><ul><li>The transfer deadline</li><li>The invoice correction requirement</li><li>The required attendee details</li><li>The separate turnaround times</li></ul><p>This is why knowledge representation is more than text-splitting. Text-splitting gives you chunks; this gives you meaning. A teacher model can do much of this work by reading messy source material, removing noise, standardising formats and consistently extracting the units that matter. The result is not more data, but cleaner, more structured knowledge.</p><h3>Generation units: preparing what the model should see</h3><p>Atomic units are the building blocks. The next question is how to assemble them for a specific task before they reach the model? A model rarely needs every document and every past example. It needs the pieces that matter, plus the relationships and constraints that help it use them correctly.</p><p>Let’s call that assembled input a <strong>generation unit</strong>. It answers one question:</p><blockquote>What does the model need to see to perform this task well?</blockquote><p>For the conference chatbot, a generation unit for a combined transfer-and-invoice request would not be two full policies and a stack of past replies. It would contain only the useful pieces:</p><ul><li>The two deadlines, kept apart</li><li>The required details for each request</li><li>The separate turnaround times</li><li>The constraint not to merge or invent conditions</li></ul><p>Rather than giving the model raw material and hoping it finds the structure, prepare the knowledge first and pass a version it can use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjNTiBsZ_ZjKP7XNO4X29g.png" /></figure><h3>Why this decides the quality of synthetic data</h3><p>This is where the representation decision stops being optional.</p><p>The common approach to synthetic data is to give a teacher model some source material or a few examples, ask it to create more training data, and fine-tune on that output. The teacher model can only build from what it is given, for example:</p><ul><li>If it sees noisy material, the generated data carries that noise forward</li><li>If it sees only surface-level examples, it copies the format without the workflow</li><li>If the knowledge is scattered across sources, it produces examples that are fluent but incomplete.</li></ul><p>So the quality of synthetic data is decided earlier than people expect, not at the generation step, but in the representation step. The solution is the approach described above, applied before generation rather than after.</p><p>The result is controlled recomposition, not random synthesis. The teacher model still generates new examples, but it does so from existing knowledge relationships, guided by the task format, and constrained by what the source supports. This creates variation while staying grounded in the original data.</p><p><strong>Knowledge fine-tuning</strong> teaches facts and rules the model does not already hold. Source material is often fragmented, with policies spread across documents and rules mentioned only once. Organising knowledge units around topical or entity-level relationships gives the teacher model a richer input, enabling it to generate QA and instruction data beyond what the original corpus could support alone.</p><p><strong>Task fine-tuning</strong> teaches a behaviour: producing the output in the right form, tone, and structure. The source example is decomposed into atomic units and recombined against an exemplar that supplies the format. Each synthetic example traces back to real data while reaching combinations the original dataset did not contain.</p><p>The AI Labs team have recently published a paper <a href="https://arxiv.org/abs/2605.19394"><strong><em>EmbGen; Teaching with Reassembled Corpora</em></strong></a><em> </em>which follows this principle — The corpus becomes more learnable by first becoming more structured. On public benchmarks, recomposing the corpus this way improved accuracy over the strongest synthetic-data baseline, with the largest gains where the knowledge was most scattered across sources.</p><p>The same pattern appears in an internal use case. An open-source model is first fine-tuned on the available data, which is noisy and limited in scope. The training data is then rebuilt from extracted knowledge units, and the same model is fine-tuned again on the reconstructed dataset. Task-quality scores increase by around 20 per cent.</p><p>The model does not change. The data does.</p><h3>From raw cases to synthetic data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HyWQkd3Ci4JKwgQyip3GIg.png" /></figure><p>Lets return to the conference support corpus, the source material is not a clean policy document but a collection of resolved support conversations: real cases that show what an attendee asked and how the issue was resolved.</p><p>A basic approach passes those conversations to a teacher model and asks it to generate more examples in the same style. This creates variation, but when the unit of generation is the entire case, the teacher model can do little more than imitate it. There is limited control over which knowledge is reused, which conditions are preserved, and which new combinations remain valid.</p><p>A representation-based approach changes the unit of generation, shifting from complete cases to the reusable concepts they contain.</p><p><strong>Step 1: entity extraction</strong></p><p>The teacher model reads each raw case and extracts the key entities. Each entity becomes an atomic unit: a short label plus an explanation of what it means and what constraints apply.</p><p>The source conversations are human-written and uneven. A transfer case might contain this raw exchange:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0wLVK5Mr72fmqf1xtdR53w.png" /></figure><p>From this exchange, the teacher model extracts a structured representation of the transfer process, including its conditions, required details and constraints.</p><p>An invoice case yields a second unit from an exchange like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aYg_jdD3TaubHyhR5Qn3TQ.png" /></figure><p>From this, the teacher extracts a unit defining the correction requirements and timelines.</p><p>Repeated across the corpus, this builds a pool of clean, reusable units.</p><p><strong>Step 2: assembling the generation unit</strong></p><p>To create a new training example, two atomic units are selected from the pool and combined with an existing support conversation that acts as a task template. The template provides the structure, tone and response format. The atomic units provide the knowledge. Together, they form the generation unit:</p><ul><li><strong><em>Atomic units:</em></strong> registration transfer + invoice correction</li><li><strong><em>Template:</em></strong> a resolved support conversation that demonstrates the expected response style</li><li><strong><em>Constraints:</em></strong> connect both requests logically, preserve the conditions, keep the timelines separate, request all required details and do not invent a new service level</li></ul><p><strong>Step 3: what the teacher model generates</strong></p><p>The teacher model is not asked to paraphrase the template or extend a source case, but to write a new scenario that integrates the two atomic units and follows a structure the template defines. The result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_mXaeyvyihZjo1WMfQ-lsw.png" /></figure><p>This scenario did not exist in the original corpus, yet every constraint traces back to an extracted unit: the knowledge from the pool, the structure from the template, the teacher model only supplying the situation that connects them.</p><p>That’s the difference between paraphrase augmentation and representation-based synthesis: new task instances the corpus never held, still grounded in it.</p><h3>Control matters as much as connection</h3><p>Assembling atomic units is useful, however it’s also risky.</p><p>A generation unit is more than a collection of related entities. It represents a decision about which pieces of knowledge can be combined to solve a specific task. Each unit also carries the conditions and assumptions of the case from which it was extracted, and those assumptions do not always survive when units are placed side by side.</p><p>Two rules can describe related events and still be incompatible. In the conference example, invoice corrections are allowed before the event date, while registration transfers close fourteen days before. Three days out, one request may still be valid and the other may not.</p><p>A generation unit that merges those rules without preserving the difference teaches the model the wrong behaviour. The source documents may be correct. The extracted units may be correct. The failure happens in the assembly.</p><p>This is why validation is part of representation, not a final clean-up step. Before units from different sources become a training instance, they must be genuinely compatible, consistent and complete enough to teach the right thing.</p><p>Finding the relationship between two rules isn’t enough, you also have to check whether combining them produces something a model can safely learn</p><h3>Representation beyond fine-tuning</h3><p>Bad representation in fine-tuning data does more damage than bad representation at inference, the mistake gets trained in rather than just returning a wrong answer once.</p><p>But the same decision should come first in any AI system that retrieves passages, maintains memory, or generates training data — What are the atomic units for this task? and what should a well-formed generation unit contain?</p><p>Answering deliberately, rather than defaulting to raw data, is what leads to practical wins — fewer unsupported answers, better coverage of edge cases, and failures that are easier to trace back to a missing unit or a bad assembly.</p><h3>Closing</h3><p>AI systems don’t operate on “data”. They operate on what we choose to show them: a retrieved passage, a memory, a chunk, a training example, a generation unit.</p><p>A model that fails to absorb a sparse rule, a retrieval system that can’t answer a corpus-level question, and an assistant that blends separate policies into one imaginary process may look like different failures. Often, they share the same root cause: knowledge reaches the model in a form it cannot use effectively.</p><p>More data, bigger models, longer context won&#39;t remove the underlying question of what the model should actually be shown.</p><p>That decision is knowledge representation.</p><p><strong>The next time an AI system gets it wrong, don’t start with the model. Start with what training data it was given to work with</strong>.</p><p><strong><em>Arun Lenin</em></strong><em> is an AI Researcher at CommBank’s AI Labs and a Kaggle Grandmaster. His work spans post-training small language models, knowledge representation in AI systems, and customer vulnerability in agentic systems.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/1*apMaPRWZ9lX4xLrTYxpUpw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c4723547095" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/the-missing-layer-in-fine-tuning-what-the-teacher-model-needs-to-see-2c4723547095">The Missing Layer in Fine-Tuning: What the Teacher Model Needs to See</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI Guardrails That Prove, Not Guess]]></title>
            <link>https://medium.com/commbank-technology/ai-guardrails-that-prove-not-guess-8b9372f8d4be?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b9372f8d4be</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[automated-reasoning]]></category>
            <category><![CDATA[aiguardrails]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 03:39:34 GMT</pubDate>
            <atom:updated>2026-08-17T00:13:33.726Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Combining language models with automated reasoning: rules written in plain English are compiled into formal logic and verified by an SMT solver, enabling decisions to be traced back to an explicit rule rather than a score.</em></p><p>AI guardrails are increasingly used to decide whether a model’s output should be allowed through, blocked, or routed to a human. Most of these guardrails are themselves models: a second LLM scores an answer, spots potential issues, or estimates whether a response is acceptable. That works well for many problems, but it has a structural weakness. The same input can pass on one occasion and fail on another, and the reasoning behind either decision is difficult to inspect.</p><p>This article describes a pattern we’ve been investigating, <strong>AI+AR</strong>: the AI proposes, maps, repairs and explains, while automated reasoning verifies. The language model does what it is good at (reading messy human language) and an SMT solver does what it is good at (evaluating logic exactly).</p><h3><strong>Scores and proofs</strong></h3><p>It helps to be precise about what a judge-style guardrail computes. Given an output <strong>y</strong>, a judge model produces a score <strong>g(y) ∈ [0, 1]</strong> and the gate applies a threshold:</p><blockquote><strong><em>verdict(y) = pass if g(y) ≥ τ, otherwise block</em></strong></blockquote><p>Everything interesting is hidden inside <strong>g</strong>. It is a learned function: stochastic under sampling, sensitive to phrasing, and opaque even to its operators. Two runs on the same input can land on opposite sides of <strong>τ,</strong> and when they do, there is no artefact you can point to that explains why.</p><p>Formal methods offer a complementary construction. Instead of asking a model whether something <em>appears</em> acceptable, we compile the rules themselves into logic and ask a sharper question: <em>is this specific claim consistent with these specific rules and facts?</em> The answer is not a score but a verdict with a certificate. Given the same rules and facts, the outcome remains the same.</p><h3><strong>The mathematics of a verdict</strong></h3><p>The construction needs three ingredients, all expressed over a shared set of typed variables <strong>x₁, …, xₙ</strong> (booleans, integers, reals, strings):</p><p><strong>1. The policy φ. </strong>A quantifier-free formula encoding the rules: boolean connectives <strong>(∧, ∨, ¬) </strong>over linear arithmetic constraints. This fragment, known as <strong>QF_LIA </strong>(quantifier-free linear integer arithmetic), is decidable: the solver always terminates with an exact answer.</p><p><strong>2. The facts F. </strong>A conjunction of ground assignments extracted from the live request, e.g. <strong><em>books_on_loan = 8 ∧ requested_books = 5.</em></strong></p><p><strong>3. The claim c. </strong>The proposition the AI’s answer commits to, e.g. <strong><em>“this borrow request is allowed”.</em></strong></p><p>Verification is then two satisfiability queries to the solver, and the pair of results partitions every claim into exactly one of three verdicts:</p><p><strong><em>F ∧ φ ∧ c and F ∧ φ ∧ ¬c (each either SAT or UNSAT)</em></strong></p><p><strong>Proved. </strong>If <strong>F ∧ φ ∧ ¬c</strong> is unsatisfiable, then every model of the facts and rules makes the claim true; in logical notation, <strong>F ∧ φ ⊨ c.</strong> The claim doesn’t merely avoid contradiction; it is entailed. The response passes.</p><p><strong>Refuted. </strong>If <strong>F ∧ φ ∧ c</strong> is unsatisfiable, the claim contradicts the rules. Crucially, the solver returns an <em>unsat core</em>, a minimal subset of conjuncts that cannot hold together, which names the violated rule. The response is held for repair.</p><p><strong>Ambiguous. </strong>If both queries are satisfiable, the policy genuinely permits both outcomes: the rules are silent on this case. Rather than failing quietly, the system says so and routes the case to review. Under-specification becomes a detectable condition, not a silent coin flip.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kr8jZ8FwRPU9u8MtqDGVAA.png" /><figcaption>Two satisfactory checks partition every claim into exactly one of three verdicts, each mapped to a gate action.</figcaption></figure><p>Two properties follow immediately. <strong>Determinism: </strong>the verdict is a function of the triple <strong>(φ, F, c)</strong> alone; rerunning the check cannot change the answer. <strong>Explainability: </strong>a refutation always carries a certificate locating the disagreement in specific, named rules. Neither property is available from a threshold over a learned score.</p><h3><strong>How it works</strong></h3><p>The pipeline splits the labour along the line where each technology is trustworthy. Everything probabilistic happens on the AI side of the boundary; everything on the AR side is exact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dGYxe5fGTBiAJypLatCkEg.png" /><figcaption>The AI+AR pipeline: the language model reads messy human language; the solver evaluates logic exactly</figcaption></figure><ol><li><strong>Write the rules in plain English. </strong>We use a deliberate toy example throughout: <strong><em>“Borrowers need an active library membership, nothing overdue, and at most 10 books out at once.”</em></strong></li><li><strong>Compile to formal logic. </strong>An LLM extracts typed variables and rules from the text and structures them as machine-verifiable logic, compatible with the CVC5 SMT solver.</li><li><strong>Store as structured, versioned JSON. </strong>Human-readable, diffable, easy to review. Every change bumps the version.</li><li><strong>Verify real claims against it. </strong>When the AI answers a question, the claim and the facts are mapped into the policy’s variables and the solver runs the two satisfiability checks.</li><li><strong>Gate the response. </strong>Proved claims proceed. Refuted claims are held back for repair with the violated rule explicitly named. Ambiguous claims go to review.</li></ol><h3><strong>A worked example</strong></h3><p>The library policy compiles to a single formula over four typed variables: <strong><em>m (membership_active, bool), o (has_overdue, bool), b (books_on_loan, int) and r (requested_books, int):</em></strong></p><p><strong>φ ≡ m ∧ ¬o ∧ (b + r ≤ 10)</strong></p><p>Consider three requests. In each case the LLM extracts facts from the request, maps them onto the policy’s variables, and the AI’s draft answer supplies the claim <strong><em>c = “the borrow is allowed”.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xaRi78hi_kXnIFUYkuOVsw.png" /><figcaption>Three claims against the same policy. In both failures the AI’s answer sounds helpful; the solver locates the exact rule that breaks.</figcaption></figure><p>Walk through scenario 2 the way the solver does. The facts are <strong><em>F ≡ (m = ⊤) ∧ (o = ⊥) ∧ (b = 8) ∧ (r = 5).</em></strong> Substituting into <strong><em>φ</em></strong> forces <strong><em>b + r = 13, and 13 ≤ 10</em></strong> is false in linear integer arithmetic; no assignment can rescue it. Hence <strong><em>F ∧ φ ∧ c</em></strong> is UNSAT, the claim is refuted, and the unsat core is the single constraint <strong><em>b + r ≤ 10</em></strong>. In SMT-LIB, the standard input language of solvers like CVC5, the whole check is a few lines:</p><pre>(set-logic QF_LIA)<br>(declare-const membership_active Bool)<br>(declare-const has_overdue       Bool)<br>(declare-const books_on_loan     Int)<br>(declare-const requested_books   Int)<br> <br>;; policy φ<br>(assert (and membership_active<br>             (not has_overdue)<br>             (&lt;= (+ books_on_loan requested_books) 10)))<br> <br>;; facts F, extracted from the request<br>(assert (= membership_active true))<br>(assert (= has_overdue false))<br>(assert (= books_on_loan 8))<br>(assert (= requested_books 5))<br> <br>(check-sat)   ; =&gt; unsat: the claim is refuted</pre><p>Notice what the two failing scenarios have in common: the AI’s draft answer <em>sounds</em> perfectly helpful. A guardrail scoring tone and topicality could plausibly wave both through. The solver flags them because <strong>8 + 5 = 13</strong> and <strong>13 </strong>is not at most <strong>10</strong>, and because a lapsed membership makes m false. Small stakes here, but the mechanism is the point: the disagreement is located in a specific rule, not diffused across a score.</p><h3><strong>What a policy looks like</strong></h3><p>Policies live as structured JSON: the original English, the typed variables, and the compiled rule, side by side.</p><pre>{<br>  &quot;name&quot;: &quot;Library Borrowing&quot;,<br>  &quot;original_text&quot;: &quot;Borrowing policy<br>      1. Membership must be active.<br>      2. No overdue items on the account.<br>      3. At most 10 books out at once, including this request.&quot;,<br>  &quot;logic&quot;: {<br>    &quot;variables&quot;: [<br>      { &quot;name&quot;: &quot;membership_active&quot;, &quot;type&quot;: &quot;bool&quot;,<br>        &quot;description&quot;: &quot;Whether the membership is active&quot; },<br>      { &quot;name&quot;: &quot;has_overdue&quot;,       &quot;type&quot;: &quot;bool&quot;,<br>        &quot;description&quot;: &quot;Whether any items are overdue&quot; },<br>      { &quot;name&quot;: &quot;books_on_loan&quot;,     &quot;type&quot;: &quot;int&quot;,<br>        &quot;description&quot;: &quot;Books currently on loan&quot; },<br>      { &quot;name&quot;: &quot;requested_books&quot;,   &quot;type&quot;: &quot;int&quot;,<br>        &quot;description&quot;: &quot;Books in this request&quot; }<br>    ],<br>    &quot;rules&quot;: &quot;And(membership_active, Not(has_overdue),<br>               books_on_loan + requested_books &lt;= 10)&quot;<br>  },<br>  &quot;version&quot;: 2<br>}</pre><p>Three things that earn this format it’s keep:</p><p><strong>1. Typed variables. </strong>Booleans, integers, reals and strings, each with a description. Types are what let the solver reason exactly instead of approximately.</p><p><strong>2. Composable rules. </strong>And, Or, Not and comparison operators, evaluated deterministically by CVC5. If a rule is ambiguous, the solver says so explicitly rather than failing silently.</p><p><strong>3. Versioning. </strong>Every modification increments the version. If someone asks months later why a response was held back, the exact rules that made the call are still there to read.</p><h3><strong>LLM as a judge vs AI+AR</strong></h3><p>The most common alternative today is LLM-as-a-judge: a second model reads the first model’s output and scores or critiques it. That is still an LLM reasoning probabilistically about another LLM, so it inherits the same failure modes it is meant to catch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*3I9hZQMrcrYAy1EFZRzNcw.png" /></figure><h3><strong>Where the guarantee stops</strong></h3><p>It is worth being precise about what is proved. The solver’s verdict is exact <em>relative to the formalisation</em>: if the LLM compiles the English policy into the wrong formula, or maps a request onto the wrong facts, the proof is a correct answer to the wrong question. The trust boundary sits at the two translation steps, which is why the pattern keeps them small, reviewable and versioned. The compiled policy is a diffable artefact a human can audit once, rather than a judgement remade probabilistically on every request.</p><p>The ambiguity verdict earns its place here too. A policy that under-specifies a case does not silently default to pass or block; the double SAT check surfaces the gap, which in practice becomes a queue of policy improvements, each one a version bump with a paper trail.</p><h3><strong>Conclusion</strong></h3><p>The two approaches are complements, not rivals. LLM-as-a-judge techniques remain the right tool for tone, safety and other properties for which no precise rule exists. Our working hypothesis is simpler: wherever a rule <em>can</em> be written down precisely, a proof is a stronger signal than a judge’s opinion, deterministic where the judge is stochastic and explainable where the judge is opaque.</p><p>Whether this pattern becomes a standard component of AI systems remains an open question, but the economics are suggestive: a solver check costs milliseconds, produces a certificate, and never changes its mind.</p><p><strong>Ritchie Ng</strong> is a Distinguished AI Scientist and CEO Technical Advisor at CommBank, working on applied AI, agentic systems and automated reasoning. He has previously led AI and data science teams across industry and has contributed to research, engineering and education initiatives spanning generative AI, deep learning and large-scale AI systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*e-Ql5wvZQ0iayMABlbwK2w.png" /></figure><p><strong><em>Disclaimer: This article is the opinion of an individual senior technology staff member at the Commonwealth Bank of Australia, and does not represent the views of the Group.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b9372f8d4be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/ai-guardrails-that-prove-not-guess-8b9372f8d4be">AI Guardrails That Prove, Not Guess</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving Decompiled Code Readability with LLM Agents]]></title>
            <link>https://medium.com/commbank-technology/improving-decompiled-code-readability-with-llm-agents-f67bf10d2505?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/f67bf10d2505</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 08:05:52 GMT</pubDate>
            <atom:updated>2026-08-17T00:13:45.092Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Editors note: </strong>This article summarises research by Neil Archibald, Distinguished Engineer, and Ruben Thijssen, Chief Engineer, on their paper <a href="https://arxiv.org/abs/2606.06838"><em>LLM Agent-Assisted Reverse Engineering with Quantitative Readability Metrics.</em></a><em> </em>Reverse engineering in Australia is protected by the Copyright Act, and is critical component of ensuring that software is secure and interoperable.</p><p>A decompiler reconstructs C-like source code from a compiled binary. It recovers the control flow fairly well, but the parts of a program that existed only in the original source (variable names, types, comments and structure) are lost during compilation, making the reconstructed code hard to read. Security tasks such as vulnerability research and malware analysis depend on reading that code, so poor readability has an immediate, costly and time-consuming impact.</p><p>Reverse engineering is part of a myriad of security research tasks at CommBank. So anything that makes decompiled code faster to read has a direct payoff for the team. The research conducted for the paper was to understand whether an LLM-based agent could systematically improve readability, and what conditions were required for it to do so effectively.</p><p>This post explores the findings, illustrating a practical approach to improving decompiler output using large language models guided by quantitative readability metrics. Findings show that LLMs can make decompiled code significantly easier to understand, but success depends on providing a clear, measurable definition of readability. Without that guidance, models often struggle to maintain direction over complex tasks, fail to complete them consistently, or optimise for the wrong objective.</p><h3><strong>What a decompiler produces</strong></h3><p>A compiler turns source code into the machine instructions a processor can execute. A decompiler attempts to convert those instructions back into source code. While the result is valid(-ish) C, the code often comes with reconstructed data types, generic names in place of the originals, and heavily optimised structures.</p><p>For example:</p><pre>int32_t FUN_00401a30(int32_t *param_1, int32_t param_2) {<br>  int32_t iVar1;<br>  int32_t iVar2 = *param_1;<br>  for (iVar1 = 1; iVar1 &lt; param_2; iVar1 = iVar1 + 1) {<br>    if (param_1[iVar1] &gt; iVar2) {<br>      iVar2 = param_1[iVar1];<br>    }<br>  }<br>  return iVar2;<br>}</pre><p>While the function above is relatively simple, it is hard to read, and it is not obvious at a glance. A real binary contains hundreds, if not thousands of them, all carrying near-identical function names like <em>FUN_00401a30</em>, and are filled with variables like <em>iVar1.</em></p><p>The early phases of the research found that LLMs are able to autonomously reverse engineer quite well, even with minimal guidance. However, doing this at scale, across hundreds of functions in large binaries, is quite challenging. LLMs tend to hallucinate, and the readability of code is subjective.</p><h3><strong>3-Phased Research Approach</strong></h3><p>The research approach followed three distinct phases, each guided by the previous work. Direct control of Ghidra, Reward similarity, and Composite QRS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGc1Zhibx9fkAGkqlcDBTQ.png" /></figure><p><strong>Phase 1: Direct control of Ghidra</strong></p><p>In the first phase the agent was given direct control over <a href="https://github.com/nationalsecurityagency/ghidra">Ghidra</a>, a popular disassembly and decompilation toolkit, through a Model Context Protocol (MCP) server, letting it rename functions, refine types, and edit the decompilation. It improved the first several functions but then degraded, doing progressively less work on later functions. Without being able to measure readability or correctness the LLM had no feedback to act on, and no way to stay consistent across a large binary.</p><p><strong>Phase 2: Reward structural similarity</strong></p><p>In the second phase a reward signal was added. The agent’s output was recompiled, the resulting binary was compared to the original, and scored on structural similarity. Functional correctness held, but readability got worse: the agent started optimising for the metric in an unintended way.</p><p>When a measure becomes the target, it stops being a good measure. Our prompts instructed the agent to make its compiled output to represent the functionality of the original binary. Starting from clean code like this:</p><pre>int64_t compute_sum(int* arr, int len) {<br>  int64_t result = 0;<br>  for (int i = 0; i &lt; len; i++) {<br>    result += arr[i];<br>  }<br>  return result;<br>}</pre><p>the agent (after several iterations) produced this:</p><pre>int64_t compute_sum(int* arr, int len) {<br>  int64_t rax = 0;<br>  for (int64_t rcx = 0; rcx &lt; len; rcx++) {<br>    rax += *(arr + rcx * 8);<br>  }<br>  return rax;<br>}</pre><p>While the structural similarity improved, readability did not. The variables are named after CPU registers and the array access has become pointer arithmetic. The agent had found a genuinely efficient way to score well, and the fault was in the reward system, not its behaviour.</p><p><strong>Phase 3: Creating a composite readability metric</strong></p><p>The single similarity score was replaced with a composite metric that measures readability along three independent axes and put the metric behind a gate to validate the code still aligns to the original binary. The agent is now tasked with improving readability while preserving correctness at the same time.</p><p><strong>Quantitative Readability Score (QRS)</strong></p><p>A composite metric called the Quantitative Readability Score (QRS) was defined to give the agent a usable objective . Three readability sub-metrics were combined to measure readability, each measuring a different property of the code:</p><ul><li><strong>Lexical Surprisal</strong>: how predictable the code is to a small language model trained on real C. Idiomatic code scores well; decompiler artefacts such as <strong><em>iVar1</em></strong> and <strong><em>param_2</em></strong> score poorly, because real code is generally not written that way.</li><li><strong>Structural Simplicity</strong>: cyclomatic complexity, nesting depth, and function length. Deeply nested or very long functions score lower.</li><li><strong>Idiomatic Quality</strong>: the density of style violations reported by <strong>clang-tidy</strong>, using a pre-defined list of checks for patterns decompilers commonly produce. I.e. bare hex literals, raw pointer arithmetic, <strong><em>goto</em></strong> statements, single-character names, and redundant casts.</li></ul><p>The three combined with weights of 0.34, 0.33, and 0.33. Because they measure different things, raising the overall score by gaming one tends to lower another. Reducing cyclomatic complexity by collapsing control flow into a single large expression increased idiomatic violations; renaming everything to single letters lowered the lexical surprisal score.</p><p>In front of the three sub-metrics is a correctness gate. The edited code must recompile to a binary that is structurally similar to the original. If it does not, the composite score is multiplied by 0.1, so a readable but incorrect result scored very low.</p><blockquote><strong>Wait, what?</strong></blockquote><blockquote>One of the early experiment produced head scratching results as it produced a result that looked much better than it was. Several well-known open-source libraries were compiled, their binaries were decompiled, the agent was run on the output, and the result was compared to the original source. The output matched the originals very closely, down to variable names and comments.</blockquote><blockquote>The LLM did not reverse-engineer these binaries. These libraries were so popular that the evidence of them having been included in the model’s training data was observed. The model was reproducing source it had already seen rather than recovering it from the binary. This showed that the main evaluation had to be run on a synthetic corpus the model could not have memorised. This kind of contamination is suspected to be more common in published results than people admit; recall is very easy to mistake for capability.</blockquote><h3><strong>Reverse engineering 200 small C binaries</strong></h3><p>The QRS-guided refinement process was evaluated on a synthetic corpus of 210 small C binaries (about 10,000 lines in total), each binary implemented a common pattern such as bubble sort, binary search, or a linked list. Each binary was refined repeatedly until both the QRS and structural-similarity thresholds were met. After each pass, the agent received its QRS score and information about its weakest scoring sub-metric.</p><p>Two experiments were run: in the first, the agent could only edit source files; in the second, it could also compile the code and read compiler errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RE8iYkZThDwF8_mI7xDu7A.png" /></figure><p>Access to tools like a compiler (through the <strong><em>Bash</em></strong> command-line interface) mattered more than expected. It roughly halved the number of iterations and produced better and more readable source code. Reviews of the experiments echoed this and showed the LLM would catch and fix issues like compiler errors. The bigger surprise was the regressions, or rather the absence of them: across both experiments, 1,453 refinement passes in the first and 826 in the second, not one iteration reduced the QRS score.</p><h3><strong>What the experiments show</strong></h3><p>The experiments provided several findings on how an LLM can be effectively directed over a long-running task:</p><ul><li>Short iterations focussed on making a single change and with a fresh context each time worked better than long, open-ended sessions, in which the LLMs tend to drift.</li><li>A multi-component metric is less likely to be gamed.</li><li>Letting the LLM compile and check its own work has a meaningful impact on the quality of the output.</li></ul><p>None of this is novel on its own. It is however the combination of these sub-components that provided an effective and deterministic framework to keep a non-deterministic capability(LLM) on task.</p><h3><strong>Limitations and future work</strong></h3><p>QRS-guided refinement worked well within the scope tested, but these were recognised as early and lab-only results. For anyone interested in exploring this area further, there are a few things worth knowing.</p><ul><li>Readability is incredibly subjective. The before and after code was reviewed and judged on readability. However, readability is expected to be judged differently between people, seniority, teams and companies. This means that both the thresholds and the weights of the sub-metrics in QRS require tuning based on what is being reverse-engineered, and who will be reading the output.</li><li>“Correct” means structurally similar, not provably equivalent. The gate uses radare2 to compare control-flow graphs, which is fast and reliable, but not a true equivalence proof. Pairing the gate with symbolic execution or differential testing would close that gap.</li><li>Only simple, well-formed C was evaluated. The corpus was 210 small binaries, with no C++, Rust or Go, no ARM or MIPS, and nothing obfuscated. Whether QRS holds up on messier real-world code, and whether the sub-metric weights need retuning per domain, remains open.</li></ul><p>The broader lesson generalises beyond decompilation: agents do their best work with clear feedback, grounded checks and short improvement loops.</p><p>Here, that meant pairing a readability score with a correctness gate. For AI-powered engineering more widely, it is a reminder that how measurement and feedback are designed can matter as much as which model is used.</p><p><strong><em>Neil Archibald </em></strong><em>is a Distinguished Engineer at the Commonwealth Bank of Australia, working with a focus on security research.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*_UTP-xIyLxE5-9l0yF4hrQ.jpeg" /></figure><p><strong><em>Ruben Thijssen </em></strong><em>is a Chief Engineering at CommBank and builds scalable security solutions.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*Y4LKVQho_kT_VUibVqrlqw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f67bf10d2505" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/improving-decompiled-code-readability-with-llm-agents-f67bf10d2505">Improving Decompiled Code Readability with LLM Agents</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Preserving CommBank’s Archives with AI: From VHS to Vision Models]]></title>
            <link>https://medium.com/commbank-technology/preserving-commbanks-archives-with-ai-from-vhs-to-vision-models-3caff6d4f166?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/3caff6d4f166</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Fri, 24 Jul 2026 05:59:44 GMT</pubDate>
            <atom:updated>2026-08-17T00:13:55.836Z</atom:updated>
            <content:encoded><![CDATA[<p>Every organisation accumulates knowledge over time. Some of it lives in documents, some in photographs, and some in recordings that capture moments, decisions and events that would otherwise be lost.</p><p>At CommBank, more than a century of history is preserved by the Group Archives team across a vast collection of records, including thousands of hours of footage stored on VHS and Betamax tapes. These recordings provide a unique window into Australia’s past, from historic advertising campaigns and major company milestones to everyday moments that reflect how banking and society have changed over time.</p><p>The challenge is that magnetic tape does not last forever. As physical media deteriorates and playback equipment becomes increasingly difficult to maintain, the opportunity to preserve and understand these recordings is rapidly disappearing. While digitisation protects the footage itself, making thousands of hours of video searchable and accessible remains a significant task.</p><p>Project ECHO was built to help solve that problem. Developed by our AI Labs team and NextGen AI Automation, it is a multi-modal video annotation pipeline that uses open-weight models running on a single 24GB GPU to transcribe, describe and catalogue more than 12,000 hours of digitised archive footage, helping transform a historical collection into a searchable resource for future generations.</p><p>Digitisation is the critical first step, but to unlock the full value of this archive, these videos must also be searchable and accessible. Through Project ECHO (<em>Enhancing Cultural Heritage with Open Artificial Intelligence</em>), these digitised materials become an indexable, institutional memory bank that helps future generations look back on CommBank’s role within Australia’s history and culture.</p><h3>Building a multi-modal video annotation pipeline</h3><p>The AI Labs &amp; NextGen AI Automation teams partnered with the CommBank Archives team to build a multi-modal pipeline using free and open-weight models for transcription and scene description of digitised film. In a GenAI plot twist, this partnership arose after CommBank’s head archivist discovered the AI Labs team by talking to our internal Copilot.</p><p>As with many archives in the public and private sectors, cost efficiency was the key point of optimisation. Of course, this presented a challenge but also an attractive opportunity for the dev team to showcase the multi-modal capabilities of open-weight models at a time when <a href="https://evidentinsights.com/bankingbrief/ai-ozempic">tokenomics is coming sharply into focus</a>. Here’s what we built:</p><h3>System Architecture</h3><ol><li>The Group Archives team extracts digitised media and associated <a href="https://developers.preservica.com/documentation/open-preservation-exchange-opex">OPEX metadata</a> from <a href="https://preservica.com/"><em>Preservica</em></a>, a proprietary archival database, and uploads it to an internal web portal which stores the media file and the metadata in AWS <a href="https://aws.amazon.com/s3/">S3</a> storage and a <a href="https://aws.amazon.com/dynamodb/">DynamoDB</a> database respectively.</li><li>Every evening a batch job is kicked off as an <a href="https://aws.amazon.com/ecs/">ECS</a> task, which:</li></ol><ul><li>Retrieves unprocessed media files from the S3 storage</li><li>Cuts out keyframes (approximate scene cut frames) from the video file using ffmpeg’s scene filter</li><li>Resamples the audio stream to Whisper’s native 16kHz mono</li><li>Calls the vLLM endpoints for the transcription and description</li></ul><p>3. Finally, we save the output artefacts to DynamoDB and notify the Archives team by email.</p><p>To help the team review the scene descriptions easily we mapped the JSON output to a nice frontend rendered with markdown tables and headings.</p><p>Lastly, the descriptions and transcriptions are fed back into <em>Preservica</em> to enrich the existing records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDWvQCp2pH_uh_7GEt5Wyg.png" /><figcaption>System architecture diagram for the project</figcaption></figure><p>For our compute, we were running an <a href="https://aws.amazon.com/ec2/">EC2</a> g5.xlarge instance equipped with 24GB of VRAM. To satisfy our memory constraints, we chose the Google <a href="https://huggingface.co/google/gemma-4-E2B-it">Gemma 4 E2B </a>model for image description and OpenAI’s <a href="https://huggingface.co/openai/whisper-large-v3-turbo">Whisper Large v3 Turbo</a> for speech-to-text transcription.</p><p>We opted for <a href="https://docs.vllm.ai/en/stable/">vLLM</a> as our inference server stack as it handles concurrent requests cleanly with continuous batching and we could stream keyframes and audio directly to the OpenAI-compatible endpoints.</p><p>We retained both models in VRAM using separate vLLM processes concurrently and deferred to the GPU scheduler to optimise throughput. Worth noting, this GPU only costs <a href="https://aws.amazon.com/ec2/pricing/on-demand/">$1.308 USD</a>/hour to rent on demand.</p><p>We also considered generating text and image embeddings to build a retrieval-augmented generation (RAG) search index. However, we prioritised plain-text outputs because they are optimal for subject matter experts to review, edit, and feed back into existing archival workflows.</p><h3>Scene descriptions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcSb02M-8VgQNOM6q3sNCQ.png" /><figcaption>A screencap from the scene description testing tool in full early-CGI glory</figcaption></figure><p>Our output formats were intended to be both human and machine parseable. Because the output would be reviewed by archivists and later ingested by archival systems, we wanted a clean and predictable schema.</p><p>For the scene descriptions, we use vLLM’s <a href="https://docs.vllm.ai/en/stable/examples/features/structured_outputs/?h=stru">Structured Outputs</a> with a Pydantic schema to enforce a structured JSON output.</p><pre>from typing import Annotated, Literal<br>from pydantic import BaseModel, Field<br><br>class KeyframeDescription(BaseModel):<br>    &quot;&quot;&quot;Structured description of a single digitised keyframe.&quot;&quot;&quot;<br><br>    scene_description: Annotated[<br>        str,<br>        Field(description=&quot;Detailed visual description of what is happening in the frame.&quot;, max_length=800),<br>    ]<br>    content_type: Annotated[<br>        Literal[<br>            &quot;talking_head&quot;, &quot;news_segment&quot;, &quot;advertisement&quot;, &quot;sports&quot;,<br>            &quot;music_performance&quot;, &quot;title_card&quot;, &quot;b_roll&quot;, &quot;documentary&quot;,<br>            &quot;home_video&quot;, &quot;other&quot;,<br>        ],<br>        Field(description=&quot;Best-fit category for this frame&#39;s content.&quot;),<br>    ]<br>    setting: Annotated[<br>        Literal[<br>            &quot;Advertisement&quot;,<br>            &quot;Annual General Meeting&quot;,<br>            &quot;Branch&quot;,<br>            &quot;Forum&quot;,<br>            &quot;Indoor&quot;,<br>            &quot;Interview&quot;,<br>            &quot;Office&quot;,<br>            &quot;Outdoor&quot;,<br>            &quot;Panel Discussion&quot;,<br>            &quot;Presentation&quot;,<br>            &quot;Studio&quot;,<br>            &quot;Other&quot;,<br>        ],<br>        Field(description=&quot;Physical environment or scene setting. Pick the single best match. Use &#39;Other&#39; only if none of the specific options fit.&quot;),<br>    ]<br>    people_count: Annotated[<br>        int,<br>        Field(ge=0, le=50, description=&quot;Number of visible people in the frame.&quot;),<br>    ]<br>    text_visible: Annotated[<br>        list[Annotated[str, Field(max_length=200)]],<br>        Field(<br>            description=(<br>                &quot;All legible text found in the frame, including captions, chyrons, title cards, &quot;<br>                &quot;logos, lower-thirds, signs, etc. Empty list if none.&quot;<br>            ),<br>            max_length=20,<br>        ),<br>    ]<br>    colour_mode: Annotated[<br>        Literal[&quot;colour&quot;, &quot;black_and_white&quot;, &quot;sepia&quot;],<br>        Field(description=&quot;Colour presentation of the frame.&quot;),<br>    ]</pre><p>Note, that we can apply length limits on the fields to prevent unbounded generation and help us keep to our conservative token output budget.</p><p>To optimise our throughput, we pass the extracted keyframes to the vLLM Gemma endpoint using an in-memory BytesIO representation instead of writing the image files to disk first. Extracted keyframes are streamed directly to the vLLM endpoint in a batch size of 12. This ensures near constant 100% GPU utilisation for image processing. Finally, we optimally prefetch subsequent media files (these are between 500MB to 6GB file size) so that there is no waiting gap between processing consecutive files.</p><p>We also kept the stable part of the prompt at the front and appended dynamic video metadata at the end. This allowed vLLM to <a href="https://docs.vllm.ai/en/latest/features/automatic_prefix_caching/">reuse the cached prefix</a> across requests, reducing repeated prompt-processing prefill overhead.</p><p>Each frame took just over 1 second to process, end-to-end. Google has also recently released <a href="https://blog.google/innovation-and-ai/technology/developers-tools/multi-token-prediction-gemma-4/"><em>assistant</em> Gemma models</a> to increase token decoding speed by guess-and-checking with <a href="https://docs.vllm.ai/en/stable/examples/features/speculative_decoding/">speculative decoding</a>. Unfortunately, speculative decoding is not yet configured for non-text modalities, so we weren’t able to evaluate it.</p><p>We observed that Gemma 4 E2B occasionally misidentified certain historical objects, such as typewriters. The larger Gemma models did not exhibit the same issue, and our human-in-the-loop workflow allows the Archives team to correct any misidentifications before outputs are released.</p><h3>Speech-to-Text (STT) transcription</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAFYkRWI5jTOnVBz_6m7Xw.png" /><figcaption>A screencap of the user-facing dashboard where archivists can check and correct transcripts</figcaption></figure><p>vLLM has a clean ‘audio tower’ interface built-in that handles chunking and audible-speech <a href="https://docs.vllm.ai/en/stable/api/vllm/multimodal/audio/#vllm.multimodal.audio.split_audio">boundary detection</a>. Thankfully, most of the audio was high-quality recordings, meaning we didn’t need to aggressively pre-process to account for noise.</p><p>However, since some of our videos were extremely long (exceeding 3 hours) we resampled the audio from 48kHz stereo to Whisper’s native 16kHz mono to decrease audio file sizes. The transcriptions were generated with timestamps, to allow us to output a clean <a href="https://en.wikipedia.org/wiki/SubRip">SubRip</a> (SRT) subtitle file for the Archives team to align the video to the audio.</p><p>We selected Whisper as our STT model because it has built-in vLLM support and a relatively low memory footprint. However, we are also evaluating newer STT models. One promising option is Microsoft’s <a href="https://github.com/microsoft/VibeVoice">VibeVoice</a>, which supports “hotwords”: predefined terms that can improve transcription accuracy for domain-specific vocabulary. For example, Australian English accents are relatively underrepresented in many training corpora, and Whisper struggled to correctly transcribe the phrase “<em>Crocodile Dundee</em>”.</p><p>On a related note, due to their training corpus, the models default to transcribing text using American English spelling and grammar. Thankfully this is easy to fix at the prompt level.</p><p>In our testing, we managed to hit a faster-than-real-time factor of approximately 10x to 20x (excluding upstream media extraction and downstream review).</p><h3>What’s next?</h3><p>From requirements gathering to deployment, the whole project took about 6 weeks.</p><p>At AI Labs, we’re excited about the role that open-weight models will play in the preservation of historical materials. Smaller models have evolved from academic toys to being capable of producing quality output that’s consumable by both humans and AI frameworks alike.</p><p>We believe that <strong>fitting the model size to the problem</strong> unlocks performance at price.</p><p>This is also an example of using AI as a force multiplier. The annotation work would be impossible relying on humans alone, but this pipeline amplifies specialist archival expertise at scale.</p><blockquote><em>“The ECHO pipeline will save us about 12,000 hours of skilled transcription and description work, which is well beyond our capacity as a small five-person team.”<br></em><strong><em>Jeff Palmer, Group Archivist</em></strong></blockquote><p>We welcome interest from small archives, museums and not-for-profit organisations who are exploring new ways to process and unlock their digital AV collections. If this resonates, we’d be pleased to hear from you and explore how we can assist your work through our ECHO initiative. You can contact the team on <a href="mailto:archives@cba.com.au">archives@cba.com.au</a>.</p><p>This project is available as open source. Explore the <a href="https://github.com/Commonwealth-Bank-of-Australia/project-echo">GitHub repository</a> to learn more.</p><h3>Authors</h3><p><strong><em>Lachy Berry</em></strong><em> — Data Scientist at CommBank.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*DdZs8t6NkyCXzZUMCMSxZg.png" /></figure><p><strong><em>Xun Wang</em></strong><em> — Principal Engineer at CommBank.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*Co-GNP-ACpakVM4mKAffdQ.png" /></figure><p><strong><em>Yossi Frenkel — </em></strong><em>Data Scientist at CommBank.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*aNo7Yx4XIl49ishNpU2Oxg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3caff6d4f166" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/preserving-commbanks-archives-with-ai-from-vhs-to-vision-models-3caff6d4f166">Preserving CommBank’s Archives with AI: From VHS to Vision Models</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Agents safe and reliable via data structures and enforcement]]></title>
            <link>https://medium.com/commbank-technology/making-agents-safe-and-reliable-via-data-structures-and-enforcement-205722a4c91d?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/205722a4c91d</guid>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Thu, 16 Jul 2026 00:38:47 GMT</pubDate>
            <atom:updated>2026-08-17T00:14:06.756Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article is an opinion piece by Blair Hudson, Chief Engineer, on lessons learned building agents, and how to keep them safe — through external controls and good engineering.</em></p><p>A good agent should still be safe if the system prompt were removed.</p><p>That sounds extreme, but it is a useful design test. If the only thing stopping your agent from skipping verification, calling tools <em>out of order</em>, exposing sensitive data, or taking an irreversible action is a paragraph in the system prompt, the system is brittle.</p><blockquote>“Tools should enforce correctness. System prompts should improve consistency. Guardrails should enforce non-negotiables.”</blockquote><p>System prompts are useful for steering: tone, scope, style, wording preferences and general conversational behaviour. They make the agent more consistent. But if the agent must behave a certain way for safety, compliance, privacy or correctness, that behaviour should not live only in the prompt.</p><p>If it must happen, the recommendation would be to enforce it in the tool or make it a guardrail. Then you can test it, measure it and monitor it separately from conversational behaviour.</p><h3>Seven design anti-patterns</h3><p>Here are some of the most commonly observed design pitfalls:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShXllfOtUxLfqOiyf6qNmw.png" /></figure><p>1. Control logic in the prompt</p><p>2. Workflows that collapse into form-filling</p><p>3. Identity exposed as an agent input</p><p>4. Consumer modes as agent switches</p><p>5. Opaque tool failures with nowhere to go</p><p>6. Idempotency in the description, not the tool</p><p>7. Prompt constraints that are not measured</p><h3>Ask what happens if the model ignores the prompt</h3><p>If the answer is “it could take action before verification”, “it could access a record the caller should not see” or “it could retry indefinitely”, the design is relying on the wrong layer.</p><p>Instead of putting this in the prompt:</p><pre>Only perform this action after verification has passed.</pre><p>Make the tool enforce it:</p><pre>@dataclass<br>class WorkflowState:<br>    verification_passed: bool<br>    target_resolved: bool<br>    attempts: int<br><br>agent = Agent(&quot;model&quot;, deps_type=WorkflowState)<br><br>@agent.tool<br>def perform_sensitive_action(ctx: RunContext[WorkflowState]) -&gt; str:<br>    if not ctx.deps.verification_passed:<br>        return &quot;Verification has not been completed.&quot;<br>    return _do_sensitive_action()</pre><p>Instead of putting retry limits in the prompt:</p><pre>Escalate after two failed attempts.</pre><p>Make the tool count and lock:</p><pre>@agent.tool<br>def attempt_verification(ctx: RunContext[WorkflowState], answer: str) -&gt; str:<br>    if ctx.deps.attempts &gt;= 2:<br>        return &quot;Maximum verification attempts reached. Escalating.&quot;<br>    ctx.deps.attempts += 1<br>    return _check_answer(answer)</pre><p>Instead of relying on the model to hide sensitive identifiers:</p><pre>Never show the full identifier.</pre><p>Make the tool return only masked values:</p><pre>@agent.tool<br>def get_record_details(ctx: RunContext[SessionDeps], record_id: str) -&gt; RecordDetails:<br>    record = _fetch_record(ctx.deps.actor, record_id)<br>    return RecordDetails(<br>        identifier=_mask(record.identifier),<br>        status=record.status,<br>    )</pre><p>Defensively-designed tools check workflow state before proceeding. State lives in dependencies injected at runtime, not in parameters exposed to the model, so the model is the connective layer but not the enforcement layer.</p><h3>Collapse deterministic tool chains</h3><p>A common challenge is a prompt that says:</p><pre>First call Tool A. Then Tool B. Then Tool C.<br>Never call Tool C before Tool B. Never skip Tool A.</pre><p>If those tools must always be called in that exact order, they probably should not be separate agent tools but implementation detail of one operation. Instead of exposing the chain as individual tools the agent should orchestrate:</p><pre># bad - the agent must get this sequence right every time<br>@agent.tool<br>def resolve_actor_id(ctx: RunContext[SessionDeps], name: str) -&gt; str: ...<br><br>@agent.tool<br>def resolve_resource_id(ctx: RunContext[SessionDeps], actor_id: str) -&gt; str: ...<br><br>@agent.tool<br>def check_eligibility(ctx: RunContext[SessionDeps], resource_id: str) -&gt; bool: ...</pre><p>Resolve authenticated context before the run starts and inject it into dependencies:</p><pre>result = await agent.run(<br>    user_message,<br>    deps=SessionDeps(<br>        actor=get_actor_from_session(request),<br>        http_client=client,<br>    ),<br>)</pre><p>The actor is resolved once at dispatch time. The agent starts with the context it needs, and with no extra tool call and no round-trip, there is less for the model to get wrong. An agent does not add value by orchestrating deterministic backend plumbing, it only adds risk.</p><p>The same applies to flows like retrieve record -&gt; verify field 1 -&gt; verify field 2 -&gt; perform action. If the action must only happen after all verification succeeds, you can collapse it:</p><pre>@agent.tool<br>def verify_and_apply_change(ctx: RunContext[SessionDeps], reference: str, confirmation_code: str) -&gt; str:<br>    if not _verify_reference(ctx.deps.actor, reference):<br>        return &quot;Reference did not match.&quot;<br>    if not _verify_code(ctx.deps.actor, confirmation_code):<br>        return &quot;Confirmation code did not match.&quot;<br>    return _apply_change(ctx.deps.actor.id)</pre><p>The agent collects inputs but the tools own the transaction boundary.</p><h3>If everything collapses into one tool, maybe you do not need an agent</h3><p>There is a challenge in the opposite direction too. If the agent becomes:</p><pre># bad - this is a form, not an agent<br>@agent.tool<br>def collect_name(ctx: RunContext[SessionDeps], name: str) -&gt; str: ...<br><br>@agent.tool<br>def collect_date(ctx: RunContext[SessionDeps], date: str) -&gt; str: ...<br><br>@agent.tool<br>def submit_request(ctx: RunContext[SessionDeps]) -&gt; str: ...</pre><p>Then maybe we’re overengineering a solution that can be reduced to a form and an API call. Forms are cheaper, easier to test, easier to evaluate and less variable.</p><p><strong>The question to ask is:</strong> is there actual work for the agent to do?</p><p>If the job is deterministic data collection followed by one backend call, consider that an agent may not be a good solution. If the job requires conversation, ambiguity handling, search, comparison, refinement and repeated attempts to find the right answer, an agent is justified.</p><h3>Identity is not a parameter</h3><p>In authenticated channels the caller identity is already established. It should not appear in the tool schema the agent sees at all. Anything the agent should not supply goes into dependencies injected when the agent run is instantiated and invisible to the model:</p><pre>@dataclass<br>class SessionDeps:<br>    actor: AuthenticatedActor  # resolved from session, not agent-visible<br>    http_client: httpx.AsyncClient<br><br>agent = Agent(&quot;model&quot;, deps_type=SessionDeps)<br><br>@agent.tool<br>async def get_resource_summary(ctx: RunContext[SessionDeps], resource_id: str) -&gt; str:<br>    if resource_id not in ctx.deps.actor.allowed_resource_ids:<br>        return &quot;Resource not found for this caller.&quot;<br>    return await _fetch_summary(ctx.deps.http_client, resource_id)</pre><p>The model can supply a <strong>resource_id</strong>, but it has no knowledge of actor and cannot supply or override it. The identity is bound at dispatch time:</p><pre>result = await agent.run(<br>    user_message,<br>    deps=SessionDeps(<br>        actor=get_actor_from_session(request),<br>        http_client=client,<br>    )<br>)</pre><p>This closes an entire class of prompt-injection risk. If the agent cannot pass an <strong>actor_id</strong>, it cannot be tricked into passing the wrong one. The same pattern applies to session tokens, verified channel context, agent identity and any other value already known from the authenticated environment.</p><p>The same reasoning applies to authorisation. If a tool accepts a parameter like <strong><em>authorised: bool</em></strong>, the model can fabricate it. The model has no authority to grant authorisation, it can only report a claim.</p><pre># bad - the agent can set this to True<br>@agent.tool<br>async def submit_change(ctx: RunContext[SessionDeps], change_id: str, authorised: bool) -&gt; str: ...</pre><p>Authorisation requires an out-of-band flow like a consent screen, approval step, signed token or equivalent. The resulting approval is injected into dependencies by the orchestration layer, never supplied by the agent:</p><pre># good - authorisation is a flow, not a parameter<br>@agent.tool<br>async def submit_change(ctx: RunContext[SessionDeps], change_id: str) -&gt; str:<br>    approval = ctx.deps.approval<br>    if not approval:<br>        return &quot;Approval required. Please complete the approval step.&quot;<br>    if approval.change_id != change_id:<br>        return &quot;Approval was issued for a different change.&quot;<br>    return await _apply_change(change_id, approval.token)</pre><p>The tool checks dependencies for a signed authorisation object. If absent, it returns a safe message the agent can surface. The orchestration layer handles the approval, injects the result, then resumes. The model never influences the authorisation decision.</p><p>A broader principle: if a failure mode is fundamentally an identity or access problem, do not solve it with evals or prompt instructions. Access control is not a probabilistic problem, and a deterministic check cannot be fooled by a clever prompt.</p><h3>Build your agent for one consumer: another agent</h3><p>A common attempt to handle multiple consumer types, such as end-user, support, admin or system caller, is a mode parameter:</p><pre># bad - the model enforces the boundary<br>@agent.tool<br>async def get_record_details(ctx: RunContext[SessionDeps], record_id: str, mode: Literal[&quot;end_user&quot;, &quot;support&quot;, &quot;admin&quot;]) -&gt; RecordDetails: ...</pre><p>This is actually a prompt instruction with extra steps, where the model decides which mode applies. A confused model, a misconfigured prompt or a prompt injection can cross the boundary.</p><p>Separating agents for different consumers is better. Assume your expert agent will be called by a channel agent that handles the consumer-facing interaction and calls your agent with a well-scoped, authenticated request. Your agent becomes a expert service: one caller, one access scope, one set of dependencies.</p><p>When someone acts on behalf of someone else, that is an IAM policy problem. The channel or orchestration layer resolves the policy and injects both identities into dependencies:</p><pre>@dataclass<br>class SessionDeps:<br>    operator: AuthenticatedActor<br>    subject: Subject<br>    permissions: frozenset[str]<br><br>@agent.tool<br>async def update_case(ctx: RunContext[SessionDeps], case_id: str) -&gt; str:<br>    if &quot;update_case&quot; not in ctx.deps.permissions:<br>        return &quot;You do not have permission to update this case.&quot;</pre><p>The agent enforces the policy and does not reason about why the permissions are what they are.</p><h3>Use tool failures to steer the agent</h3><p>Do not front-load every possible rule into the system prompt. Return structured failures that are specific, safe and actionable:</p><pre>@dataclass<br>class ToolResult:<br>    status: str<br>    user_message: str<br>    next_action: str<br><br>@agent.tool<br>def search_records(ctx: RunContext[SessionDeps], date: str | None, amount: float | None) -&gt; ToolResult | list[Record]:<br>    if date is None:<br>        return ToolResult(<br>            status=&quot;missing_required_input&quot;,<br>            user_message=&quot;Please ask for the date before searching.&quot;,<br>            next_action=&quot;collect_date&quot;,<br>        )<br>    if not ctx.deps.verification_passed:<br>        return ToolResult(<br>            status=&quot;verification_required&quot;,<br>            user_message=&quot;Verification must be completed before continuing.&quot;,<br>            next_action=&quot;collect_verification_details&quot;,<br>        )<br>    return _do_search(ctx.deps.actor.id, date, amount)</pre><p>This steers the agent using live state, not a long prompt written at the start of the conversation. Tool failure outputs should be structured, user-safe, specific about what is missing, clear about the next action and free of internal system details.</p><h3>Idempotency belongs in the tool, not the description</h3><p>Tool descriptions that say things like:</p><blockquote>“Do not call more than once for the same confirmed details unless the user explicitly requests a new result.”</blockquote><p>are instructions to the model, not constraints on the tool. The model can ignore them, miscount or be confused by a long conversation. Idempotency is a systems property and should be enforced in the tool.</p><p>For expensive or side-effecting calls, the tool should be safe to call twice. Deduplicate using a key from dependencies injected by the orchestration layer, not supplied by the agent:</p><pre>@dataclass<br>class SessionDeps:<br>    actor: AuthenticatedActor<br>    idempotency_key: str  # injected per run by orchestration<br><br>@agent.tool<br>async def get_quote(<br>    ctx: RunContext[SessionDeps],<br>    option_type: str,<br>    quantity: int,<br>) -&gt; QuoteResult:<br>    cached = await _get_cached_quote(<br>        ctx.deps.idempotency_key,<br>        option_type,<br>        quantity,<br>    )<br>    if cached:<br>        return cached<br>    result = await _fetch_quote(option_type, quantity)<br>    await _cache_quote(ctx.deps.idempotency_key, option_type, quantity, result)<br>    return result</pre><p>The agent never sees the idempotency key. It just calls the tool. The tool is safe to call repeatedly and the description can honestly say so: returns cached result if already fetched this session. The same applies to submission tools. If an operation must not be submitted twice, the tool deduplicates against the session key in dependencies. If the model calls it again, it gets the original result back.</p><h3>Prompt constraints that are not measured are not guardrails</h3><p>System prompts often contain lines like:</p><pre>Do not provide regulated advice.<br>Do not make unsupported product recommendations.<br>Never reveal internal system details.</pre><p>These look like constraints, but they are actually requests. The model either follows them or it does not, silently, with no compliance rate, no regression detection and no alerting. You cannot easily measure whether they hold, you cannot tell when a model change impacts their behaviour, and you cannot report them to a risk team with a confidence interval.</p><p>A real guardrail is a separately evaluated control, not a prompt instruction. It might be a classifier, a policy engine, a deterministic validator or an allowlist, but it must be measured independently of the agent. In practice, many high-signal guardrails are specialised classifiers with their own data, evaluation pipeline, model card and ownership.</p><p>These classifiers are most useful at two positions: before the agent runs and before the response reaches the user:</p><pre>User message -&gt; input classifier -&gt; Agent -&gt; output classifier -&gt; User response</pre><p>Input guardrails catch things the agent should never see or engage with: regulated-advice requests, out-of-scope tasks or prompt-injection attempts.</p><p>Output guardrails catch things the agent should never say: sensitive data that leaked through, unsafe advice or policy violations in the response.</p><p>The agent integrates both as service calls:</p><pre>async def run_agent(message: str, deps: SessionDeps) -&gt; str:<br>    input_check = await guardrails.classify(message, policy=&quot;regulated_advice&quot;)<br>    if input_check.triggered:<br>        return _safe_deflection(input_check.policy)<br><br>    response = await agent.run(message, deps=deps)<br><br>    output_check = await guardrails.classify(<br>        response.output,<br>        policy=&quot;regulated_advice&quot;,<br>    )<br>    if output_check.triggered:<br>        return _safe_deflection(output_check.policy)<br><br>    return response.output</pre><p>Because the classifier is a separate service, it has its own measurement pipeline. Violation rate, false positive rate, latency and model accuracy can be tracked independently of agent evals. The classifier can be retrained, upgraded or replaced without touching the agent, and the agent can be changed without affecting the classifier measurement baseline. A prompt instruction cannot give you this, so if a behavioural constraint is a critical part of your safety or compliance posture it needs to be a control that can be independently measured.</p><h3>What good agent work looks like</h3><p>This post has mostly focused on finding and fixing anti-patterns, but it’s fair to look at indicators of good use cases. One such strong use case is search and matching over ambiguous information. The user might say:</p><blockquote>“I need to find a purchase from yesterday afternoon. I think it was around $40, but it might have been part of a larger order. The receipt is missing.”</blockquote><p>The agent collects partial details, searches, compares candidates, asks narrowing questions and retries with corrections. The tool signature reflects the open-ended nature of the work, and the fields are optional and the agent fills them iteratively:</p><pre>@agent.tool<br>async def search_activity(<br>    ctx: RunContext[SessionDeps],<br>    date: str | None = None,<br>    amount: float | None = None,<br>    activity_type: str | None = None,<br>    description_hint: str | None = None,<br>    identifier_hint: str | None = None,<br>) -&gt; list[ActivityMatch]:<br>    return await _search(<br>        ctx.deps.actor.id,<br>        date,<br>        amount,<br>        activity_type,<br>        description_hint,<br>        identifier_hint,<br>    )</pre><p>Contrast this with call three tools to resolve an identity, which is backend orchestration that should be collapsed.</p><h3>Don’t give an agent a choice if it can’t go wrong</h3><p>Do not let the agent decide whether verification passed. Do not let it decide whether a caller owns a resource, whether retry limits are exhausted, whether sensitive data should be masked, or whether an approval is valid.</p><pre># bad - the model decides if verification passed<br>@agent.tool<br>def perform_action(ctx: RunContext[SessionDeps], verified: bool) -&gt; str:<br>    if verified:<br>        return _do_sensitive_action()<br>    return &quot;Not verified.&quot;<br><br># good - the tool decides using injected state the agent cannot forge<br>@agent.tool<br>def perform_action(ctx: RunContext[WorkflowState]) -&gt; str:<br>    if not ctx.deps.verification_passed:<br>        return &quot;Verification is incomplete.&quot;<br>    return _do_sensitive_action()</pre><p>The agent can decide how to ask a question, summarise a result or help the user choose between ambiguous matches, and the system should decide what is allowed.</p><h3>The design hierarchy</h3><pre># Tool design: correctness, authorisation, state, business rules<br>@agent.tool<br>def perform_operation(ctx: RunContext[WorkflowState], amount: float) -&gt; str:<br>    if not ctx.deps.verification_passed:<br>        return &quot;Not verified.&quot;<br>    if amount &gt; ctx.deps.limit:<br>        return &quot;Exceeds limit.&quot;<br>    return _do_operation(amount)<br><br># Guardrails: non-negotiable behavioural constraints,<br># measured separately from the agent<br>async def run_agent(message: str, deps: SessionDeps) -&gt; str:<br>    if (await guardrails.classify(message, policy=&quot;regulated_advice&quot;)).triggered:<br>        return _safe_deflection()<br>    response = await agent.run(message, deps=deps)<br>    if (await guardrails.classify(response.output, policy=&quot;regulated_advice&quot;)).triggered:<br>        return _safe_deflection()<br>    return response.output<br><br># System prompt: steering, consistency, tone, scope, interaction style<br>agent = Agent(&quot;model&quot;, deps_type=WorkflowState, system_prompt=&quot;You are a service assistant. Be concise and professional.&quot;)<br><br># Model: conversation, ambiguity handling, reasoning over returned data</pre><h3>A practical test</h3><p>For every instruction in your system prompt, ask:</p><blockquote>“Is this steering, or is this control logic?”</blockquote><p>If it is steering, it can stay in the prompt. If it is control logic, move it into a tool or a guardrail first. If tools must always be called in the same order, collapse them. If the collapsed workflow is just input collection, ask yourself why you are building an agent. If the workflow involves uncertainty, search, comparison and iterative narrowing, you’re probably building an agent that deserves to be an agent.</p><p>This boundary will matter more as agent systems become more distributed. Channel agents call expert agents. Expert agents interact with systems of record through tools. Guardrail services are measured independently. The teams that deliver the most customer value will not be the teams with the cleverest prompts, they will be the teams with clear contracts between prompts, tools and controls.</p><p>Prompts obviously still matter and shape the experience, but the things that must not fail need to live in deterministic or independently measured layers that can be tested, monitored and owned.</p><p>Build agents that are safe by design, not safe because the prompt asks nicely.</p><p><strong>Author note: </strong>This post is an engineering perspective based on patterns seen when designing and reviewing agentic systems. It is not a description of any CommBank implementation or policy. The examples use simplified Pydantic AI syntax to aid with explanations. Nothing in this article is financial, legal or product advice.</p><p><em>Blair Hudson is an AI and software engineering leader at CommBank. His work focuses on the most complex challenges architecting, engineering and adopting AI safely across the group. If you’d like to get in touch, please reach out to Blair Hudson on </em><a href="https://www.linkedin.com/in/blairhudson/"><em>LinkedIn</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*gHUPy8Teavwr-5OvEywkIA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=205722a4c91d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/making-agents-safe-and-reliable-via-data-structures-and-enforcement-205722a4c91d">Making Agents safe and reliable via data structures and enforcement</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enterprise-grade AI infrastructure with AWS SageMaker HyperPod]]></title>
            <link>https://medium.com/commbank-technology/enterprise-grade-ai-infrastructure-with-aws-sagemaker-hyperpod-dcde2ddb3f4e?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcde2ddb3f4e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[aws-sagemaker]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Thu, 25 Jun 2026 03:09:26 GMT</pubDate>
            <atom:updated>2026-06-25T03:12:11.361Z</atom:updated>
            <content:encoded><![CDATA[<p>Some practical lessons we learnt running LLM training and inference at scale inside a large financial services organisation.</p><h3><strong>The challenge: its not just about GPUs</strong></h3><p>One of our early learnings was that at the outset, the problem appeared straightforward: secure access to high-performance GPUs and run training jobs. In practice, the GPU layer proved to be only one part of the challenge.</p><p>The first generation of the platform was simpler. GPU capacity was reserved and teams ran workloads through SageMaker Training Jobs. This approach worked well for early adoption, but it introduced limitations as demand and complexity increased. SageMaker Training Jobs tend to be intentionally structured around specific runtime and packaging patterns, and interactive access during execution can be limited depending on the workload. Distributed training across multiple nodes also required additional coordination. As more teams and workloads joined the platform, the overhead of managing jobs at scale became more noticeable. Another practical consideration was scheduling efficiency: when reserved GPU capacity was already in use, additional jobs could be delayed or fail to start due to lack of available capacity.</p><p>We found that the move to HyperPod represented a deliberate trade-off. The platform team took on more infrastructure responsibility in exchange for greater flexibility and control across the full job lifecycle, from pod specification to inter-node networking.</p><p>That flexibility introduced a new set of engineering questions:</p><ol><li>How can multiple teams share the same GPU cluster without interfering with each other?</li><li>How should a training job recover if it has been running for 20 hours and a node fails in the final hour?</li><li>How can teams be given secure access to AWS services without credentials appearing in training scripts?</li><li>How should Python packages be installed when cluster nodes have no outbound internet access?</li><li>How can expensive GPU nodes be used efficiently when some workloads require only a fraction of a GPU?</li></ol><p>In our experience running large language models in a financial services environment adds constraints that many tutorials do not cover. Security boundaries are strict. Cost governance requires GPU usage to be tracked carefully. Multi-team isolation is often essential. Network-restricted environments also mean that common assumptions, such as downloading models or packages directly from the public internet at runtime, do not apply.</p><p>To address this in our environment, we adopted AWS SageMaker HyperPod orchestrated by Kubernetes for distributed machine learning workloads. The platform now supports both model training and inference across multiple business domains.</p><p>This article focuses on the engineering lessons from building and operating that platform, including the decisions, trade-offs and implementation patterns that proved most useful in practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPFuS9BhK7-WsWMgMFFN2A.png" /></figure><h3><strong>What is HyperPod?</strong></h3><p>AWS SageMaker HyperPod, orchestrated by a Kubernetes cluster, is designed for large-scale machine learning training. Compared with a general-purpose Kubernetes cluster, three capabilities are especially valuable:</p><ul><li>Automated node health monitoring — failed GPU nodes are detected and replaced automatically.</li><li>Built-in checkpointing integration — jobs can resume from the last saved state after a node failure.</li><li>High-performance networking — Elastic Fabric Adapter (EFA) provides low-latency, high-bandwidth inter-node communication for multi-node training.</li></ul><h3><strong>The hardware: A100s and H100s</strong></h3><p>The platform runs on multiple GPU instance types, primarily:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*Dgx0mTHrLGrW5vnlnq1WDg.jpeg" /></figure><p>P4 instances serve as the main workhorse and support most fine-tuning workloads effectively. P5 instances with H100s are used when additional memory or materially higher throughput is required.</p><h3><strong>GPU partitioning with MIG: making every GPU count</strong></h3><p>One of the efficiency challenges we identified early was that not every workload requires a full GPU. A researcher running a small evaluation job, or experimenting with a 7B model, does not necessarily need the full memory capacity of an A100. Without partitioning, that workload could reserve an entire GPU while leaving most of it idle.</p><p>We found in this case an effective approach was NVIDIA MIG (Multi-Instance GPU), a hardware-level partitioning capability available on A100 and H100 GPUs. MIG allows a single physical GPU to be divided into isolated GPU instances, each with dedicated memory, compute cores and memory bandwidth. These are hardware-enforced partitions rather than time-shared virtual slices, which means each MIG instance is isolated from others on the same physical GPU.</p><p>On A100 nodes, MIG profiles are configured so that Kubernetes pods can request fractions of GPU resources instead of full devices:</p><pre>resources:<br>limits:<br>nvidia.com/mig-1g.5gb: 1</pre><p>A single A100 can be partitioned into up to seven MIG instances at the same time, which allows one physical node to support multiple independent workloads concurrently.</p><p>This matters in a multi-tenant environment. Because the partitions are hardware-enforced, a workload on one MIG instance cannot affect the memory or compute available to another. This improves predictability and helps maintain isolation between workloads.</p><p>In practice, we found that MIG allows exploratory workloads, evaluations and lighter inference tasks to run without waiting behind larger training jobs. Capacity that might otherwise sit idle between full-GPU workloads can be used productively, improving overall cluster utilisation.</p><h3><strong>Multi-tenant isolation</strong></h3><p>One of the earliest design decisions we made was how to isolate teams from each other. Each business domain that onboards to HyperPod receives dedicated logical resources:</p><ol><li>Kubernetes namespace, jobs run in isolation and other teams cannot interfere with those workloads.</li><li>Kueue LocalQueue, resource quota management and fair scheduling.</li><li>Service account, IAM Roles for Service Accounts (IRSA) binding grants pods access to AWS services without embedding credentials.</li></ol><p>This architecture meant that a researcher in one domain could not accidentally access data from a project running in another namespace, and quota limits could be enforced cleanly in each domain.</p><p>An example of a job configuration looks like this:</p><pre>metadata:<br>namespace: hyperpod-ns-domain1<br>labels:<br>kueue.x-k8s.io/queue-name: hyperpod-ns-domain1-localqueue<br>spec:<br>template:<br>spec:<br>serviceAccountName: hyperpod-ns-domain1-sa<br>nodeSelector:<br>beta.kubernetes.io/instance-type: ml.p4d.24xlarge</pre><p>A small number of YAML fields determines the team boundary, the resource pool and the hardware target. The remainder of the configuration is specific to the training workload itself.</p><h3><strong>The training workflow</strong></h3><p>Each training job followed the same five-step pattern, regardless of model size:</p><ol><li>Write and test training code locally, usually on JupyterHub with a small data subset before consuming GPU capacity.</li><li>Package and upload to S3, training code is bundled into a sourcedir.tar.gz archive and pushed to the team’s S3 bucket.</li><li>Generate a PyTorchJob manifest, Hydra is used for configuration management and Jinja2 for YAML templating, so switching from P4 to P5, or from one node to three nodes, is handled by a single CLI override:</li></ol><pre>python run_hyperpod.py instance_type=ml.p5.48xlarge worker_replicas=3</pre><p>4. Submit via kubectl, for example:</p><pre>kubectl apply -f trainer.yaml -n &lt;namespace&gt;</pre><p>5. Monitor via kubectl logs, pods stream training output directly.</p><h3><strong>Training at scale: the 120B+ parameter case</strong></h3><p>One of our early more demanding workloads on the platform was fine-tuning a 120B+ parameter model, which does not fit on a single node. In this scenario, FSDP (Fully Sharded Data Parallel) became essential.</p><p>Why FSDP rather than DeepSpeed? Both can shard large models across GPUs. We selected FSDP because it is native to PyTorch, avoids introducing an additional framework dependency, and integrates cleanly with Hugging Face Trainer for fine-tuning workloads. DeepSpeed can be advantageous for very large pre-training runs, particularly where ZeRO-3 with CPU offloading is required, but for fine-tuning with LoRA across 24 GPUs, FSDP proved simpler to operate and debug.</p><p>Multi-node NCCL configuration is handled through environment variables. Getting NCCL configuration right was one of the more challenging parts of the stack. Misconfiguration does not always fail loudly. A training job can appear to start normally, with pods scheduled and ranks initialised, and then make no further progress because the distributed processes are waiting on communication that is not functioning as expected.</p><p>One issue encountered during testing was NCCL_IB_DISABLE defaulting to 1, which disables InfiniBand/EFA and causes traffic to fall back to TCP. TCP may appear workable in some situations, but it did not provide the performance characteristics required for efficient multi-node training.</p><p>A practical way we used to diagnose this was to set NCCL_DEBUG=INFO temporarily. This produced much more logging, but it also revealed which transport NCCL actually selected. If the logs show NET/Socket rather than NET/IB, inter-node communication is likely not using EFA.</p><p>A production-ready configuration might look like this:</p><pre>NCCL_IB_DISABLE=0<br>NCCL_NET_GDR_LEVEL=PHB<br>NCCL_CROSS_NIC=1<br>NCCL_ALGO=Tree,Ring<br>NCCL_DEBUG=WARN</pre><p>A useful operational step we utilised before launching any real multi-node training job was to run a simple all_reduce benchmark such as nccl-tests and confirm that bandwidth was consistent with expected EFA throughput. If throughput is materially lower than expected, we noticed the issue was likely in the transport configuration rather than the training code.</p><h3><strong>Checkpoint management: training resilience</strong></h3><p>For jobs that run for hours or days, checkpointing was essential. The below pattern was what we used on this platform:</p><ul><li>Save locally every 20 to 100 steps, depending on job duration.</li><li>Upload to S3 after each local save (Sync or Async depending on the requirements).</li><li>On restart, rank 0 scans S3 for the latest checkpoint and downloads it before signalling other ranks to continue.</li></ul><p>We found the rank-0 coordination pattern was more important than it may first appear, in a multi-node job, all ranks start at the same time. If every rank independently downloads the checkpoint from S3, it created unnecessary load and introduced the risk that some ranks resume before others are ready. With rank 0 coordinating the download and the remaining ranks waiting at a barrier, we found that all processes resumed from the same local state in a controlled way.</p><p>Synchronous S3 upload was also chosen deliberately. Although upload is slower, it guarantees a known state, i.e. the checkpoint is either fully written, or it is not.</p><p>This pattern works well with HyperPod’s automatic node replacement. If a node fails during training, the job restarts, rank 0 locates the latest durable checkpoint in S3, and training resumes from that point. The maximum amount of lost work is bounded by the checkpoint interval rather than the full run.</p><h3><strong>Enterprise constraints that shape the design</strong></h3><p>Many HyperPod examples are written for simpler environments. Enterprise settings introduce additional constraints that shape the platform design in important ways.</p><h4><strong>No outbound internet from cluster nodes</strong></h4><p>HyperPod nodes in this environment do not have outbound internet access. That changes how package installation and model access must be handled.</p><p>Python packages are installed through an internal proxy rather than directly from public package repositories.</p><p>Foundation models are pre-staged into a shared S3 location that approved domains can access. This avoids runtime dependency on public model hubs and makes startup more predictable for large models.</p><h4><strong>Controlled S3 paths</strong></h4><p>Each team’s S3 bucket enforces that training artefacts live under an approved shared path. This aligns with IRSA policy boundaries, where the service account’s IAM role is scoped to a specific prefix.</p><h4><strong>Credentials are intentionally abstracted away</strong></h4><p>Pods receive AWS access through IRSA (IAM Roles for Service Accounts). The Kubernetes service account is bound to an IAM role, and the pod receives short-lived credentials automatically through the runtime environment. We found there were no long-lived access keys to manage or embed in scripts.</p><p>Training artefacts in S3 are accessed through IRSA within the team’s namespace and role boundary, including:</p><ol><li>Training code</li><li>Training data</li><li>Checkpoints</li><li>Shared foundation models</li></ol><h4><strong>From training to inference</strong></h4><p>The same platform now supports both sides of the model lifecycle. After fine-tuning:</p><ol><li>Final model adapters are saved to S3 as standard HuggingFace-format checkpoints</li><li>Models are served for inference workloads on the same GPU infrastructure using Inference Operator</li><li>Evaluation jobs, using the same PyTorchJob pattern, run benchmarks against held-out datasets before a model is promoted</li></ol><p>For us using the same infrastructure for training and evaluation kept the feedback loop tight and reduced platform complexity.</p><h4><strong>Observability and debugging</strong></h4><p>The primary debugging interface is kubectl. We observed that a small set of commands usually covers most common scenarios:</p><pre># Is the job running or waiting for resources?<br>kubectl get pytorchjobs -n &lt;namespace&gt;<br># Why is it stuck in Suspended?<br>kubectl get localqueue &lt;queue&gt; -n &lt;namespace&gt; -o yaml<br># What is happening inside?<br>kubectl logs -f -l training.kubeflow.org/job-name=&lt;job&gt; -n &lt;namespace&gt;<br># For multi-node jobs, check each worker<br>kubectl logs &lt;job&gt;-worker-0 -n &lt;namespace&gt;<br>kubectl logs &lt;job&gt;-worker-1 -n &lt;namespace&gt;</pre><h3>The most common failure modes we encountered:</h3><ol><li>Suspended indefinitely, quota exhausted or no nodes match the nodeSelector.</li><li>Init container failure, incorrect S3 path or sourcedir.tar.gz not uploaded.</li><li>OOMKilled, batch size too large, gradient checkpointing disabled, or instance type too small for the model.</li><li>Distributed training hang, usually related to NCCL or EFA configuration.</li><li>Package install failure, required proxy environment variables missing from the container specification.</li></ol><p>In our experience, once these patterns are understood they become relatively straightforward to diagnose and resolve.</p><h3><strong>Key takeaways</strong></h3><p>For any teams building similar infrastructure, several lessons stood out to us:</p><ol><li>The GPU layer was only one part of the problem. Isolation, credential management, package distribution and resilience all mattered just as much, and often required more engineering effort.</li><li>Managed training services were an effective starting point. As usage grows, more flexible infrastructure became valuable, but that flexibility also shifted more responsibility to the platform team.</li><li>MIG partitioning improved efficiency for mixed workloads. Not every task needed a full A100. Hardware-enforced MIG slices allowed lighter inference, evaluation and exploratory workloads to share infrastructure cleanly.</li><li>NCCL issues were worth planning for early. Enabling NCCL_DEBUG=INFO during initial multi-node testing, verifying EFA transport, and running nccl-tests before large jobs saved substantial debugging time.</li><li>Isolation payed off quickly. Namespace, Kueue and IRSA boundaries per team reduced accidental cross-team impact and simplify quota enforcement.</li><li>Decoupling code from the container image improved iteration speed. The init container pattern kept the runtime stable while allowing training code to evolve independently.</li><li>Synchronous checkpointing was often the right trade-off. It introduced a small pause, but avoids ambiguous checkpoint state during failures.</li><li>Rank-0 coordination for checkpoint loading was important in multi-node training. It prevented unnecessary S3 load and kept all ranks aligned during resume.</li><li>Pre-staging models mattered in network-restricted environments. A shared S3 location gave teams fast, controlled access to approved foundation models without internet dependency.</li></ol><p><strong>Saurabh Sehgal </strong>— Staff Systems Engineer</p><p>Saurabh Sehgal is an Engineering Lead at CommBank, specialising in AI infrastructure, building the systems that enable machine learning to scale from experimentation to production. His work focuses on designing robust pipelines, automating deployments, and ensuring models remain reliable and observable over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/1*UsD3US4s7ZlEeVQqeVe7DQ.jpeg" /></figure><p><strong>Asad Younis </strong>— Principal Engineer</p><p>Asad Younis is a Principal Engineer at CommBank, where he leads the design and development of AI/ML and analytics platforms. He has been working on building scalable MLOps systems and enabling AI-driven solutions across the organisation, including platform capabilities for data, analytics, ML, and emerging AI use cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/1*ZgKwTvOA9mZPFQUfubeIig.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcde2ddb3f4e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/enterprise-grade-ai-infrastructure-with-aws-sagemaker-hyperpod-dcde2ddb3f4e">Enterprise-grade AI infrastructure with AWS SageMaker HyperPod</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Coral: Orchestrating AI Agents for Development at Scale]]></title>
            <link>https://medium.com/commbank-technology/project-coral-orchestrating-ai-agents-for-development-at-scale-fc301d1a787f?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc301d1a787f</guid>
            <category><![CDATA[aipe]]></category>
            <category><![CDATA[ai-engineering]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Thu, 21 May 2026 05:30:06 GMT</pubDate>
            <atom:updated>2026-06-25T03:11:56.859Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>One year on — what changed, what scaled and what we learnt</strong></h4><p>We previously shared the early story of Project Coral and how we were beginning to orchestrate AI agents for software development at scale. Our first post focused on an emerging idea: that software engineering could move beyond isolated coding assistants towards systems of agents, tools and humans working together. Since then, both Coral and the broader industry have moved quickly.</p><p>In this post, we reflect on what’s changed since we launched Coral, what we’ve learned from operating Coral at scale across the bank, and where we think this model of engineering is heading next. You can read the original post here: <a href="https://medium.com/commbank-technology/project-coral-how-were-orchestrating-ai-agents-for-development-at-scale-e0e11b9f0e2a"><em>Project Coral: How We’re Orchestrating AI Agents for Development at Scale</em></a>.</p><h3><strong>From experiment to engineering capability</strong></h3><p>Over the last year, Coral has gone from an interesting internal capability to an increasingly visible part of how software is changed across the bank. It is now contributing meaningfully to the day-to-day flow of engineering work: opening pull requests (PRs), reviewing PRs, identifying opportunities for uplift, and helping teams reduce repetitive toil.</p><p>On any given day, Coral is putting forward a significant number of PRs, reviewing many more and operating across a growing footprint of repositories and projects. Coral is no longer a narrow experiment on the edge of engineering. It has become part of the operational fabric of software delivery.</p><h3><strong>Project Coral in numbers</strong></h3><p>Coral is now available to all engineers across the bank, seamlessly integrating with the tech ecosystem and actively contributing to over 2,300 repositories.</p><p>Since its rollout, we have observed Coral driving significant impact at scale, such as:</p><ul><li>Surfacing over 12,800 technical debt issues</li><li>Raising more than 8,100 PRs</li><li>Reviewing over 17,300 unique PRs in the last 3 months alone</li></ul><p>This demonstrates how Coral is helping engineers move faster, improve code quality, and streamline collaboration across the organisation. Its impact matters, not only because of volume, but also because of the type of work being done. A large share of engineering effort in mature environments is not greenfield delivery; it is maintenance, documentation, standardisation, remediation and uplift. These tasks are often important, but they are also the ones most likely to be delayed, fragmented or inconsistently executed.</p><p>Coral has proven particularly effective in this space. It can spot patterns, apply repeatable changes, generate PRs with context, and participate in review loops in ways that reduce manual overhead while preserving engineering control. The impact is not just more PRs. It is more of the right work being done, with less friction.</p><h3><strong>The industry has moved quickly</strong></h3><p>The timing has been interesting. When we first introduced Coral, the industry was still largely centred on individual coding Co-pilots and early experimentation with agentic workflows. In the year since, the market has accelerated dramatically. Co-pilots have become mainstream, developer tooling vendors have moved quickly into more autonomous workflows, and the broader software ecosystem has started to converge on a more agent-oriented future, including standards and conventions such as AGENTS.md and agent skills.</p><p>That shift has validated much of the original direction behind Coral. But it has also clarified something important: capability alone is no longer the differentiator. The challenge is not just generating code. The challenge is building systems of agents, tools, workflows and governance that are reliable and useful inside real engineering organisations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h94lgi4lf5uBSUlalZtW7w.png" /></figure><h3><strong>From single agents to multi-agent systems</strong></h3><p>This is where Coral has continued to evolve. What began as orchestration of task-specific AI capabilities is increasingly becoming a platform for multi-agent systems. Rather than thinking about a single agent doing a single job, we’ve found that the more scalable model is a set of specialised agents, each with a defined role, equipped with skills, constrained by policy, and able to operate at both global and project-specific levels.</p><p>Some of those skills are universal across the estate. Others are tailored to specific repositories, teams or technology stacks. This distinction matters. engineering organisations do not operate as a single homogeneous surface. They operate as a mix of common platforms, local contexts and evolving standards. Supporting both global and per-project intelligence has become a core design principle.</p><h3><strong>Capability breakdown</strong></h3><ul><li>Global agents for estate-wide uplift and standardisation</li><li>Specialised agents that are integrated with continuous integration (CI) workflows</li><li>Project-level agents with local context and repository-aware behaviour</li><li>Reusable agent skills for common engineering workflows</li><li>Governed agent-to-agent handoffs between organisational units</li><li>Support for emerging agent interoperability and orchestration standards</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*kORfKzN_dapCoOf67u8zXg.png" /></figure><h3><strong>Early mis-steps and the way ahead</strong></h3><p><strong>What we encountered</strong></p><p>In the beginning, many Coral workflows required too much boilerplate. Automation existed, but it often depended on teams wiring together too much context, too many prompts, too many configuration elements, and too many manual hand-offs. In theory, this created flexibility. In practice, it created toil.</p><p>Engineers ended up doing work to prepare automation, rather than benefiting from automation that understood enough of the environment to be useful by default. Much of the boilerplate that had accumulated around these Coral workflows was not enabling scale; it was getting in the way of it.</p><p><strong>How we responded</strong></p><p>Coral reduced this boilerplate by adopting an event-driven architecture built on webhook-based integrations with systems like GitHub. Instead of waiting to be invoked in a narrow, explicit way, it subscribes to a stream of repository and lifecycle events delivered as HTTP call backs, each carrying structured payloads. These events are ingested and processed centrally in Coral’s orchestration layer, where they are normalised and enriched with execution context such as repository state, organisational policies, and prior outcomes. This allows Coral to make decisions that are aware not just of the event itself, but of the environment in which it occurred, and to determine whether and how to act. That shift turned out to be one of the most important architectural advantages of the platform.</p><p>The power was not just in generating output, but in being able to observe what was happening across the SDLC and respond appropriately. A dependency event, a policy change, a new engineering standard, a repository signal, a CI outcome, or a review state change: these are all inputs into a system that can act much more effectively than a one-shot assistant ever could. This ability to listen broadly and respond selectively is likely to remain one of Coral’s most important strengths.</p><p><strong>Event-driven examples</strong></p><ul><li>Dependency or library uplift, triggered by external advice or internal policy changes</li><li>Code quality improvement, triggered by CI workflows (e.g. Quality Gates)</li><li>PR review assistance, triggered by repository activity</li><li>Documentation or standards remediation, triggered by engineering guardrails</li><li>Execution of custom workflows, triggered by whitelisted non-Coral entities</li><li>Remediation of quality issues, triggered by investigations led by other agents</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*Gw6qEaS2cZZ0f-krZFUWeA.png" /></figure><h3><strong>Introducing cloud agents</strong></h3><p>To support that approach, we introduced cloud agents and expanded our operating model significantly. Moving beyond more constrained local or tightly coupled patterns allowed us to reduce onboarding friction, centralise capability where it made sense, and create a more elastic execution model. It also created a clearer separation between orchestration, agent execution, policy enforcement, context retrieval, and actioning against downstream systems.</p><p>That separation has made the platform more flexible and easier to evolve. It has also made the hard problems easier to identify.</p><h3><strong>What we learnt</strong></h3><p><strong>1. Multi-pass workflows outperform single-shot generation</strong></p><p>One of the clearest lessons from the last year is that multi-pass agents outperform single-shot agentic jobs for many classes of engineering work. Real engineering tasks are rarely linear. They involve interpretation, verification, iteration, reconciliation and review. A single agent producing one answer in one pass can be impressive, but it is often brittle. Multi-pass workflows, by contrast, allow for decomposition, checking, refinement and collaboration.</p><p>In practice, this meant moving Coral away from a single prompt that produces a final answer, and instead structuring work as a sequence of stages where intermediate outputs are generated, inspected, and fed into subsequent steps. Orchestration is then applied to sequence these steps properly, where different agents or prompts operate over shared intermediate state and can be invoked conditionally based on prior results. One agent identifies candidate changes, another validates them, another can explain or review them, and a human steps in at the right points.</p><p>This is slower than a pure “one prompt in, one answer out” model, but it is materially more useful when correctness, explainability and trust matter.</p><p><strong>2. Building orchestration is simple — running it is not</strong></p><p>A second lesson is that orchestration is foundational, but not the hardest part. Defining workflows, sequencing steps, and wiring together tools or agents is relatively straightforward with modern frameworks. In practice, this often looks like expressing workflows as directed graphs or step-based pipelines, where tasks can be triggered, retried, or conditionally executed based on intermediate results. The complexity does not come from defining the flow, but instead from making it behave reliably under real-world conditions.</p><p>Achieving this requires maintaining shared context across steps, persisting intermediate state, and coordinating execution when tasks are interdependent or partially complete. Failures are rarely clean; a step may succeed with low confidence, produce conflicting outputs, or depend on stale context. Handling this means introducing mechanisms for retries validation, reconciliation, and clear ownership of decisions across agents and humans. These systems also need to enforce trust boundaries and ensure consistent behaviour across long-running flows, even as inputs and state evolve.</p><p>This shifts the problem from simply designing workflows to operating a distributed system of loosely coupled components. As more agents, tools and humans are involved, the system starts to resemble an organisation as much as an application. Designing for this has required a shift in mindset from workflow design to operating model design.</p><p><strong>3. Reliable swarms depend more on trust &amp; governance boundaries than model capabilities</strong></p><p>That shift has also reinforced that trust and governance is always paramount. To produce working, high quality software, the technical excellence of individual models is less important than how multiple agents come together, and the rules which oversee multi agent interactions.</p><ul><li>Agents need clear authority boundaries</li><li>Actions need to be inspectable</li><li>Decisions need to be attributable</li><li>Controls need to be proportionate, and actionable</li></ul><p>We have found repeatedly that the importance of robust trust and governance is more important than technical excellence of one-shot models. If a powerful agent that cannot be trusted, audited, or safely delegated to, it does not create durable value, and it costs more time than it saves. Conversely, a more constrained system with strong policy, clear review paths and predictable behaviour can become deeply embedded in engineering workflows because people know how to work with it.</p><p><strong>4. Adoption Is won through fit, not firepower</strong></p><p>Related to the above point is another major lesson: adoption is not primarily a technical problem. It is a socio-technical one. Engineers do not adopt systems purely because they are clever, they adopt them when they are legible, reliable, low-friction and aligned with the way teams work.</p><p>This means that change management, interface design, team‑level trust and the path from suggestion to action all matter. In many cases, the hardest problem is not getting an agent to produce a change. It is creating the surrounding operating conditions in which that change is welcomed, understood and efficiently incorporated into delivery.</p><h3><strong>Looking ahead</strong></h3><p><strong>Coral as orchestrator and delegator…..</strong></p><p>Looking ahead, it’s likely that Coral’s role will continue to shift from direct doer towards orchestrator and delegator. It will still generate, review and act. But increasingly, its value will come from selecting the right capability at the right time across the engineering lifecycle. That includes routing work to specialised agents, selecting the right skills for a project context, applying policy-aware automation, and enabling group-wide operations that would otherwise be expensive to manage manually.</p><p>This is especially relevant for large-scale uplift and migration work, where consistency, reach and visibility matter as much as raw speed. We see strong potential for Coral to support broader bank-wide operations across repositories and projects: migrations to new standards, dependency and platform uplift, remediation campaigns, policy-aligned changes, and modernisation efforts that require action across a large and diverse estate.</p><p>These are exactly the kinds of changes that are difficult to execute consistently through decentralised manual effort alone. An orchestrated system, with the right controls and domain awareness, can make these programmes far more tractable.</p><p><strong>…..Towards an organisation wide coordinator for software engineering</strong></p><p>More broadly, it appears that the next frontier is an engineering way of working in which Coral acts as a global coordinator across software engineering work and the broader SDLC — not replacing human engineering talent, but building an intelligent layer that can understand signals, trigger the right capabilities, surface the right decisions, and maintain good controls and quality across a large engineering ecosystem.</p><p>In that world, the value of the platform is not merely that it can write code. It is that it can help align change across people, repositories, standards, tools and governance requirements.</p><h3><strong>Conclusion</strong></h3><p>A year on, our perspective is clearer and our confidence is stronger than when we began. The future of AI in engineering is not just better agentic tools and autonomous code generation. It is shaped by policy-aware, event-driven systems that can operate across the full lifecycle of software delivery. Coral has helped us explore this future in practice and has become a meaningful expression of this approach.</p><p>The technical frontier remains important, but the next phase will be defined just as much by governance, trust and how effectively these systems can operate within the organisation. These aren’t secondary concerns. They are the conditions that will determine whether agentic engineering systems become genuinely foundational.</p><h3><strong>Contributors</strong></h3><p><strong>Project Coral Team:</strong> David Hong, Chang Liu, Henry Chan, Shamron Singh, Gabriel Chee, Jonathan Tang, Li Ching Tan, Ling Chen, Mary Huang, Mia Liao, Nikki Shao, Rita Truong, Ryan Haque, and Coral</p><p><strong>Special Thanks to:</strong> AI Powered Engineering Crew, Andrew Shu, Ange Lin, Marcella Bava, Artem Bednarchuk, Brent Mckendrick, Julian Walker, Martha McKeen, Rodrigo Castillo</p><p><strong>Other GitHub Contributors:</strong> Carlos DAgostino, Isuru Ranatunga, Max Ovington</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc301d1a787f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/project-coral-orchestrating-ai-agents-for-development-at-scale-fc301d1a787f">Project Coral: Orchestrating AI Agents for Development at Scale</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Privacy-preserving machine learning with homomorphic encryption]]></title>
            <link>https://medium.com/commbank-technology/privacy-preserving-machine-learning-with-homomorphic-encryption-506f932da330?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/506f932da330</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-privacy]]></category>
            <category><![CDATA[homomorphic-encryption]]></category>
            <category><![CDATA[logistical-regression]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Fri, 13 Mar 2026 03:07:13 GMT</pubDate>
            <atom:updated>2026-03-13T03:09:04.972Z</atom:updated>
            <content:encoded><![CDATA[<p>Generative AI is moving fast: breakthroughs make the news almost daily, but so do stories about <a href="https://en.wikipedia.org/wiki/Prompt_injection">prompt injections</a> and <a href="https://simonwillison.net/tags/exfiltration-attacks/">exfiltrated private data</a>.</p><p>At CommBank AI Labs we focus on exploring innovative technologies and challenging ourselves with hypotheticals that seem impossible. Could we perform LLM inference without the model ever being exposed to the raw prompt? Can we use MCP servers without worrying about leaking our private data?</p><p>In this post, we explore <a href="https://en.wikipedia.org/wiki/Homomorphic_encryption">Homomorphic Encryption</a> (HE), an innovative privacy-enhancing technology that allows for useful computations to be executed directly on encrypted data without exposing the underlying plaintext data itself.</p><p>We will look at running inference with machine learning models on customer data without ever needing to reveal the raw data. It is also important to understand why homomorphic encryption is not yet ready for most latency-sensitive production use cases, and what it will take to get it there.</p><p><strong>What is homomorphic encryption?</strong></p><p>Whenever you log in to your banking app or browse the web, a flurry of back-and-forth activity is instigated between your browser or device and the server handling your request. When the World Wide Web was nascent, there were no practical security measures to prevent this flow of traffic from being intercepted. Any nefarious actor could tap these transmissions and discover your banking details or read the contents of the pages you were accessing. To remedy this, cryptographic protocols were adopted to provide <a href="https://en.wikipedia.org/wiki/Transport_Layer_Security"><em>Transport Layer Security</em></a> (TLS).</p><p>Whilst TLS is apt for protecting your data<strong> </strong>in transit, it does not address a broader question about privacy and access to sensitive data. In the cybersecurity world, it is considered best practice to abide by the <em>Principle of Least Privilege</em>: every system that accesses data or executes commands should be granted should be granted only the minimum privileges required to perform its task. This helps isolate the impact of a potential exploit or breach in any subsystem. In an ideal world, it would be possible to avoid revealing private data to the server at all, while still being able to use internet services.</p><p>Homomorphic encryption is a cryptographic development that allows an untrusted party to perform specific computations on encrypted data<strong> without ever having to see the raw data</strong>.</p><p>Here’s an illustrative example. Imagine you <em>encrypt</em> a secret number, <strong>4, </strong>and send it to a server. With homomorphic encryption, the server can add the number <strong>7 </strong>to your encrypted <strong>4</strong> without ever having to see your raw number. When you <em>decrypt</em> the result, you still get <strong>4+7=11</strong>, just as if the calculation had been performed on the raw numbers.</p><p>To reiterate, only you, the sender, would <strong>ever</strong> be able to see the raw input (<strong>4</strong>) and output (<strong>11</strong>) using your private decryption key. The server computes on an encrypted ciphertext payload that is indistinguishable from noise and cannot be feasibly reversed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FoqGJRSW980hria1QnCTnQ.png" /></figure><p>We won’t dive into the mathematical machinery behind <em>how</em> this works here. Suffice it to say that modern homomorphic encryption schemes depend on the cryptographic hardness of the <a href="https://en.wikipedia.org/wiki/Learning_with_errors">Learning with Errors Problem</a>, a type of lattice problem. The <em>homomorphism</em> in the name comes from the ability to preserve algebraic structure between the plaintext space and the ciphertext space. Specifically, the primitive arithmetic operations you can perform with HE includes addition and multiplication (with some schemes allowing for table lookups and other operations). If you’re interested in a more foundational mathematical treatment, please have a read through <a href="https://www.jeremykun.com/2024/05/04/fhe-overview/">this fantastic primer</a>. For the rest of this post, we focus on applications and outline how we envisage this technology being used in the future.</p><p><strong>How do homomorphic encryption and machine learning complement each other?</strong></p><p>Homomorphic encryption enables computations to be carried out directly on encrypted data, so sensitive information remains protected throughout the process. In the context of machine learning, this means models can be trained or used for inference on encrypted datasets, without ever exposing the raw data. This approach allows organisations to draw valuable insights and make predictions while maintaining strict privacy standards, as neither the server nor the model ever sees the unencrypted customer data.</p><p>While seemingly fantastical, it turns out that this is possible! Recall that homomorphic encryption allows for very few primitive operations, but much as the <a href="https://en.wikipedia.org/wiki/NAND_gate">NAND gate</a> is functionally complete for Boolean functions, we can <em>compile </em>homomorphic encryption operations into a ‘circuit’ that can evaluate more complex machine learning functions.</p><p><strong>Building a logistic regression classifier model for transaction embeddings</strong></p><p>At AI Labs, we’ve built small proof-of-concept machine learning models that<strong> run inference on encrypted data </strong>to experiment with state-of-the-art homomorphic encryption tooling.</p><p>The code snippet below demonstrates training a logistic regression classifier against a salary credit label using vector embeddings of transactions data as the feature input.<strong> </strong>After training, we compile the model into a quantised version that can execute on <em>encrypted</em> transaction embeddings using<strong> </strong>homomorphic encryption. Crucially, we observe parity in precision and accuracy between executing the model over encrypted and unencrypted embeddings features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdIxzNUtMvUpv-2zpQrwuQ.png" /></figure><pre>import pandas as pd<br>import numpy as np<br><br>from concrete.ml.sklearn import LogisticRegression as HELogisticRegression<br><br>from sklearn.model_selection import train_test_split<br>from sklearn.preprocessing import StandardScaler<br>from sklearn.linear_model import LogisticRegression<br>from sklearn.metrics import ConfusionMatrixDisplay<br><br># %% Load the raw data<br># | description                      | salary_credit_flag | tran_vect_y                   |<br># |----------------------------------|--------------------|-------------------------------|<br># | SALARY CREDIT COMMBANK           | true               | [0.0234, 0.0156, ...]         |<br># | REGRESSION SUPERMARKET MELBOURNE | false              | [0.0145, 0.0298, ...]         |<br># | FORTNIGHTLY PAY LOGISTICS        | true               | [0.0287, 0.0091, ...]         |<br># | ENCRYPTION FUEL SYDNEY NSW       | false              | [0.0178, 0.0234, 0.0056, ...] |<br># | WEEKLY WAGES MODELLING           | true               | [0.0321, 0.0142, 0.0098, ...] |<br>transactions = pd.read_parquet(&#39;sample_credits_embeddings.parquet&#39;)<br>label = &quot;salary_credit_flag&quot;<br><br># %% Prepare dataset for modelling by exploding the transaction vector embeddings<br>EMBEDDINGS_DIMENSIONS = 768<br>feature_cols = [f&quot;feature{i}&quot; for i in range(EMBEDDINGS_DIMENSIONS)]<br>exploded_embeds = pd.DataFrame(<br>    np.vstack(transactions[&quot;tran_vect_y&quot;]),<br>    columns=feature_cols<br>)<br>data = pd.concat([transactions.drop(columns=&quot;tran_vect_y&quot;), exploded_embeds], axis=1)<br><br># %% Create a stratified train and test set<br>X, y = data[feature_cols], data[label]<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=data[label], random_state=0)<br># X_train.shape=(80000, 768) and y_train.shape=(80000,)<br># X_test.shape=(20000, 768) and y_test.shape=(20000,)<br><br># %% Using a standard scaler on the embedding features massively improves model performance.<br># For more information on the interplay between feature transformations and FHE quantisation, please see<br># https://github.com/zama-ai/concrete-ml/blob/release/1.9.x/docs/advanced_examples/LogisticRegression.ipynb<br>scaler = StandardScaler().fit(X_train)<br>X_train_s, X_test_s = scaler.transform(X_train), scaler.transform(X_test)<br><br># %% Train the logistic regression model &quot;in the clear&quot;<br>model = LogisticRegression().fit(X_train_s, y_train.astype(int))<br><br># %% Generating predictions &quot;in the clear&quot; on our test set is almost instantaneous!<br>y_pred = model.predict(X_test_s)<br><br># %% How good is our model?<br>ConfusionMatrixDisplay.from_estimator(model, X_test_s, y_test, values_format=&#39;d&#39;)<br><br># %% Define an encrypted, quantised model using concrete-ml:<br>cml_model = HELogisticRegression.from_sklearn_model(model, X_train_s, n_bits=8)<br><br># %% Compiling the model takes 15 seconds as a once-off cost<br>cml_model.compile(X_train_s)<br>print(cml_model.fhe_circuit)<br><br># %% Run the prediction in the clear using *simulated* FHE takes 40 seconds<br>y_pred_simulate = cml_model.predict(X_test_s, fhe=&quot;simulate&quot;)<br><br># %% Running the prediction fully using FHE is extremely slow!<br># But we can run this on 1000 samples to estimate the additional overhead of FHE models<br>fhe_samples = 1000<br>y_pred_fhe = cml_model.predict(X_test_s[:fhe_samples], fhe=&quot;execute&quot;)<br><br># %% Sanity check that probabilities for test samples are the same whether encrypted or not!<br>(<br>    cml_model.predict_proba(X_test_s[:2], fhe=&quot;simulate&quot;), <br>    cml_model.predict_proba(X_test_s[:2], fhe=&quot;execute&quot;)<br>)<br>#(array([[9.99999908e-01, 9.21928652e-08],<br>#        [9.99945497e-01, 5.45032043e-05]]),<br># array([[9.99999908e-01, 9.21928652e-08],<br>#        [9.99945497e-01, 5.45032043e-05]]))</pre><p>Running both the ordinary Logistic Regression model on plaintext embeddings and the compiled model on <em>encrypted</em> embeddings results in the same model classification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*FKtyWhIJth4KeovlUJoe5w.png" /></figure><p>The example code above was executed on an AWS r7i.2xlarge instance without GPU acceleration. I’ve elided some of the uninformative code here, but the key point to note is that constructing a model from a pre-trained <a href="https://scikit-learn.org">sklearn</a> model is as simple as:</p><pre>HELogisticRegression.from_sklearn_model(model, X_train_s, n_bits=8)</pre><p><strong>So, what’s the catch?</strong></p><p>The biggest roadblock to more widespread adoption of homomorphic encryption for machine learning pipelines is the runtime overhead of running inference under a FHE scheme. Requests often require transmitting large ciphertexts between the client and server. This communication overhead is in addition to the substantial processing and memory required on the server to perform the computation. Altogether, computing under homomorphic encryption schemes can take orders of magnitude longer than equivalent plaintext computation.</p><p>In the logistic regression example above, performing inference with the logistic regression model under FHE is equivalent to executing this compiled circuit:</p><pre>%0 = q_X                            # EncryptedTensor&lt;int8, shape=(1, 768)&gt;  ∈ [-128, 127]<br>%1 = [[  -7] [  ... 1] [ -49]]      # ClearTensor&lt;int8, shape=(768, 1)&gt;      ∈ [-128, 127]<br>%2 = matmul(%0, %1)                 # EncryptedTensor&lt;int19, shape=(1, 1)&gt;   ∈ [-144397, 70774]<br>%3 = sum(%0, axis=1, keepdims=True) # EncryptedTensor&lt;uint13, shape=(1, 1)&gt;  ∈ [5049, 5715]<br>%4 = -13                            # ClearScalar&lt;int5&gt;                      ∈ [-13, -13]<br>%5 = multiply(%4, %3)               # EncryptedTensor&lt;int18, shape=(1, 1)&gt;   ∈ [-74295, -65637]<br>%6 = subtract(%2, %5)               # EncryptedTensor&lt;int19, shape=(1, 1)&gt;   ∈ [-75029, 140974]<br>%7 = [[-29680]]                     # ClearTensor&lt;int16, shape=(1, 1)&gt;       ∈ [-29680, -29680]<br>%8 = add(%6, %7)                    # EncryptedTensor&lt;int18, shape=(1, 1)&gt;   ∈ [-104709, 111294]<br>return %8</pre><p>Executing the compiled logistic regression model on encrypted embeddings takes 2 <em>minutes</em> for just 1000 samples and uses gigabytes of memory. That’s over 40 minutes of execution time to predict just 20,000 samples. In contrast, generating predictions “in the clear” with the regular model on the same test set of 20,000 samples is close to instantaneous.</p><p>We should point out that there’s only 768 features in our example, imagine the latency overhead when running inference over deep neural networks or computing forward passes of transformer language models under FHE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*rrHGl7Nxqbg37H85S8jsWw.jpeg" /></figure><p>The figures here are indicative and were measured on a single machine. We’re ignoring networking communication overhead between the client and server, which is pronounced when using a homomorphic encryption scheme.</p><p>Fortunately, homomorphic encryption is a <a href="https://eprint.iacr.org/search?q=Homomorphic+encryption">very actively researched</a> area, with more efficient schemes and algorithmic developments being constantly developed. An exciting avenue of exploration is the use of GPUs and purpose-built hardware to accelerate the compute workload. If you want to see more <a href="https://docs.zama.ai/concrete-ml/tutorials/ml_examples">examples</a> and try your own hand at it, I’d recommend exploring the <a href="https://docs.zama.ai/concrete-ml">concrete-ml</a> library from Zama.</p><p><strong>What’s next?</strong></p><p>Imagine <strong>private MCP servers </strong>with the rapid adoption of Agentic AI and LLM-powered code assistants, it is becoming increasingly prevalent to couple executable systems with LLM prompts via tool calls and MCP servers. However, such workflows are often vulnerable to prompt injection attacks and can be exploited to exfiltrate data. But imagine a future where you could hand off encrypted data to an MCP server, and have usable results returned to you, all without having to hand over your raw data.</p><p>The holy grail of homomorphic encryption is <strong>Private Transformer Inference</strong>. It has become increasingly common for users of Large Language Models to ask questions that include <a href="https://openai.com/index/helping-people-when-they-need-it-most/">highly sensitive personal information</a> as context. Model providers often apply input guardrails to redact personally identifiable information (PII) or block sensitive prompts, adding complexity and latency overhead. Homomorphic encryption suggests a different possibility: encrypt the prompt before it is sent to the model and allow the model to generate a response over encrypted representations. In such a setup, the model provider would not be able to see either the prompt or the response in plaintext.</p><p>In principle, it is possible to perform LLM inference using HE today, but the overhead of existing schemes is such that generating even a single token with a small model could take multiple hours.</p><p>It’s not all doom and gloom for HE in production though, Homomorphic encryption forms a sort of cryptographic ‘primitive’ that can interoperate with other privacy-enhancing technologies. For instance, Apple’s <a href="https://machinelearning.apple.com/research/homomorphic-encryption">Live Caller ID</a> uses BFV, a type of Fully Homomorphic Encryption, alongside a Private Information Retrieval database scheme to efficiently serve hundreds of millions of customers in a privacy-preserving manner.</p><p><strong>Conclusion</strong></p><p>Homomorphic encryption is an increasingly active field of research. <a href="https://eprint.iacr.org/search?q=homomorphic">New publications</a> push the boundaries of what is feasible with today’s hardware and protocols, and exciting advances are being made to build <a href="https://spectrum.ieee.org/fhe-intel">special-purpose chipsets</a> to accelerate homomorphic encryption computation.</p><p>CommBank AI Labs is excited about the potential of novel privacy-enhancing technologies, including homomorphic encryption, and is actively exploring the applicability of homomorphic encryption in our AI and machine learning pipelines. We look forward to sharing more with you in the future as the technology matures.</p><p>If you’d like to get in touch, please reach out to Yossi Frenkel at <a href="https://au.linkedin.com/in/y-frenkel">LinkedIn</a> or<em> </em>contact<em> </em>CommBank<em> </em>AI Labs at <a href="mailto:AILabs@cba.com.au?subject=Homomorphic%20Encryption">AILabs@cba.com.au</a>.</p><p>Yossi is an AI Researcher at CommBank AI Labs. His work focuses on bringing ideas from mathematics and computer science into practical machine learning systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*8yP12ujdsKg-iD-JUe7HDg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=506f932da330" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/privacy-preserving-machine-learning-with-homomorphic-encryption-506f932da330">Privacy-preserving machine learning with homomorphic encryption</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using GenAI To Make The Perfect Cup Of Tea]]></title>
            <link>https://medium.com/commbank-technology/using-genai-to-make-the-perfect-cup-of-tea-5153aa204714?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/5153aa204714</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 23:43:30 GMT</pubDate>
            <atom:updated>2025-11-20T23:43:30.173Z</atom:updated>
            <content:encoded><![CDATA[<p>You could author a Standard Operating Procedure (SOP) to make a good cup of tea. But SOPs can fall short when dealing with the complexities of real-world situations. You wouldn’t refill and re-boil the kettle if the kettle had just boiled. If someone came along and removed the cup, you wouldn’t just flood your countertop with boiling water.</p><p>In organisations we write SOPs to ensure consistency, measurability and quality. We typically manage ‘happy paths’ well, but often leave complex exception paths for experienced staff to figure out.</p><p>In this article I’ll describe how we’re using AI smarts to make our processes more resilient. I hope these insights will help you, fellow AI practitioners, make your processes more resilient; remove human exception processing; and ensure you don’t flood your countertop with boiling water.</p><p><strong>Defining our world</strong></p><p>The world consists of state. In our example:</p><ul><li>The temperature of the water in the kettle</li><li>The contents of your cup (have you put milk in — or heaven forbid sugar)</li><li>Has the tea been mashed etc.</li></ul><p>There are things we can do to affect state: (in AI these might be considered tools)</p><ul><li>Turn the kettle on</li><li>Retrieve a cup from the cupboard</li><li>Put a teaspoon of sugar in the cup etc.</li></ul><p><strong>Engineering a process the traditional way</strong></p><p>This could be the process for making a tea:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/0*2kUwvToIbooZznxM.png" /></figure><p><strong>Process for making tea</strong></p><p>You could easily code this process using your language / state machine / directed graph of choice. Alternatively, you could use GenAI to determine the flow — embedding the SOP into the LLM prompt.</p><p>No matter which approach you use, however, encoding a Standard Operating Procedure suffers from the same issues.</p><p><strong>The traditional way is broken</strong></p><p><strong>Changes of state</strong></p><p>Processes are typically very unaccommodating of unexpected changes in state. In a large multiuser system state can regularly shift ‘underneath’ a process. A naively implemented cuppa tea SOP simply could not adapt if someone came along and turned off the kettle before it boiled, or added a second teabag to the cup.</p><p><strong>Exception management</strong></p><p>Exceptions are thrown when the current state does not match expectations. Typically an exception gets recorded somewhere and a human is called on to investigate. Going forward we want AI to handle not just happy paths but all paths. We need to consider if our system’s designed to fail healthily; is it a valid strategy to just try a bunch of things until one succeeds or does an exception leave a trail of unstable state in its wake?</p><p><strong>Unexpected changes in customer demands</strong></p><p>Customers’ needs often change over time, especially with long-running processes. Circumstances can shift, a merchant might deliver goods while a credit card transaction is being disputed, or the credit limit being requested could change. A well-designed process should accommodate changes in requests without starting over or requiring human intervention. Work should be redone where necessary, but already completed and correct work should not be discarded wastefully.</p><p><strong>Failing forward</strong></p><p>Processes should ideally be designed to fail forward. When something unexpected occurs, data and customers can be left in an undesirable state; the process should be intelligent enough to continue moving toward the desired outcome. Good implementations of a process might roll back, but more often (especially for low-value or high-complexity operations) a human will likely be called in to hopefully make sense of the mess.</p><p><strong>Long running process</strong></p><p>Long-running processes (e.g., a home loan application that can take weeks) are particularly challenging. How should in-flight processes be handled when process or policy changes occur? Should certain steps be rerun? Should we just start again? Should we consider “grandfathering” — locking in the process definition at the time of instance creation? Ideally, we would intelligently determine which steps need reworking and apply the same principles of failing forward.</p><p><strong>Prevents service evolution</strong></p><p>Processes consume external services. Services are often leaky abstractions, forcing process authors to understand the internal operations and side effects of every service they use. At scale, this becomes highly problematic, leading to rigid, deadlocked systems where changing or evolving service implementations becomes nearly impossible.</p><p><strong>Prevents business evolution</strong></p><p>Processes are point-in-time calcifications of policy, any policy change requires a review of all affected processes. This dependency slows the organisation’s potential rate of change, as processes must be reviewed, regression tested and updated with every change in policy.</p><p><strong>A better way of making tea</strong></p><p>AI offers new ways to engineer businesses to be more agile and resilient in the face of changes, whether in processes, services, policies, underlying state, customer demands, or system availability.</p><p><strong>Use emergent (rather than explicit) process</strong></p><p>Instead of defining process and adhering to a process — you can reframe it as policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YIbQRZaf7c5RRL8sC_GS1w.png" /></figure><p>These policies are absolute truths. Process, rather than being prescribed, emerges from constraints defined in the policy.</p><p>You can determine what to do next based on what can be done next.</p><p>It is important to note that the failure states of these systems differs from conventional process-based systems. Incompletely specified policy can lead to loops or stagnation where no valid next operation exists, though tests can be written to detect these conditions. However, by adhering to well-crafted policy statements you can reliably get the desired outcome, irrespective of how state, customer requests, or the machinery of execution change, or fail underneath you.</p><p><strong>Don’t code — interpret</strong></p><p>Business documentation (policy / procedures etc) should be written for human and AI consumption. Ongoing advances in GenAI Code generation (Cursor, Cline, Roo etc) are making it easier to convert well-written human readable documentation into executable code.</p><p>Business policy can be interpreted into code at design-time or at run-time.</p><p><strong>Design time interpretation of policy</strong></p><p>One approach is to use AI to consume and interpret Policy documents &amp; emit code to execute that policy. A design time approach has many benefits</p><ul><li>Artifacts can be vetted for correctness before they are published.</li><li>Completeness/correctness can be verified through generated unit tests.</li><li>The implementation will perform consistently correctly — a benefit of deterministic over stochastic.</li><li>Changes to the underlying documentation can be detected and pull requests automatically generated to update code artifacts. Continuous consistency.</li></ul><p><strong>Run-time interpretation of policy</strong></p><p>The other approach is run-time interpretation of policy using AI. This approach is becoming increasingly viable as AI becomes more powerful, cheaper and more trusted within organisations.</p><p>Run-time AI implementations give you full runtime flexibility. The ability to, given any system state and requirement, adlib and fail forwards towards consistently successful outcomes. Assuming you can do it safely.</p><p><strong>Adlib, safely</strong></p><p>The greatest strength of runtime AI is its unpredictable stochastic nature, but to run an effective business you still need to ensure quality outcomes.</p><p><strong>Policy</strong></p><p>Detailing and enforcing policy ensures fundamental business tenets are not broken, irrespective of any small mistakes made &amp; corrected.</p><p><strong>Execute safely — APIs should not leave a mess</strong></p><ul><li>APIs (tools) should be written explicitly for AI consumption.</li><li>APIs should not execute if preconditions are incorrect (e.g. don’t attempt to turn on a kettle if it is empty), if an error occurs, they should not leave inconsistent state behind.</li><li>APIs should execute with the correct authority and scope. An API to turn on the kettle should not execute with admin access, it should not have the power to turn on all kettles in your building, it should not have the scope to act on any kettle other than the one in front of you.</li><li>A robust set of tools can give you the confidence to execute an API knowing the blast radius of any error is minimal &amp; that any error can be record from failing forward.</li></ul><p><strong>Reconcile Outcomes</strong></p><p>Measure outcomes of your actions and reconcile them against expected outcomes. Don’t trust the process, measure the results. At the end of the day teas drunk should equal teas requested. Any discrepancy necessitates investigation.</p><p><strong>In conclusion</strong></p><p>Traditional Standard Operating Procedures (SOPs) often fail to handle unexpected changes or exceptions in processes, leading to inefficiencies and the need for human intervention. By leveraging GenAI to interpret flexible policies rather than executing rigid step-by-step instructions, organisations can build more resilient, adaptive systems that handle both standard operations and real-world complexity.</p><p><em>(* my family originally come from the UK midlands — there we don’t brew tea — we make proper tea — we mash our tea)</em></p><p><em>Edward Gallimore — Distinguished Engineer, Commonwealth Bank</em></p><p><em>Ed is a </em><strong><em>Distinguished Engineer</em></strong><em> at CommBank, where he leads strategic initiatives to advance engineering excellence and innovation across the organisation.</em></p><p>Disclaimer: This is Ed’s personal opinion and does not reflect the view’s of the Commonwealth Bank of Australia. In this article, “policy” refers to the technical concept of a policy, and not a legal or compliance policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/0*CrIjcqVUZvgX42CN.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5153aa204714" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/using-genai-to-make-the-perfect-cup-of-tea-5153aa204714">Using GenAI To Make The Perfect Cup Of Tea</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enforcing Compliance While Retaining Agency: A Rule-Based Policy Engine Approach for ReAct Agents]]></title>
            <link>https://medium.com/commbank-technology/enforcing-compliance-while-retaining-agency-a-rule-based-policy-engine-approach-for-react-agents-a9a8a1b4a88c?source=rss-8809ccabadac------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9a8a1b4a88c</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[react-agent]]></category>
            <dc:creator><![CDATA[CommBank Innovation & Technology Blog]]></dc:creator>
            <pubDate>Fri, 05 Sep 2025 06:52:45 GMT</pubDate>
            <atom:updated>2025-11-11T23:01:06.170Z</atom:updated>
            <content:encoded><![CDATA[<p>Many enterprises are rushing to build and deploy agentic applications. These applications replace hard-coded workflows through LLM-based reasoning and planning, leading to significant productivity gains and a more fluid, natural user experience. However, LLMs have their quirks: they hallucinate, they’re non-deterministic, and they don’t follow instructions 100% of the time. As a result, we need to put in extra effort to ensure that agentic applications comply with existing policies and avoid breaking system integrity.</p><p><strong>Why prompt engineering and LLM-based guardrails are insufficient</strong></p><p>There are two well-known techniques to ensure LLMs behave well in enterprise settings: prompt engineering and LLM guardrails. However, both techniques are non-deterministic in themselves, and we cannot rely on them to enforce certain hard business or compliance rules that must never be violated.</p><p>A common example of this type of hard security compliance rule is that before updating sensitive user records (phone number or address), you must run identity verification (IDV). Neither prompt engineering nor common guardrails can guarantee an AI agent would follow the rule without failure.</p><p><strong>The wrong way: over-constraining agents leads to robotic behaviour</strong></p><p>Engineers are familiar with handling constraints when building traditional deterministic software, constraints are simply baked into deterministic workflows. When certain pre-conditions aren’t met, users simply cannot move forward. Over the years, enterprise applications have accumulated thousands of these workflows and SOPs, and these are precisely what agentic AI is supposed to replace.</p><p>When building agentic systems that must comply with business rules, some engineers fall back to old habits and simply map existing workflows and SOPs into LLM calls in almost 1:1 correspondence. For example, you can directly map SOPs and workflows into a LangGraph DAG. However, these “translated” workflows often underutilise the planning and reasoning capabilities of AI agents, leading to poor user experience.</p><p><strong>Example: A hypothetical travel booking system</strong></p><p>Let’s use a hypothetical travel booking system as an example. An existing workflow might be structured as follows: 1. Choose a destination city 2. Choose a starting city 3. Choose a transportation type (bus, train, flight) 4. Based on each transportation type, there is a sub-workflow for making additional adjustments 5. Confirm selection 6. Submit booking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*fH9pUu6vAI5cfW0oe0RqBg.png" /><figcaption>Hypothetical ticket booking workflow</figcaption></figure><p><strong><em>Figure 1: A hypothetical ticket booking workflow</em></strong></p><p>If you translate this workflow into a chat-based AI agent and map every step into a node in LangGraph with every transition requiring an LLM call, the user experience would feel robotic. For example, when a user types “I want to travel from Sydney to Melbourne by train on Tuesday morning,” the system would fail to exploit the fact that the user has provided all necessary information to skip steps 1–3 and even narrow down the options in step 4.</p><p><strong>Additional problems with this approach:</strong></p><p>1. <strong>Poor handling of interruptions</strong>: Suppose the user initially starts booking a flight ticket (state 4.2) but changes their mind and wants to switch to a train instead. Our agent wouldn’t allow that pivot unless we exhaustively add every possible transition path.</p><p>2. <strong>High maintenance cost</strong>: If the business operating model changes slightly, the over-specified agent behaviour would require significant code changes, instead of relying on the LLM’s own reasoning and planning capabilities to adapt.</p><p><strong>The right way: retaining agency while ensuring compliance</strong></p><p>How can you build a compliant AI agent while maximizing its agency and autonomy? The key is to recognise the different types of constraints enforced in existing business workflows: enforce the hard rules deterministically while minimizing their interference with LLMs, and leave the rest to LLM prompt instructions, leveraging their reasoning and planning capabilities as much as possible.</p><p><strong>Understanding two types of constraints</strong></p><p>When you examine existing enterprise workflows and SOPs, you notice that workflow steps can be largely separated into two categories:</p><p>1. <strong>Technology-driven constraints</strong>: Steps that exist purely because of limitations in existing technology. Sub-problems were broken down to make them easier to solve. Steps 1–3 in our travel example had to be done sequentially in the past because GUI-based deterministic UX was the only feasible technology to accurately capture user intentions. Today, LLMs fundamentally reset this paradigm.</p><p>2. <strong>Compliance-driven constraints</strong>: Steps that must be taken regardless of technology choice, for example, ensuring users have a chance to confirm their order before submitting it. No matter what UX design we choose, this rule must be followed to the letter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*TAK69ynUSMLwMER3_KD1sw.png" /><figcaption><strong><em>Existing workflows work under two types of constraints</em></strong></figcaption></figure><p><strong><em>Figure 2:</em></strong><em> Existing workflows work under two types of constraints.</em></p><p>In practice, only a small portion of existing workflows fall into the second category. After separating these two types of constraints, you can introduce a better design paradigm:</p><p>· <strong>Distill and enforce</strong>: A small set of policy rules (compliance-driven constraints) are distilled and enforced strictly</p><p>· <strong>Simplify and empower</strong>: The rest of the workflows are simplified and rewritten into LLM prompts, giving LLMs flexibility to plan dynamically according to conversation flow</p><p><strong>My approach: deterministic policy enforcement</strong></p><p>I follow three core principles when enforcing hard business rules:</p><p>1. <strong>Structured state management</strong>: Keep policy-related data as structured and strongly typed state (e.g., Pydantic models) outside of LLM chat history and prompts. This structured state serves as our single source of truth against LLM hallucinations and failures.</p><p>2. <strong>Controlled state updates</strong>: Updates to this state occur only during tool calls, and the updated state is rendered as LLM-friendly messages as feedback, ensuring the agent remains aware of the current state.</p><p>3. <strong>Pre-execution rule checking</strong>: Compliance rules are checked at the beginning of every tool call, preventing LLMs from causing real side effects even when their reasoning is flawed. When violations inevitably occur, an explainable reason is returned so the agent can replan or ask the user for guidance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*b1uivTnGkdQ6wmUIYdOHNQ.png" /><figcaption><em>Overall architecture and how LLMs work in tandem with a deterministic rule-based policy engine:</em></figcaption></figure><p><strong><em>Figure 3: Tool calls as boundary to ensure system integrity and compliance</em></strong></p><p><strong>Important note</strong>: The policy engine is not a replacement for LLM-based guardrails but rather brings determinism to codifiable policies.</p><p><strong>Implementation: a concrete example</strong></p><p>To make these concepts concrete, I built a toy example using two different frameworks (LangChain and Semantic Kernel).</p><p><strong>🔗 Code repositories:</strong> — <a href="https://github.com/smartnose/policy-enforcer">LangChain implementation</a> — full source code — <a href="https://github.com/WeiOnThePike/policy-enforcer-sk">semantic kernel implementation</a> — alternative framework implementation.</p><p><strong>The Scenario</strong></p><p>In this example, the AI agent helps plan weekend activities. Users can choose from camping, swimming, or playing video games, and the agent must follow these rules (only a selected set is shown here for brevity):</p><p>1. <strong>Gaming requirements</strong>: Users must have a TV and an Xbox before they can play games</p><p>2. <strong>Camping requirements</strong>: Users must have hiking boots before they can go camping</p><p>3. <strong>Swimming requirements</strong>: Users must have goggles before they can go swimming</p><p>4. <strong>Weather restrictions</strong>: If it’s raining, users cannot go camping</p><p>The following sections demonstrate how we implement the three core principles outlined above.</p><p><strong>Principle 1: structured state tracking</strong></p><p>I maintain important state data as our source of truth, separate from LLM interactions:</p><pre>class AgentState(BaseModel):<br>    &quot;&quot;&quot;<br>    Tracks the current state of the agent including user inventory,<br>    weather conditions, and activity choices.<br>    &quot;&quot;&quot;<br><br>    # User inventory<br>    inventory: Set[str] = Field(default_factory=set, description=&quot;Items the user owns&quot;)<br><br>    # Weather state<br>    weather: WeatherCondition = Field(<br>        default=WeatherCondition.UNKNOWN, description=&quot;Current weather condition&quot;<br>    )<br>    weather_checked: bool = Field(<br>        default=False, description=&quot;Whether weather has been checked&quot;<br>    )<br><br>    # Activity state<br>    chosen_activity: Optional[Activity] = Field(<br>        default=None, description=&quot;User&#39;s chosen activity&quot;<br>    )<br><br><br>class WeatherPlugin(PolicyEnforcedPlugin):<br>    &quot;&quot;&quot;Plugin for weather-related functions.&quot;&quot;&quot;<br><br>    @kernel_function(<br>        description=&quot;Check the current weather condition. Returns a random weather condition.&quot;,<br>        name=&quot;check_weather&quot;,<br>    )<br>    def check_weather(self) -&gt; Annotated[str, &quot;Current weather condition with status&quot;]:<br>        &quot;&quot;&quot;Check the weather condition.&quot;&quot;&quot;<br>        # Check rules first<br>        rule_violation = self.check_tool_rules(&quot;check_weather&quot;)<br>        if rule_violation:<br>            return f&quot;❌ Rule violation: {rule_violation}&quot;<br><br>        state = get_state()<br><br>        # Generate random weather<br>        weather_options = [<br>            WeatherCondition.SUNNY,<br>            WeatherCondition.RAINING,<br>            WeatherCondition.SNOWING,<br>        ]<br><br>        if state.weather_checked and state.weather != WeatherCondition.UNKNOWN:<br>            return (<br>                f&quot;🌤️ Weather already checked! Current weather: {state.weather.value}\n&quot;<br>                f&quot;📊 Weather status: Known and checked&quot;<br>            )<br><br>        new_weather = random.choice(weather_options)<br><br>        # Update state<br>        state.set_weather(new_weather)<br><br>        # The agent will be informed of the updated state<br>        return (<br>            f&quot;🌤️ Weather check complete! Current weather: {new_weather.value}\n&quot;<br>            f&quot;📊 Weather status: Updated and available&quot;<br>        )</pre><p><strong>Principle 2: controlled state updates and rule enforcement</strong></p><p>Here’s how I check business rules before allowing state updates (using Semantic Kernel as an example):</p><pre>class PolicyEnforcedPlugin:<br>    &quot;&quot;&quot;<br>    Base class for Semantic Kernel plugins with policy enforcement.<br><br>    This provides the policy enforcement pattern using<br>    Semantic Kernel&#39;s function decoration approach.<br>    &quot;&quot;&quot;<br><br>    def check_tool_rules(self, tool_name: str, **kwargs) -&gt; Optional[str]:<br>        &quot;&quot;&quot;Check tool-specific business rules.&quot;&quot;&quot;<br>        state = get_state()<br>        rule_engine = get_rule_engine()<br><br>        # Check general tool-specific rules<br>        result = rule_engine.check_tool_rules(state, tool_name=tool_name)<br>        if not result.allowed:<br>            return result.reason<br><br>        return None  # Fixed: was &#39;none&#39;<br><br>    def check_activity_rules(self, activity: str) -&gt; Optional[str]:<br>        &quot;&quot;&quot;Check activity-specific rules.&quot;&quot;&quot;<br>        state = get_state()<br>        rule_engine = get_rule_engine()<br><br>        result = rule_engine.check_activity_rules(state, activity)<br>        if not result.allowed:<br>            return result.reason<br><br>        return None</pre><p><strong>Policy checks are performed across all tool calls through a base Python class:</strong></p><pre>class PolicyEnforcedPlugin: <br> “”” <br> Base class for Semantic Kernel plugins with policy enforcement. <br> <br> This provides the policy enforcement pattern using <br> Semantic Kernel’s function decoration approach. <br> “”” <br> <br> def check_tool_rules(self, tool_name: str, **kwargs) -&gt; Optional[str]: <br> “””Check tool-specific business rules.””” <br> state = get_state() <br> rule_engine = get_rule_engine() <br> <br> # Check general tool-specific rules <br> result = rule_engine.check_tool_rules(state, tool_name=tool_name) <br> if not result.allowed: <br> return result.reason <br> <br> return none <br> <br> def check_activity_rules(self, activity: str) -&gt; Optional[str]: <br> “””Check activity-specific rules.””” <br> state = get_state() <br> rule_engine = get_rule_engine() <br> <br> result = rule_engine.check_activity_rules(state, activity) <br> if not result.allowed: <br> return result.reason <br> <br> return None</pre><p><strong>Principle 3: Rule Definition</strong></p><p>Each rule deterministically codifies the business logic and provides an LLM-friendly description that can be rendered into prompt instructions:</p><pre>class PlayGamesRule(BusinessRule):<br>    &quot;&quot;&quot;Rule: User must have TV and Xbox to play games.&quot;&quot;&quot;<br><br>    def __init__(self):<br>        super().__init__(<br>            name=&quot;Play Games Equipment Rule&quot;,<br>            description=f&quot;The user must have a {Item.TV.value} and an {Item.XBOX.value} before they can play games&quot;,<br>        )<br><br>    def check(<br>        self, state: AgentState, *, activity: Optional[str] = None, **kwargs<br>    ) -&gt; RuleResult:<br>        if activity != Activity.PLAY_GAMES.value:<br>            return RuleResult(allowed=True)<br><br>        required_items = ItemRequirements.PLAY_GAMES<br>        missing_items = ItemRequirements.get_missing_items(activity, state.inventory)<br><br>        if not missing_items:<br>            return RuleResult(allowed=True)<br><br>        missing_names = [item.value for item in missing_items]<br>        return RuleResult(<br>            allowed=False,<br>            reason=f&quot;Cannot play games. Missing required items: {&#39;, &#39;.join(missing_names)}&quot;,<br>        )</pre><p><strong>Recovery Through ReAct Pattern</strong></p><p>In both implementations, I adopted the ReAct pattern to enable agents to replan and retry different paths when tool calls fail due to policy violations or other errors.</p><p><strong>Why ReAct?</strong> While not strictly necessary (agents could simply return failure messages and ask for user input), leveraging ReAct to reflect on immediate tool call results allows agents to take proactive recovery steps, often leading to better user experiences.</p><p>Below is a trace of the agent’s thought and action process showing how it recovers from policy violation warnings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*bouAf1naY9tPvueI74VkRg.png" /><figcaption><strong><em>ReAct agent recover from policy check failures</em></strong></figcaption></figure><p><strong><em>Figure 4: ReAct agent recovers from policy check failures.</em></strong></p><p><em>Only one round of reflection and replanning is shown here; in practice, the agent may go through multiple rounds of tool calls and reflection.</em></p><p><strong>Validation: an ablation study</strong></p><p>As discussed in the Rule Definition section, it’s good practice to embed business rules into an agent’s instructions. To validate our approach, I experimented with the opposite: removing these rules from instructions, making the agent ignorant about the rules and only discovering consequences when violations occur.</p><p><strong>Results</strong>: In our test, the agent violated policy rules an average of 0.7 times per interaction. However, the policy engine successfully prevented actual violations, and the ReAct design kept the agent on track without user intervention. While we would never attempt this in production, the experiment effectively demonstrates and validates our design’s effectiveness.</p><p><strong>Key takeaways and future directions</strong></p><p>AI agents offer tremendous opportunities while requiring new design approaches. In this blog post, I explored a method to harness LLMs’ agency while ensuring policy compliance.</p><p><strong>Integration with existing practices</strong></p><p>Our policy engine approach can be combined with other best practices:</p><p>· <strong>LLM-based guardrails</strong>: For handling edge cases and providing additional safety layers</p><p>· <strong>Deterministic UI components</strong>: Using UX widgets to capture structured input when 100% accuracy is required for user intention</p><p>· <strong>Hybrid approaches</strong>: Carefully balancing where we have zero tolerance for LLM-induced errors versus where we can leverage LLM flexibility</p><p><strong>Design Principles to Remember</strong></p><p>1. <strong>Start with user goals</strong>: Remember that existing workflows were created to achieve specific user outcomes — don’t follow them blindly</p><p>2. <strong>Minimize unnecessary constraints</strong>: Avoid over-extending constraints that limit an agent’s planning capabilities</p><p>3. <strong>Strategic error tolerance</strong>: Carefully delineate where you have low or zero tolerance for LLM-induced errors</p><p>The future of agentic AI lies not in replacing human judgment, but in thoughtfully combining the strengths of deterministic systems with the flexibility of LLM reasoning.</p><p><em>If you want to find out more about working in Data Science at CommBank, feel free to message me on </em><a href="https://www.linkedin.com/in/smartnose/"><em>LinkedIn</em></a><em>.</em></p><p><strong><em>Wei Liu</em></strong></p><p><strong><em>Distinguished AI Scientist — Commonwealth Bank</em></strong></p><p><em>Dr. Wei Liu is a Distinguished AI Scientist at CommBank, where he is responsible for developing autonomous AI agents that enhance banking accessibility and security for millions of Australian businesses. Prior to joining CommBank, Dr. Liu accumulated 14 years of diverse experience within the technology sector in Seattle, U.S., holding senior R&amp;D leadership positions as well as individual contributor roles at companies including Sift, Zillow, Microsoft, and Amazon. He is dedicated to building innovative, large-scale V1 products by leveraging AI, data science, big data technologies, and software engineering to address unmet customer needs with pioneering solutions. Dr. Liu has authored 13 papers and book chapters in various conferences and journals and holds 10 U.S. patents.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*E88s1bjlOWMIs0qM1ZyxRw.jpeg" /></figure><p>Disclaimer: This article is the opinion of an individual senior technology staff member at the Commonwealth Bank of Australia, and does not represent the views of the Group. In this article, ‘compliance’, and ‘policy’ refer to technical, not legal concepts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9a8a1b4a88c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/commbank-technology/enforcing-compliance-while-retaining-agency-a-rule-based-policy-engine-approach-for-react-agents-a9a8a1b4a88c">Enforcing Compliance While Retaining Agency: A Rule-Based Policy Engine Approach for ReAct Agents</a> was originally published in <a href="https://medium.com/commbank-technology">CommBank Innovation &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>