Skip to main content
    listerineh.dev
    • About
    • Experience
    • Projects
    • Skills
    • Blog
    • Talks
    • Contact
    • Why
    • About
    • Experience
    • Projects
    • Skills
    • Blog
    • Talks
    • Contact
    • Why

    © 2026 Sebastian Alvarez

    All projects

    CodeSentry Swarm

    Three AI agents on Google Cloud that review a pull request, prove the bug with a failing test in a sandbox, and propose a fix. Deterministic code decides, and a person merges.
    Source Code
    CodeSentry Swarm
    Role
    Backend & AI Engineer
    Timeline
    November 2026
    Status
    In Progress

    In numbers

    AI agents, each behind its own queue
    33
    From a new pull request to a proposed fix, live
    111111s
    Model cost for 22 reviewed pull requests
    0.130.13USD
    Spans in one trace, from webhook to verdict
    1515

    About the Project

    CodeSentry Swarm is a multi-agent pipeline that audits a pull request, tests its own hypothesis in an isolated sandbox, and comments a typed fix. The idea behind it: the probabilistic part lives behind a queue, and the decisions that matter are made by deterministic code.

    When a pull request opens, a signed webhook reaches an API on Cloud Run, which stores the task in Firestore and answers right away. Triage, on Gemini, reads the diff and writes a hypothesis, a pytest test and the edits. A Cloud Run Job runs that test in a sandbox with no network: it must fail on the pull request, and the whole suite must pass with the fix. The Judge reads the exit codes and writes the verdict; it can reject a green run but never approve a red one. A failing run goes back to Triage with feedback, up to three times, and then asks a person. Every step is a Pub/Sub message with retries and a dead-letter queue, and every model call is a span in Cloud Trace with its tokens and cost.

    I built it in November 2026 as the live demo for my talk From Endpoints to Agent Swarms, first given at Universidad Indoamérica. I wanted to show the backend patterns that make agents safe to run, not another chat window: queues, idempotent stages, sandboxes, budgets and tracing. It is Python and FastAPI, deployed with Terraform and MIT-licensed, and it also runs offline with hand-written scenarios for anyone who wants to try it without a cloud account.

    Technologies
    1. AI

      • Gemini AI
    2. API & backend

      • Python
      • FastAPI
    3. Data

      • Firestore
    4. Cloud & infra

      • Cloud Run
      • Pub/Sub
      • Terraform

    Relevance

    Agents in production terms: queues, idempotent stages, sandboxed execution, deterministic gates and tracing on Google Cloud.

    How it works

    The path a request takes, step by step.

    1. 01 · PersonPull requestSigned GitHub webhook
    2. 02 · ServiceAPICloud Run answers 202 and stores the task in Firestore
    3. 03 · AI agentTriageGemini writes a hypothesis, a test and the fix
    4. 04 · ServiceSandboxCloud Run Job with no network and no roles
    5. 05 · AI agentJudgeGemini reads the exit codes and writes the verdict
    6. 06 · ResultCommentThe fix and a typed report on the pull request
    Every hop is a Pub/Sub message with retries and a dead-letter queue. A red run goes back to Triage with feedback, up to 3 times, and then asks a human.

    Decisions

    The choices that shaped it, and what each one cost.

    1. 01

      Put every agent behind a queue

      Why
      A slow or failing model call retries with backoff instead of holding the webhook open. After 5 attempts the message lands in a dead-letter queue instead of disappearing.
      What it cost
      Pub/Sub starts a new trace for each message and Eventarc arrives with no context, so the trace ID has to travel by hand.
    2. 02

      Let exit codes decide, not the model

      Why
      The new test must fail before the fix and the whole suite must pass after it. The Judge can reject a green run, but it can never approve a red one.
      What it cost
      Green is evidence, not proof: a test that only covered its own case let a wrong rounding fix through. That is why a human merges.
    3. 03

      Run untrusted code in a job with no identity

      Why
      The sandbox has no network and its service account has no roles. It reads the code and writes the result through signed URLs that expire in 15 minutes.
      What it cost
      The first run took 1 min 32 s to start, so a live demo needs a warm-up pull request first.
    4. 04

      Derive the task ID from the commit

      Why
      The ID comes from the repository, the pull request number and the commit, so a redelivered webhook lands on the same task and each stage is claimed once.
      What it cost
      Every new push is a new task, so pushing again means another review and another comment.

    Next project

    KairoOpen-source tasks for iOS and Android. Shared calendars, realtime sync with friends, and focus tools for ADHD.Next project
    listerineh.dev

    Full-stack engineer building AI agents, cloud platforms and web products. Based in Quito, working remotely.

    Open to new projects

    Work

    • Projects
    • Experience
    • Skills
    • Blog
    • Talks

    About me

    • About
    • Why Listerineh?
    • Contact

    Connect

    • GitHub
    • LinkedIn
    • Instagram
    • Email

    © 2026 Sebastian Alvarez · All rights reserved.

    • Privacy Policy
    • Terms of Use
    • Unsubscribe from the newsletter
    • Component Library