DEV Community

Savanth JR
Savanth JR

Posted on

How I Built an AI Agent That Doesn't Break Production (Thanks to TrueForge & Qodo)

Let’s be real for a second: autonomous AI agents are incredible, but giving them direct write access to your live production environment is terrifying.

For the Agent Harness Hackathon, I wanted to build an AI marketing assistant that could verify campaign links, shorten them, and update a live production endpoint. But I also wanted to sleep at night knowing a hallucinating bot wouldn't wipe out a live ad campaign.

Enter CampaignGuard—a sandboxed AI agent with a strict Human-in-the-Loop (HITL) safety gate.

Here is a look at what I built, the tech stack, and the very real bumps I hit along the way.

What is CampaignGuard?**

CampaignGuard is designed to prevent broken ad funnels and unauthorized production overwrites.

  • The Brains: Powered by Gemini Flash to understand natural language prompts.

  • **The Sandbox**: It runs a custom Python tool (link_manager.py) inside TrueForge to check URL health and generate short links.
    
  • **The Target**: It updates a live public GitHub Gist via REST API (acting as the live campaign config endpoint).
    
  • **The Guardrail**: Before it executes the irreversible Gist overwrite, TrueForge pauses the agent and forces me to click "Approve".
    

The "Bumps in the Road" (aka Reality)

Building this wasn't just a smooth copy-paste journey. Here are a few walls I ran into and how I fixed them:

The Localhost Trap: I originally tried spinning up TrueForge natively in Windows Git Bash, only to be met with a wall of ESM loader errors. Lesson learned: TrueForge's sandbox strongly prefers Linux. I quickly switched over to WSL (Ubuntu), and it purred like a kitten.

The "Lazy" Agent Hallucination: At first, when I asked the agent to update the Gist, it just confidently replied, "The live update has been successfully executed!"... without actually running the Python script. I had to aggressively update my TrueForge System Prompt to force the agent to run the explicit python3 -c command in the sandbox rather than just pretending it did.

The Classic Typo: While manually testing my GitHub API tokens in the terminal, I wrapped my token in literal angle brackets <ghp_...>, resulting in a frustrating 401 Bad credentials error until I realized what I had done.

Enter fullscreen mode Exit fullscreen mode




Qodo to the Rescue

As part of the hackathon, we ran our pull requests through Qodo for automated code review, and it legitimately saved my API integration.

I deliberately used the standard Python urllib library to keep my sandbox footprint zero-dependency. However, when I wrote the PATCH request for the GitHub API, I missed a crucial detail. Qodo instantly flagged a High Severity Bug: I forgot the Content-Type: application/json header. Without it, urllib defaults to form-urlencoded, and GitHub would have rejected the payload entirely.

It also caught a broken test import where my test suite was still looking for a deleted mock function. Fixing these right in the PR made the final merge bulletproof.

The "Aha!" Moment

The best part of this build was seeing the TrueForge safety gate work in real-time. Typing in a prompt, watching the agent test the URL in isolation, and then seeing the system physically halt and throw up a warning—"⚠️ WARNING: This will overwrite the live production Gist"—was incredibly satisfying. It bridges the gap between fast AI automation and actual enterprise safety.

Explore my Repo: https://github.com/savislost/CampaignGuard

Have you guys tried putting explicit human approval gates in your AI workflows yet? What are you using to sandbox your agents? Let me know in the comments!

Top comments (0)