AI-Assisted Engineering

AI Agents in CI/CD: Can Agents Test, Debug and Deploy Software?

Coding agents now run inside CI pipelines: triaging failed builds, fixing flaky tests, reviewing pull requests and responding to issues. They can save hours a week, and they also bring untrusted input and powerful tokens into the heart of the delivery system. We look at what works, what fails and how to run agents in CI safely.

By EthicalHat Research · · 3 min read
Infographic: Where agents fit in the pipeline, and where they don't

Over the past few months, coding agents have moved from developers' laptops into CI/CD. Vendors now offer agents that run as GitHub Actions or as integrated services: mention them in an issue or pull request and they investigate, write code, run tests and push a branch. GitHub's Copilot coding agent, OpenAI's Codex and Anthropic's Claude Code all offer this kind of integration.

The promise is a pipeline that helps fix itself. The risk is putting an instruction-following model, which reads untrusted text, inside the system that builds and ships your software.

What agents do well in CI

Failed build triage. Reading thousands of lines of logs, identifying the failing step and the likely cause, and commenting on the pull request with an explanation. This is high value and low risk.

Fixing broken and flaky tests. Reproducing a failure, adjusting the test or code, and proposing a fix as a separate pull request.

Dependency updates. Taking automated upgrade PRs that fail CI and making the code changes needed to pass.

First-pass review. Commenting on pull requests with likely bugs, missing tests and inconsistencies, before a human reviewer looks.

Small issues. Well-specified issues with reproduction steps can be turned into draft pull requests.

What should stay deterministic

Gating and deployment. Whether a change is allowed to merge or deploy should be decided by deterministic checks (tests, policy, security scans) and human approval, not by an agent's judgement. An agent may propose; the pipeline and people dispose.

Changes to pipeline configuration. Agents should not modify workflow files, build scripts or deployment configuration without the same review as any other critical change. Ideally, they should not be able to push such changes at all.

The security problem: untrusted input meets powerful tokens

CI systems are privileged: they hold tokens that can push code, publish packages and sometimes deploy. Agents in CI read content that anyone may be able to write: issue text, pull request descriptions, code comments, commit messages and dependency code.

flowchart LR
  X[Attacker opens issue or PR<br/>with hidden instructions] --> T[Workflow triggers agent]
  T --> A[Agent reads issue / diff]
  A -->|if over-privileged| B[Pushes to protected branch,<br/>exfiltrates secrets,<br/>edits workflows]
  A -->|if least-privileged| C[Can only comment<br/>or open a draft PR]

This year has shown that AI developer tooling is now a target:

  • In July, a malicious prompt was inserted into a release of Amazon Q's VS Code extension, instructing the agent to delete files and cloud resources. It shipped briefly before being pulled, and was reportedly crafted so that it would not actually work.
  • In August, the compromised Nx packages ("s1ngularity") tried to use AI CLIs on developer machines to hunt for secrets.

Pipelines that run agents on untrusted input need to be designed with this in mind.

Running agents in CI safely

1. Least-privilege tokens. Give agent jobs the minimum permissions needed, often contents: read and pull-requests: write to comment. Let them push only to their own branches, never to protected ones.

yaml
# Illustrative: an agent job that can read code and comment, nothing more
on:
  issue_comment:
    types: [created]
jobs:
  agent-triage:
    if: contains(github.event.comment.body, '/ai-triage') &&
        contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
      issues: write
    steps:
      - uses: actions/checkout@v4
        with: { persist-credentials: false }
      - name: Run agent (no secrets in environment)
        run: ./tools/run-agent --task triage --max-steps 30 --network-allowlist api.model-provider.example

2. Trigger only on trusted actors. Require that agent runs are triggered by maintainers, not by anyone who can open an issue. Be especially careful with workflow events that run with elevated permissions on content from forks.

3. No secrets in agent jobs. Keep deployment credentials, package publishing tokens and cloud keys out of any job an agent runs in.

4. Isolated, ephemeral runners with restricted network egress.

5. Protect workflow files. Use code owners and branch protection so changes to .github/workflows and build scripts require human review, and deny agents write access to them.

6. Pin and review agent tooling. Pin versions of agent actions and CLIs, and treat updates as supply-chain changes.

7. Log everything. Keep transcripts of agent runs, including what they read, which commands they executed and what they changed.

Measuring value

Track whether agents actually help: time to green for failed builds, flaky test counts, merge rates for agent PRs, and reviewer time saved. Some teams find the biggest win is simply the triage comment on every failed build.

The bottom line

Agents can take real toil out of CI: explaining failures, fixing tests and preparing routine changes. They should propose, not decide, and they should run with the least privilege possible, because in CI they read untrusted input with access to one of the most sensitive systems you have.

Our DevSecOps team builds agent-assisted CI/CD workflows with these guardrails, and our application security testing includes CI/CD pipeline security reviews.

EthicalHat Research

The EthicalHat research team: penetration testers, SOC analysts and engineers writing about security, software engineering and AI.

Want an expert opinion on your own systems?

Email info@ethicalhat.com or call +1-844-838-4422. Our security engineers are happy to talk it through.