AI Agent CI CD Pipeline 2026

🤖 Agents 2026-07-17 · Updated 2026-11-25 3 min read

Shipping an agent changes more than code: prompts, tool schemas, model versions and eval sets all move. Unit tests alone leave production as the test bed. Here is a minimal pipeline that gates every merge on prompt evals, builds an immutable image, and rolls out behind a human approval.

📜 Table of Contents

📖 Keep reading

CI/CD for AI Agents: Test and Deploy Automatically

An agent release changes code, prompts, tool descriptions, model versions and eval sets. If only unit tests run before deploy, production becomes the test environment. This is a minimal pipeline that actually holds up.

What you are shipping

Asset Change rate Failure mode Rollback
Orchestration code, tool functions High Crashes, loops, timeouts git revert and rebuild
System prompt High Drift, broken format, tone shift Switch prompt version
Tool schema Medium Wrong tool or bad args Keep both versions behind a flag
Model and sampling params Low Cost or quality jump Revert in config service
Knowledge index High Wrong or stale answers Restore index snapshot
Eval set Medium Gate goes blind Version the eval set itself

Most teams only gate the first row. Incidents usually come from the other five.

Six stages

  1. Lint (ruff, mypy) — seconds, catches the cheap mistakes
  2. Unit tests with mocked or recorded model responses
  3. Prompt eval gate — fixed suite, fail under threshold
  4. Build image tagged with the commit sha, never latest
  5. Deploy to a staging slot and run smoke cases
  6. Human approval, then production

Stage 3 is agent-specific and the one most often skipped.

GitHub Actions

name: agent-ci
on:
  pull_request:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - run: pip install -r requirements.txt
      - run: ruff check . && pytest -q
      - name: Prompt eval (smoke)
        env:
          LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
        run: python evals/run.py --suite smoke --min-pass-rate 0.90

Run 20-30 smoke cases on pull requests and the full suite on main. Running everything on every PR burns both time and API budget.

Writing the gate

Assertions, not vibes. Three kinds cover most failures:

Type Question Example
Structure Can code parse it? Valid JSON, all fields present
Content Are the facts there? Order id included, no "I cannot answer"
Behaviour Does it refuse when it should? Unauthorized request refused, no tool call
import json, sys
from agent import run_agent
from evals.assertions import check

cases = json.load(open("evals/smoke.json", encoding="utf-8"))
passed = 0
for c in cases:
    out = run_agent(c["input"], temperature=0)
    ok, reason = check(out, c["expect"])
    passed += ok
    if not ok:
        print(f"FAIL {c['id']}: {reason}")

rate = passed / len(cases)
sys.exit(0 if rate >= 0.90 else 1)

Rules that keep the gate trusted: temperature 0, pinned model version, threshold slightly below 100% so normal variance does not block every PR, explicit negative cases, and an eval set sampled from real traffic.

Treat cost as a regression too

One sentence in a prompt can add 40% to input tokens. Log total input and output tokens per eval run and diff against the previous baseline. Show the delta in the PR rather than discovering it on the invoice.

Canary and rollback

FAQ

No eval set yet? Sample 50 real requests, write the conditions a good answer must satisfy, start with your top intents. Add one case for every bug you fix.

Too expensive to call the model on every PR? Two tiers: smoke on PRs with cached responses where possible, full suite on main. Mock everything in unit tests.

Prompts in git or a config service? Either, as long as the version is traceable and tied to the deployed image. If in git, keep prompts/ under version control and stamp the version into the environment and logs.

Do I need Kubernetes? No. Docker plus nginx handles blue-green on one host. Fix the gate and rollback first.

Related Articles
2026-08-01
Multi-Agent Systems on GitHub in 2026: 10 Frameworks with Real Stars
2026-08-06
MCP Playwright Server (5,628 Stars) 2026: Give AI Agents Browser Automation via Model Context Protocol
2026-07-23
Multi-Agent Orchestration Frameworks 2026: LangGraph vs CrewAI vs AutoGen
2026-08-12
Dify vs RagFlow 2026: Which Open Source RAG Platform Fits Your Stack? Real Stars and Tradeoffs
2026-07-17
AI Agent Structured Logging 2026
2026-07-17
AI Agent Input Sanitization 2026

Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.

💬 Comments (0)

No comments yet. Be the first!

Login to comment