<?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 Vishal Sangave on Medium]]></title>
        <description><![CDATA[Stories by Vishal Sangave on Medium]]></description>
        <link>https://medium.com/@vishalsangave07?source=rss-9910718281cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jRiSU-7e7ThV5SxN.</url>
            <title>Stories by Vishal Sangave on Medium</title>
            <link>https://medium.com/@vishalsangave07?source=rss-9910718281cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:34:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vishalsangave07/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[Beyond assert: A New Framework for Production-Ready AI Testing]]></title>
            <link>https://medium.com/@vishalsangave07/beyond-assert-a-new-framework-for-production-ready-ai-testing-a5bfa08beac4?source=rss-9910718281cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5bfa08beac4</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[ai-testing-framework]]></category>
            <dc:creator><![CDATA[Vishal Sangave]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 12:57:03 GMT</pubDate>
            <atom:updated>2026-10-22T12:57:03.017Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How DriftGate brings semantic evaluation, agent contracts, and automated security testing into your Pytest workflow.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*RhmvZh5jhh8x_yqnYmpbVA.png" /><figcaption>DrifGate</figcaption></figure><p>If you’ve ever written a test for a large language model, you’ve probably run into this problem:</p><pre>assert response.text == &quot;The capital of France is Paris.&quot;</pre><p>The test passes. The next day, the model returns:</p><blockquote>Of course, the capital of France is Paris.</blockquote><p>The test fails. The answer is still correct.</p><p>That small example captures a bigger challenge: how do you test a system whose wording can change without its behavior being wrong?</p><p>Exact string comparisons still have their place, especially for structured outputs and fixed requirements. But generative AI also needs tests that evaluate meaning, enforce boundaries, and probe unsafe behavior.</p><p>That’s why we built <strong>DriftGate</strong>, an open-source, Pytest-native framework designed to bring these checks into everyday development and CI/CD pipelines.</p><h3>The Three Pillars of Modern AI Testing</h3><p>DriftGate organizes AI testing around three complementary approaches: semantic evaluation, agent contracts, and automated adversarial testing.</p><h3>1. Evaluate Meaning with LLM-as-a-Judge</h3><p>String comparisons are easy to write, but they often reject perfectly acceptable responses.</p><p>Research such as <em>Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena</em> explores an alternative: using a language model to evaluate another model’s output against a defined rubric.</p><p>DriftGate brings this approach into Pytest through its driftgate_evaluator fixture.</p><p>Here’s a brittle test:</p><pre>def test_capital(driftgate_client):<br>    response = driftgate_client.post(<br>        &quot;/chat&quot;,<br>        json={&quot;prompt&quot;: &quot;What is the capital of France?&quot;},<br>    )</pre><pre>    assert (<br>        response.json()[&quot;response&quot;]<br>        == &quot;The capital of France is Paris.&quot;<br>    )</pre><p>And here’s a semantic evaluation:</p><pre>def test_capital(driftgate_client, driftgate_evaluator):<br>    prompt = &quot;What is the capital of France?&quot;</pre><pre>    response = driftgate_client.post(<br>        &quot;/chat&quot;,<br>        json={&quot;prompt&quot;: prompt},<br>    )</pre><pre>    actual_response = response.json()[&quot;response&quot;]<br>    golden_response = &quot;The capital of France is Paris.&quot;</pre><pre>    verdict = driftgate_evaluator.compare(<br>        actual_response,<br>        golden_response,<br>        prompt,<br>    )</pre><pre>    assert verdict.passed, verdict.rationale</pre><p>The second test evaluates whether the response preserves the expected meaning, allowing harmless changes in phrasing.</p><p>An LLM judge is still a model: its assessments can be inconsistent or biased. Clear evaluation criteria and calibration against human-reviewed examples help make those assessments useful.</p><p>DriftGate also supports local models through <strong>Ollama</strong>, so you can run semantic checks during development without per-request API charges. Local compute costs still apply.</p><h3>2. Define Agent Boundaries with Contracts</h3><p>Many AI applications coordinate multiple agents and tools. Each interaction introduces assumptions:</p><ul><li>What input does this agent accept?</li><li>What output must it produce?</li><li>Which tools is it allowed to call?</li></ul><p>When those assumptions remain implicit, failures can spread through the system.</p><p>Drawing on the software engineering principle of <strong>Design by Contract</strong>, DriftGate introduces <strong>Agent Contracts</strong>: YAML files that describe an agent’s expected behavior and boundaries.</p><p>For example:</p><pre># math_agent_contract.yaml<br>name: &quot;MathAgent&quot;<br>description: &quot;Handles calculations using the calculator tool.&quot;</pre><pre>allowed_tools:<br>  - &quot;calculator&quot;</pre><pre>output_schema:<br>  type: &quot;object&quot;<br>  required:<br>    - agent_name<br>    - tool_calls<br>  properties:<br>    agent_name:<br>      const: &quot;MathAgent&quot;<br>    tool_calls:<br>      type: &quot;array&quot;</pre><p>This contract declares the agent’s identity, its allowed tool, and the required shape of its output.</p><p>Tests can validate recorded interactions against these expectations, catching unexpected tool calls and malformed responses before they break downstream components.</p><p>Contract tests complement runtime controls. Tool permissions still need to be enforced by the application itself.</p><h3>3. Make Adversarial Testing Part of the Workflow</h3><p>Testing an AI application only with cooperative prompts leaves a major gap.</p><p>What happens when someone asks it to ignore its instructions, reveal protected information, or misuse a tool?</p><p>Prompt injection is a central concern in the <em>OWASP Top 10 for Large Language Model Applications</em>. Manually checking a few examples before release provides limited coverage.</p><p>DriftGate makes repeatable adversarial testing available through the @pytest.mark.red_team marker:</p><pre>import pytest<br>from httpx import Client<br></pre><pre>@pytest.mark.red_team<br>def test_prompt_injection(<br>    attack_prompt: str,<br>    driftgate_client: Client,<br>):<br>    response = driftgate_client.post(<br>        &quot;/chat&quot;,<br>        json={&quot;prompt&quot;: attack_prompt},<br>    )</pre><pre>    assert response.is_success</pre><pre>    # Use the refusal behavior defined by your application.<br>    assert (<br>        &quot;I&#39;m not sure how to handle that&quot;<br>        in response.json()[&quot;response&quot;]<br>    )</pre><p>DriftGate expands the test across prompts from its built-in attack library, making adversarial checks repeatable in CI.</p><p>The refusal assertion here is deliberately simple and assumes your application uses a fixed fallback message. Applications with flexible refusal wording need a broader safety rubric.</p><p>Passing a prompt suite does not establish that an application is secure. It gives you a repeatable baseline that can grow as you discover new failure modes.</p><h3>Get Started in Five Minutes</h3><p>Because DriftGate builds on Pytest, you can introduce it alongside your existing tests.</p><p>From a checkout of the DriftGate repository:</p><p><strong>1. Install the development dependencies</strong></p><pre>uv sync --extra dev</pre><p><strong>2. Initialize the configuration</strong></p><pre>uv run driftgate init</pre><p><strong>3. Configure your evaluator</strong></p><p>Set up your preferred LLM judge, such as a local Ollama model, in driftgate.config.yaml.</p><p><strong>4. Run your tests</strong></p><pre>uv run pytest</pre><p>Start with one important workflow. Add semantic checks where wording can vary, contracts where agents exchange data or call tools, and adversarial cases where trust boundaries matter.</p><p>Expand your coverage as you learn how your application fails.</p><h3>Toward More Reliable AI Releases</h3><p>Deploying generative AI requires evidence that the application behaves acceptably — even when its exact outputs change.</p><p>Semantic evaluation helps assess meaning. Agent contracts make expectations explicit. Adversarial testing probes how the system responds under pressure.</p><p>Together, these approaches give teams a stronger basis for deciding whether a change is ready to ship.</p><p>DriftGate brings them into a familiar testing workflow, so AI quality checks can evolve alongside the application.</p><p>The project is open for contributions. Try it on your own workflows, share the failures your tests uncover, and help improve the framework.</p><p><strong>Explore the code, setup guide, and examples on GitHub:</strong></p><p><a href="https://github.com/vishalsangave/genai-api-quality-gates">GitHub - vishalsangave/genai-api-quality-gates</a></p><h4><strong>References:</strong></h4><ul><li>Zheng, L., et al. (2023). <strong><em>Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena</em></strong>.</li><li>OWASP Foundation. (2023). <strong><em>OWASP Top 10 for Large Language Model Applications</em></strong>.</li><li>Meyer, B. (1986). <strong><em>Design by Contract</em></strong>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5bfa08beac4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>