<?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"><channel><title><![CDATA[Agent Guardian]]></title><description><![CDATA[Agent Guardian]]></description><link>https://agent-guardian.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1593680282896/kNC7E8IR4.png</url><title>Agent Guardian</title><link>https://agent-guardian.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 09:15:37 GMT</lastBuildDate><atom:link href="https://agent-guardian.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Building Agent Guardian: Autonomous SRE Incident Response with TrueForge & Deterministic Safety]]></title><description><![CDATA[How we built an autonomous SRE incident-response agent using TrueForge harnesses, MCP microservices, and a fail-closed policy engine—and what we learned about securing AI agents in production.


Intro]]></description><link>https://agent-guardian.hashnode.dev/building-agent-guardian-autonomous-sre-incident-response-with-trueforge-deterministic-safety</link><guid isPermaLink="true">https://agent-guardian.hashnode.dev/building-agent-guardian-autonomous-sre-incident-response-with-trueforge-deterministic-safety</guid><category><![CDATA[trueforge]]></category><category><![CDATA[truefoundry]]></category><category><![CDATA[WeMakeDevs]]></category><category><![CDATA[qodo]]></category><dc:creator><![CDATA[Rushil Mistry]]></dc:creator><pubDate>Sun, 30 Aug 2026 15:34:58 GMT</pubDate><content:encoded><![CDATA[<blockquote>
<p><em>How we built an autonomous SRE incident-response agent using TrueForge harnesses, MCP microservices, and a fail-closed policy engine—and what we learned about securing AI agents in production.</em></p>
</blockquote>
<hr />
<h2>Introduction: The Promise and Peril of AI SREs</h2>
<p>When an incident strikes production at 3:00 AM, every minute spent searching logs, inspecting git diffs, and triaging stack traces translates directly to customer impact and downtime costs. Autonomous AI agents promise to revolutionize incident response by investigating alerts and executing fixes at machine speed.</p>
<p>However, giving an LLM direct access to production infrastructure introduces significant operational risk. Hallucinations, unvetted commands, or overzealous remediation scripts could escalate a minor service slowdown into a major outage.</p>
<p>To bridge this gap between <strong>high-velocity automation</strong> and <strong>uncompromising operational safety</strong>, we built <a href="https://github.com/Rushil-Mistry/Agent-Guardian"><strong>Agent Guardian</strong></a>—an autonomous SRE incident-response system built on top of <a href="https://github.truefoundry.com/trueforge"><strong>TrueForge</strong></a> and hardened with <strong>Qodo Code Integrity</strong>.</p>
<p>In this blog post, we'll walk through what we built, how TrueForge powers our harness and sandbox execution, and the key architectural lessons we learned while bringing deterministic safety to autonomous agents.</p>
<hr />
<h2>What We Built: Agent Guardian</h2>
<p><strong>Agent Guardian</strong> is a production-grade SRE agent designed to investigate alerts, collect evidence, reproduce regressions inside isolated sandbox environments, evaluate action risks quantitatively, and enforce human operator sign-offs before performing high-risk operations.</p>
<h2>Core Architecture Overview</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6a9449488cc4bb826150f016/e7f2468f-80d7-429f-9502-0654b084d13f.jpg" alt="" style="display:block;margin:0 auto" />

<h3>Key System Components</h3>
<ol>
<li><p><strong>TrueForge Harness Runtime</strong>: Manages the agent workflow lifecycle, orchestrates MCP tool calls, and handles execution in isolated sandboxes.</p>
</li>
<li><p><strong>Fail-Closed Policy Engine</strong>: Evaluates structured YAML policies with zero silent "default-allow" behavior.</p>
</li>
<li><p><strong>7-Factor Risk Assessment Engine</strong>: Quantifies operation risk into a 0–100 score using deterministic dimensions (Operation Type, Environment, Blast Radius, Reversibility, Data Sensitivity, Tool Sensitivity, Destructive Potential).</p>
</li>
<li><p><strong>Idempotent Kill Switch:</strong> State machine (<code>RUNNING</code> ➔ <code>PAUSED</code> ➔ <code>WAITING_APPROVAL</code> ➔ <code>STOPPING</code> ➔ <code>STOPPED</code>) enabling on-call engineers to halt agent execution instantly.</p>
</li>
<li><p><strong>Secret-Safe Audit Trail</strong>: Active scanning for AWS keys, GitHub PATs, and API credentials to guarantee audit logs remain secret-safe.</p>
</li>
<li><p><strong>SQL Write Guard</strong>: Lexical AST parser that blocks mutation queries (<code>UPDATE</code>, <code>DELETE</code>, <code>DROP</code>, <code>ALTER</code>) on diagnostic database connections.</p>
</li>
</ol>
<hr />
<h2>How We Used TrueForge</h2>
<p>TrueForge served as the core agent execution harness and sandboxing foundation for Agent Guardian. Here is how we leveraged its key capabilities:</p>
<h3>1. Declarative Agent Harness Configuration (<code>trueforge.yaml</code>)</h3>
<p>We configured the agent runtime declaratively in [<code>trueforge.yaml</code>], defining model parameters, timeouts, MCP tool endpoints, sandbox specs, and human-in-the-loop policies:</p>
<pre><code class="language-yaml">version: "1.0"
agent:
  name: "agent-guardian"
  version: "1.0.0"
  model:
    provider: "openai"
    name: "gpt-4o"
    temperature: 0.1

