Skip to main content

Agentic CI/CD

CI/CD pipeline design when an autonomous agent is the developer — not just a tool in the pipeline, but the actor writing code, running tests, and triggering deploys. The key difference from standard CI/CD: CI is the external watchdog, not a convenience. The agent must pass CI before it can proceed; CI provides the enforcement the absent human would otherwise provide.

Key Difference from Standard CI/CD

The agent must not be able to override CI. If the agent can skip or modify the CI pipeline, the external watchdog is compromised.

Gate Sequence

Each gate must pass before the next step. The agent cannot advance by claiming success — the gate output is machine-verified by the harness.
Gates 1–6 run in CI (GitHub Actions, etc.). Gates 7–10 run in the deploy harness. Both are external to the agent.

Staging-First, Always

The autonomous agent never deploys directly to production. The flow is:
The prod deploy requires a different actor from the agent — a separate machine identity with a scoped deploy token, or a human. The agent’s credentials do not include prod deploy permissions. Why: the agent’s failure recovery (rollback) is tested on staging before prod. A deploy that passes CI but breaks on env config reveals itself on staging without affecting users.

Network Isolation: Builder vs Deployer

Two separate network contexts prevent cross-contamination: Builder network (during code generation and test runs):
  • Outbound: npm/pip/cargo registries, git remotes
  • No access to: staging/prod databases, cloud provider APIs, deployment endpoints
Deployer network (during staging deploy):
  • Outbound: container registry, staging host, health check endpoints
  • No access to: npm registries, arbitrary internet (prevents supply chain injection during deploy)
The agent process runs in builder context. Deploy is triggered via a separate deployer process with its own credential set — the agent cannot directly access deployer credentials.

Agentic-Specific Guardrails

Standard CI/CD guardrails assume a human developer who self-limits. With an autonomous agent, these become hard enforcements: Diff size cap CI rejects any commit where git diff --stat HEAD | total lines changed > N. Forces the agent to patch incrementally. Without this, a confused agent rewrites entire files to fix a one-line bug. No destructive migration auto-run CI detects migration files containing DROP TABLE, DROP COLUMN, TRUNCATE, or ALTER TABLE ... DROP. Flags and halts — does not run. The agent can propose the migration; a human (or separate approval gate) must authorize it. Flaky test quarantine Any test that fails intermittently across N clean runs is quarantined (skipped in CI, logged for repair). Flaky tests in the agent’s feedback loop corrupt self-healing: the agent believes it broke something, enters a repair cycle, and may actually introduce new bugs. Failure signature tracking CI stores the hash of each failing test + error message across retry runs. If the same signature appears after a patch, the agent does not get credit for “fixing” it — the gate stays red.

Completion Conditions

The agent must have explicit completion criteria, or the loop never exits cleanly:
  • All CI gates green on a fresh clone
  • Staging synthetic E2E passing
  • Monitor window (N minutes of healthy health checks) complete
  • No open failure signatures in loop-state.json
  • Incident log empty (no unresolved rollbacks)
The harness checks these conditions, not the agent’s self-report.

Rollback Integration

CI/CD owns rollback triggering, not the agent:
  • Health check fails post-deploy → deployer automatically redeploys last green image
  • Agent’s self-healing cycle exhausts retry budget → harness triggers rollback + writes incident note + sets ESCALATE=1 env flag
  • CI pipeline itself fails N times with same signature → pipeline marks job as “blocked, escalation required” and halts
The agent should never need to manually trigger rollback — this is a harness responsibility.

Observability

Minimum required for the harness to operate autonomously:

Minimum Stack for First Experiment

Based on the household expense tracker reference project: