<?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 Lakshhariyani on Medium]]></title>
        <description><![CDATA[Stories by Lakshhariyani on Medium]]></description>
        <link>https://medium.com/@lakshhariyani?source=rss-b545c4f5ffdf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NVuEkCqf24kDz29GSI6jIA.jpeg</url>
            <title>Stories by Lakshhariyani on Medium</title>
            <link>https://medium.com/@lakshhariyani?source=rss-b545c4f5ffdf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:43:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lakshhariyani/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[From Agent Trace to Regression Proof: ReasonTrail]]></title>
            <link>https://medium.com/@lakshhariyani/from-agent-trace-to-regression-proof-reasontrail-e71dac57bfb0?source=rss-b545c4f5ffdf------2</link>
            <guid isPermaLink="false">https://medium.com/p/e71dac57bfb0</guid>
            <category><![CDATA[signoz]]></category>
            <category><![CDATA[ai-observability]]></category>
            <category><![CDATA[agents]]></category>
            <dc:creator><![CDATA[Lakshhariyani]]></dc:creator>
            <pubDate>Sun, 26 Jul 2026 15:53:25 GMT</pubDate>
            <atom:updated>2026-07-26T15:53:25.219Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>How one premature refund became a cited incident, a replay that changed one thing, and a test that keeps the mistake from happening twice.</em></blockquote><p>Agents are no longer just answering questions; we are giving them tools, permissions, and the liberty to act. They can approve, purchase, refund, schedule, and deploy often without waiting for a human to click Confirm. This is the story of how I built <strong>ReasonTrail</strong> to trace what happens when that freedom meets a stale policy, test one correction, and preserve the result as proof.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O4qqo1xUuZHZotTCYUFs7g.png" /></figure><p>That is exciting. BUT It also means an agent can be confidently wrong at machine speed.</p><p>Picture a high-value return. The carrier marks it <em>DELIVERED</em> at the return center. The warehouse has not inspected it or confirmed the right product came back. An outdated policy joins two dots that look close enough: delivered means returned; returned means refund. The agent requests one.</p><p>The API responds with 201 Created. Every dependency is healthy. No timeout, no exception, no smoke. To the infrastructure, this is a lovely little success. To the business, money is moving before the evidence has arrived.</p><p>That is the awkward class of failure ReasonTrail is built for: the execution succeeds, but the decision is wrong. A normal dashboard shows that the request completed. I wanted a black box that shows what the agents knew, which policy they followed, and whether one change fixes the outcome.</p><p>So I built ReasonTrail: an agent black box and counterfactual safety lab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZoFGBHuKIZBWt5Fa22gJg.png" /></figure><h3><strong>One return, four agents, two different kinds of authority</strong></h3><p>The returns_orchestrator receives the request and hands it to logistics_verifier, which calls four read-only, fixture-backed tools: return authorization, carrier delivery, warehouse inspection and item identity, and prior-refund status.</p><p>Those normalized facts move to refund_decision. In live mode, the three roles use bounded Gemini 3.5 Flash-Lite calls with Pydantic structured outputs. Fixture mode provides the deterministic backup.</p><p>The models can reason, but they cannot authorize a refund. A deterministic safety contract owns that decision, and issue_refund is permanently simulation-only.</p><p>After an incident, forensics_investigator reads a normalized, redacted ledger from SigNoz through a Viewer-only MCP connection. It cannot call return tools or mutate SigNoz, and every factual claim must cite the ledger.</p><p>The boundary is simple: agents propose; the contract authorizes; evidence explains.</p><h3>The policy bug is small. Its consequence is not.</h3><p>ReasonTrail compares two policies:</p><ul><li><strong>deprecated decision policy v2 </strong>considers authorization, carrier delivery, and “not already refunded” sufficient;</li><li><strong>current safety policy v4</strong> also requires warehouse inspection to pass and the returned item identity to match.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aL1AfDc8qT5hNt2x9jQ1xw.png" /></figure><p>In the controlled failure, the carrier reports DELIVERED, while warehouse inspection remains PENDING. V2 requests the refund; v4 catches two critical violations: inspection has not passed, and item identity is still unconfirmed.</p><p>A parcel arriving is not the same as the right item being accepted. Those facts belong in the same story, but not in the same policy rule. A green status code cannot spot that semantic bug.</p><p><strong>One contract, not six drifting copies</strong></p><p>The signature feature is the Behavior Contract Compiler.</p><p>ReasonTrail loads a strict, versioned reasontrail.behavior-contract.v1 JSON document. A contract declares required facts, allowed evidence authorities, temporal prerequisites, and protected-action occurrence limits. The compiler turns that one vocabulary into:</p><ul><li>runtime invariant evaluation;</li><li>protected-action authorization rules;</li><li>bounded telemetry descriptors;</li><li>SigNoz alert and investigation descriptors;</li><li>replay assertions;</li><li>regression-proof assertions.</li></ul><p>That avoids another failure: defining “safe” one way in an agent prompt, another way in an alert, and a third way in a test. A deployment-approval example checks that the abstraction is not refund-specific.</p><p><strong>Refund is the example, not the boundary</strong></p><p>Refunds make a useful demo because the mistake is obvious: money moves too soon. ReasonTrail itself does not encode refund logic. Its compiler understands facts, evidence authorities, prerequisites, protected actions, and action limits.</p><p>Change the vocabulary and the same engine can guard:</p><p>- a deployment agent, using approval, test, and canary evidence before release;</p><p>- a supply-chain agent, using inventory, carrier-capacity, and route-safety evidence before rerouting;</p><p>- an access agent, using corroborated security evidence and human approval before revocation.</p><p>The nouns change; the loop does not: trace the action, reconstruct the evidence, replay one change, and preserve the result as proof. If an agent can take a consequential action, ReasonTrail can put a black box around its decision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*WNM_KNu8swq-bc5Gq8J4Og.png" /></figure><h3>SigNoz is the evidence system, not a decorative dashboard</h3><p>ReasonTrail does not store a shadow copy of raw observability data in PostgreSQL. PostgreSQL keeps compact workflow records such as an incident ID and source trace ID. The execution evidence remains in SigNoz.</p><p>The controlled failure emits one OpenTelemetry trace covering HTTP entry, agents, model calls, handoffs, evidence tools, contract evaluation, the protected action, and incident persistence. Logs correlate by trace ID. Bounded metrics cover failures, violations, handoff latency, forensics, replay, and verified fixes. Query Builder reconstructs the causal trail. Three dashboards, five semantic alerts, and four saved investigations are provisioned as version-matched assets.</p><p>The Forensics Agent uses SigNoz MCP to retrieve that evidence. SigNoz documents MCP as a way to connect agents to telemetry across traces, logs, and metrics (SigNoz AI and MCP overview). Remove SigNoz and ReasonTrail loses its source trace, correlated evidence, comparison data, incident reconstruction, and the provenance required for replay. That is why SigNoz is not replaceable by a few application log lines.</p><p>SigNoz alone still should not own domain policy or execute counterfactuals. ReasonTrail adds the business-contract compiler, evidence validation, side-effect gate, one-variable replay, and durable proof. The two products meet at a clean boundary: SigNoz records and serves the truth of what ran; ReasonTrail turns that truth into a safe experiment.</p><h3>The most useful failure happened before the demo</h3><p>My first authenticated Gemini run completed every role, handoff, and evidence tool then chose to wait. It received the name of deprecated policy v2, but not its requirements, so it reasonably applied modern return-safety assumptions.</p><p>A mocked provider test had not exposed that semantic gap.</p><p>The tempting “fix” would have been to weaken validation or hard-code the unsafe answer. I did neither. The Refund Decision Agent now receives a bounded projection of the selected compiled policy and the normalized evidence. The active v4 safety contract still evaluates the requested action independently. After that change, the real model reproduced v2’s stale decision, while ReasonTrail rejected it under v4.</p><p>That was the project’s central lesson: version labels are not policy semantics, and model agreement is not authorization.</p><p>If I started again, I would compile the Behavior Contract before writing the agent prompt and test its policy projection with a real provider earlier. Mocks caught the output shape; they did not catch the semantic gap.</p><p>From incident to counterfactual to proof</p><p>The demo follows five steps:</p><p>1. <strong>Run</strong>: trigger premature_refund; observe three agents, two handoffs, and a simulated refund request under v2.</p><p>2. <strong>Incident</strong>: see v4 reject the action because inspection and identity evidence are missing.</p><p>3. <strong>Forensics</strong>: reconstruct the incident from SigNoz and separate cited facts, inference, and unknowns.</p><p>4. <strong>Replay</strong>: freeze the original PENDING warehouse evidence and substitute only decision_policy_version.</p><p>5. <strong>Proof</strong>: review and approve a generated fixture; verify that faulty v2 fails and corrected v4 passes.</p><p>The corrected replay reaches AWAITING_INSPECTION and never invokes the refund adapter. A separate healthy fixture proves that v4 permits exactly one simulated refund after inspection passes. Every original, replay, and proof target reports external_side_effect_performed=false.</p><p>Incident explanations become stale. A regression proof makes the learning executable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aL1AfDc8qT5hNt2x9jQ1xw.png" /></figure><p>SigNoz returned 16 spans and 89 normalized evidence references covering all agents, handoffs, tool reads, the simulated action, and the v2-versus-v4 evaluation. The Forensics Agent trace 7e2c443d5c3b1648f5d57b953148a5b7 contained 11 spans. Its capsule used 90 references for seven facts, one inference, and two unknowns, with no missing citations. These are verified-run counts, not performance claims.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*xGhs4JjGrBWAZrzWmXqb8Q.png" /></figure><p>The final gate passed formatting, linting, strict typing, production build, 19 web tests, 87 API tests, and the Chromium Run-to-Proof journey.</p><p>The stack is Next.js, FastAPI, PostgreSQL, OpenAI Agents SDK, Gemini, OpenTelemetry, and self-hosted SigNoz installed through Foundry (SigNoz Docker/Foundry guide).</p><p>Reproduce the safe path</p><p>start the stacks:</p><pre># WSL<br>foundryctl cast -f casting.yaml<br>docker compose up -d - wait postgres<br><br># PowerShell<br>pnpm dev</pre><p>Open ReasonTrail at <a href="http://localhost:3000/">http://localhost:3000</a> and SigNoz at <a href="http://localhost:8080.">http://localhost:8080.</a></p><p>Fixtures are the deterministic default; live mode needs an explicit server-only key and never silently falls back. Prompt capture is disabled, identifiers are redacted, and protected actions remain simulated.</p><h3>The takeaway</h3><p>ReasonTrail began with one question: how do I debug an autonomous decision when nothing technically failed? The answer became a repeatable loop:</p><p>observe the action, cite what happened, change one variable, and preserve the result as a test.</p><p>That is the difference between watching an agent and trusting its next decision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e71dac57bfb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>