The newest genuinely-shipped agentic pattern in DevOps is the agent that lives inside the pipeline: invoked by a pipeline event, running with scoped credentials, its own identity, a hard cost budget, and an audit trail — exactly like any other constrained pipeline step.
Harness shipped this as Autonomous Worker Agents (GA June 2026, with sandboxing, per-agent AI identity, and token-cost tracking; customers like Verint and United built working agents in about four days), and GitLab Duo runs the same idea inside CI jobs. This lesson teaches the pattern tool-agnostically, then you build one on your laptop.
Red build. Friday at a 40-engineer logistics company. Priya, the platform engineer on rotation, gets the ping she dreads: the payments-api build is red on a release-candidate branch.
She opens the CI logs — 1,400 lines. Is it the code? Is it the runner image that got rebuilt on Tuesday? Is it test_settlement_batch, the test that fails one run in twelve for reasons nobody has had time to chase?
Twenty-three minutes of scrolling, one re-run "just to see" (nine more minutes of pipeline time), and a Slack thread with the commit author — who has already left for the weekend.
A real code bug: a one-line rounding error in a currency helper introduced three commits ago. She writes it up, assigns it, and the release slips to Monday.
Roughly 30 red builds a month at 15–40 minutes of senior triage each: more than a full engineer-week per month deciding what kind of red a red build is — before anyone even starts fixing anything.
Same red build — but the pipeline now has a deputy step wired to run only when the test stage exits non-zero.
round_half_even applied before the multiplier in src/money.py:41, introduced in commit e3f9a2deputy/autofix-1732 — never to the failing branch, never to mainPosted under the deputy's own identity,
deputy-ci, ninety seconds after the failure.
Priya reads the comment in two minutes, agrees with the classification, opens the autofix branch, sees CI has already re-verified it green, and merges. The release ships Friday. When the same deputy meets test_settlement_batch flaking the following week, it says so — Classification: flake, retry recommended — and nobody burns senior attention on it at all.
The critical detail is what the deputy cannot do.
main; its patches land on a fresh branch of its own.src/ and tests/the scope guard is code, not instruction.It is not a chatbot with pipeline access; it is a pipeline step with a narrow job, and every governance mechanism you already trust for pipeline steps — scoped credentials, least privilege, budgets, audit — applies to it unchanged. That is why this pattern shipped for real while flashier autonomy demos did not: platform teams already know how to govern pipeline steps.
The Pipeline Deputy is not "AI in CI" — it is an agent demoted, deliberately, to the status of a pipeline step: event-triggered, credential-scoped, budget-capped, identity-tagged, and audited. The demotion is the design.
Client-safe by design — the deputy runs against an approved tenancy (Claude on AWS Bedrock, Azure OpenAI) or fully offline via Ollama, with repo identifiers, customer names, and internal hostnames redacted from the log tail before prompting; the budget, identity, scope-guard, and audit code is unchanged. Full setup is in the build guide below.
Blue = AI-added step · Amber = human control point · Gray = your existing tools.
| Step | Who acts | What changes | Why it matters |
|---|---|---|---|
| Pipeline runs lint + tests | Your existing CI | Nothing new — same stages, same gates | The deputy adds a step; it never replaces deterministic verification |
| Build goes red | CI failure hook | Failure event triggers the deputy — and only then | Agent runs on-event, not on a loop; zero cost and zero risk on green builds |
| Deputy reads log + diff | AI agent (read-only) | Failure context assembled in seconds from artifacts humans would scroll through | The 15–40 minute "what kind of red is this?" triage collapses to about a minute |
| Deputy classifies: code / env / flake | AI agent | A structured verdict with cited evidence, not a vibe | Routing is the value: flakes get retried, env issues go to platform, code bugs go to the author |
| Verdict posted as a comment | AI agent, under its own identity | Reviewable text lands where reviews already happen | Advisory output in an existing surface — no new tool for humans to learn |
| Optional autofix branch | AI agent, scope-guarded | A proposed patch exists as a fresh branch, never on the failing branch | The fix is an offer, not an action; discarding it costs one click |
| CI re-verifies the autofix | Your existing CI | The deputy's own output must pass the same gates as human code | Agents get no verification discount — the pipeline is the referee for everyone |
| Human reviews and merges | Engineer | Accept, edit, or discard — with classification and evidence pre-assembled | The human gate moves from archaeology to judgment |
| Budget + audit ledger updated | Platform | Token spend, identity, actions, and refusals are on the record | You can answer "what did the agent do and what did it cost?" — the question every audit and every postmortem will ask |
| Component | In this lesson's build | In your stack |
|---|---|---|
| Event source | pipeline.sh detects a non-zero test exit and invokes the deputy | CI failure hooks: GitHub Actions if: failure(), GitLab when: on_failure, Jenkins post-failure stage, Harness failure strategy |
| Context stores (read) | .pipeline/test.log + git diff HEAD~1, read-only | CI logs and artifacts API, the git provider's diff API, test-report artifacts |
| Action interface (allowlisted writes) | review-comment.md + deputy/autofix-* branches only; scope guard limits patches to src/ and tests/ | PR/MR comment API + push rights restricted to agent/* branches; branch protection on main; per-path allowlists |
| Approval channel | You read the comment; you decide about the branch | PR review with CODEOWNERS; merge queue; required approvals |
| Verification | Re-run pipeline.sh on the autofix branch | CI required checks re-run on the agent's PR — same gates as human code |
| Audit sink + identity | .pipeline/audit.jsonl + the DEPUTY_IDENTITY env var + token ledger | Per-agent identity (Harness agent identity, a dedicated GitHub App, a GitLab service account) + token-cost tracking dashboards |
The deputy classifies and explains; it does not create autofix branches. Run this for two to four weeks and score its classifications against what engineers conclude — the log is your evaluation set.
Autofix branches on, merges still human. This is where the pattern should live long-term for most teams — the PR is the approval artifact.
A deputy that merges its own fixes has left this pattern and entered a different risk class; the shipped evidence (Harness, GitLab Duo in CI) keeps humans on the merge.
Demotion is a config change, not a failure — write the trigger conditions down before you promote. Review cadence: monthly, 30 minutes: read the audit ledger, sample five verdicts, check spend against budget, re-affirm or change the tier. An autonomy tier is a configured, revisited setting — never a default you set once.
Promote on evidence, demote on triggers you wrote down in advance. If the demotion criteria are not written down, the tier will only ever move up.