runtime:
  type: "harness"
  max_iterations: 15
  timeout_seconds: 600
  kill_switch:
    enabled: true
    state_file: ".agent-guardian-state.json"

sandbox:
  provider: "trueforge-sandbox"
  environment: "isolated-container"
  image: "python:3.11-slim"
  memory_limit: "512MB"
  cpu_limit: "1.0"
  network_access: false
  secret_scrubbing: true
  timeout_seconds: 30
</code></pre>
<h3>2. Isolated Container Sandboxes for Diagnostic Repro Code</h3>
<p>When investigating a production issue, an SRE agent often needs to generate and run diagnostic scripts to reproduce the bug. Executing arbitrary LLM-generated code directly on host servers is extremely dangerous.</p>
<p>With TrueForge, Agent Guardian runs repro tests inside isolated Python container sandboxes (<code>python:3.11-slim</code>). Network access is disabled, execution memory/CPU are strictly capped, and outputs are automatically sanitized for secrets.</p>
<pre><code class="language-typescript">// Executing reproduction code safely inside TrueForge Sandbox
const sandboxCode = `
import sys
def test_payment_handler():
    payload = {"amount": 100, "currency": "USD", "payment_method": None}
    try:
        payload["payment_method"].lower() # Repro v1.41 bug
        return False
    except AttributeError:
        return True # Repro confirmed

assert test_payment_handler() == True
print("CONFIRMED_REGRESSION: payment_method null dereference in v1.41")
`;

const sandboxResult = await this.harness.executeInSandbox(sandboxCode);
// Clean exit with verified reproduction proof without touching production!
</code></pre>
<h3>3. Policy-Gated MCP Tool Server Suite</h3>
<p>TrueForge orchestrates communication with five specialized Model Context Protocol (MCP) microservices:</p>
<ul>
<li><p><strong>Monitoring MCP</strong> (<code>Port 3001</code>): Fetches health status, latencies, and alert logs.</p>
</li>
<li><p><strong>Logs MCP</strong> (<code>Port 3002</code>): Queries application stack traces and trace IDs.</p>
</li>
<li><p><strong>GitHub MCP</strong> (<code>Port 3003</code>): Inspects recent commits, diffs, and branch patches.</p>
</li>
<li><p><strong>Database MCP</strong> (<code>Port 3004</code>): Provides schema inspection gated by <code>SQL_READ_ONLY_GUARD</code>.</p>
</li>
<li><p><strong>Deployment MCP</strong> (<code>Port 3005</code>): Handles version deployments and rollbacks, wrapped by TrueForge policy interception.</p>
</li>
</ul>
<hr />
<h2>Incident Simulation: End-to-End Walkthrough</h2>
<p>To validate Agent Guardian under realistic operational conditions, we built a sample FastAPI microservice and simulated a high-severity production regression:</p>
<ol>
<li><p><strong>Incident Trigger</strong>: Version <code>v1.41</code> of <code>payment-service</code> is deployed, introducing an unhandled null dereference when <code>payment_method</code> is missing. Error rates spike to 35%.</p>
</li>
<li><p><strong>Phase 1: Autonomous Investigation</strong>:</p>
<ul>
<li><p>Agent Guardian queries Monitoring MCP (<code>port 3001</code>) and flags the elevated error rate.</p>
</li>
<li><p>Logs MCP (<code>port 3002</code>) pinpoints <code>AttributeError: 'NoneType' object has no attribute 'lower'</code>.</p>
</li>
<li><p>GitHub MCP (<code>port 3003</code>) identifies commit <code>8f2a1d</code> in <code>v1.41</code> as the culprit.</p>
</li>
</ul>
</li>
<li><p><strong>Phase 2: TrueForge Sandbox Verification</strong>:</p>
<ul>
<li><p>The agent writes a targeted reproduction script and executes it inside a TrueForge sandbox container.</p>
</li>
<li><p>Reproduction is confirmed in 214ms with exit code <code>0</code>.</p>
</li>
</ul>
</li>
<li><p><strong>Phase 3: Quantitative Risk Assessment</strong>:</p>
<ul>
<li><p>The proposed remediation (<code>rollback</code> to <code>v1.40</code> in <code>production</code>) is evaluated against the 7-Factor Risk Engine:</p>
<ul>
<li><p><strong>Operation</strong>: <code>deploy</code> (75)</p>
</li>
<li><p><strong>Environment</strong>: <code>production</code> (90)</p>
</li>
<li><p><strong>Blast Radius</strong>: High (70)</p>
</li>
<li><p><strong>Final Risk Score</strong>: <strong>78.5 / 100</strong> (Risk Level: <code>HIGH</code>)</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Phase 4: Policy Gate &amp; Human Approval</strong>:</p>
<ul>
<li><p>TrueForge harness pauses execution state to <code>WAITING_APPROVAL</code>.</p>
</li>
<li><p>An on-call SRE reviews the evidence payload, root cause analysis, and sandbox repro results, then issues approval via the TrueForge harness API.</p>
</li>
</ul>
</li>
<li><p><strong>Phase 5: Automated Rollback</strong>:</p>
<ul>
<li>Deployment MCP executes rollback to <code>v1.40</code>. Error rates return to 0%, and audit logs record the full lifecycle.</li>
</ul>
</li>
</ol>
<hr />
<h2>What We Learned Along the Way</h2>
<p>Building Agent Guardian revealed critical lessons about developing autonomous systems for high-stakes operational environments:</p>
<h3>1. LLMs Should Reason; Deterministic Systems Must Govern</h3>
<p>LLMs excel at synthesizing unstructured evidence—parsing log traces, correlating commit diffs, and hypothesizing root causes. However, <strong>never let an LLM grade its own safety or decide if an action requires approval</strong>.</p>
<p>By delegating risk assessment and policy decisions to a deterministic TypeScript policy engine, we eliminated non-deterministic bypasses and guaranteed consistent policy enforcement.</p>
<h3>2. "Fail-Closed" is Non-Negotiable</h3>
<p>If a policy rule definition is missing, a rule file fails to parse, or an unknown environment parameter is supplied, the policy engine must <strong>fail-closed</strong> (<code>allowed: false</code>, <code>score: 100</code>). In production SRE automation, a false denial is a minor inconvenience; a false approval can result in a catastrophic outage.</p>
<h3>3. Sandboxes are Essential for AI SRE Credibility</h3>
<p>SREs are naturally skeptical of automated fixes. Providing an isolated TrueForge sandbox execution step—where the agent proves the regression with an executable test <em>before</em> proposing a fix—radically increases human operator confidence during approval reviews.</p>
<h3>4. Defense-in-Depth Beats Single Safety Layers</h3>
<p>Single guards can fail. Agent Guardian employs four distinct safety boundaries:</p>
<ul>
<li><p><strong>Lexical AST Guards</strong> on DB connections (<code>SQL_READ_ONLY_GUARD</code>).</p>
</li>
<li><p><strong>Active Secret Scanners</strong> on audit streams (<code>SecretGuard</code>).</p>
</li>
<li><p><strong>Quantitative Policy Engines</strong> on action dispatchers.</p>
</li>
<li><p><strong>State-Machine Kill Switches</strong> on runtime harnesses.</p>
</li>
</ul>
<p>Together, these layers ensure that even if one component fails, downstream safety remains intact.</p>
<hr />
<h2>Conclusion</h2>
<p>Autonomous SRE agents have the potential to reduce Mean Time to Resolution (MTTR) from hours to seconds. But speed without control is a liability. By pairing <strong>TrueForge's harness and containerized sandboxes</strong> with <strong>deterministic fail-closed governance</strong>, Agent Guardian demonstrates how SRE teams can safely harness AI automation in production.</p>
<p>Check out the repository, inspect our 68 Vitest test suites, or run the incident simulation yourself:</p>
<p><a href="https://github.com/Rushil-Mistry/Agent-Guardian"><strong>GitHub: Rushil-Mistry/Agent-Guardian</strong></a></p>
<hr />
<p><em>Built with ❤️ using TrueForge, Qodo, TypeScript, and FastAPI.</em></p>
]]></content:encoded></item></channel></rss>