Back to blog
CI/CDregression testsPromptfooGarakPyRIT

AI Agent Security Tests in CI/CD Pipelines

Published on 2026-11-165 min read
In short: An AI agent changes behavior with every change to its prompt, model, tools or data sources, so a fixed flaw can come back without anyone noticing. The countermeasure is to replay an injection test suite on every change, with numeric blocking thresholds, inside the CI/CD pipeline. Promptfoo, Garak and PyRIT can feed that suite. It catches regressions on known attacks. It does not replace a human attacker who invents new attack chains.

Which changes should trigger security tests?

Any change that alters what the agent reads, decides or can do. The table pairs each event with the test and the blocking level we recommend.

ChangeRiskTest to replayBlocking
System prompt editedA refusal instruction disappearsDirect and indirect injection suiteBlocks the PR merge
Model or model version changeDifferent behavior against the same trapsFull suite with repetitionsBlocks the release
Tool added, tool schema or description editedNew capability or new injection through the descriptionTool abuse and authorization testsBlocks the merge
New data source (RAG, connector)Untrusted content entering the contextIndirect injection through that sourceBlocks the release
Dependency updateOrchestration logic changesFunctional tests and a short suiteWarns
Schedule (nightly, weekly)Drift in a hosted modelFull attack suiteAlerts the team

Which tools should you plug in, and how?

You combine a scenario tool with a deterministic check of tool calls. Promptfoo generates adversarial inputs from its "plugins": promptfoo redteam init --no-gui creates the configuration, promptfoo redteam run generates several hundred adversarial inputs, saved in redteam.yaml, and promptfoo redteam report shows the results. Its documentation gives an example of a scheduled GitHub Actions workflow (promptfoo/promptfoo-action@v1 with type: 'redteam') running daily and on demand. Plan a token budget: a red team run calls the model a very large number of times.

Garak (NVIDIA) runs from the command line, for example python -m garak --target_type openai --target_name <model> --spec probes.promptinject, and writes a JSONL report on every run. Its documentation does not describe an exit code tied to detected vulnerabilities: the pipeline must therefore read the report and decide for itself. PyRIT, an open source tool from Microsoft's AI Red Team, provides a command-line scanner for repeatable scans. To choose between them, see the Promptfoo, Garak and PyRIT comparison.

A minimal guardrail on a Promptfoo evaluation, which fails if a test failed:

```yaml

name: agent-security-tests

on:

pull_request:

paths: ["prompts/", "tools/", "promptfooconfig.yaml"]

permissions:

contents: read

jobs:

injection:

runs-on: ubuntu-latest

steps:

  • uses: actions/checkout@v4
  • uses: actions/setup-node@v4

with: { node-version: "24" }

  • run: npx promptfoo@latest eval -c promptfooconfig.yaml -o results.json

env: { OPENAI_API_KEY: "${{ secrets.TEST_LLM_KEY }}" }

  • run: |

FAILURES=$(jq '.results.stats.failures' results.json)

test "$FAILURES" -eq 0

`

The .results.stats.failures field and the use of jq follow the examples in Promptfoo's documentation; adapt the secret's name to your provider.

Which blocking thresholds should you set?

Set them on the agent's actions. A model can refuse in words and still act, so the reliable assertion targets tool calls and network output.

Test typeMeasureProposed blocking threshold
Forbidden action (send, delete, permission change triggered by untrusted content)Observed tool callA single occurrence blocks
Canary leak (unique string in a document)Presence in the output or a requestA single occurrence blocks
Success rate of an attack familySuccesses over n trials, with an intervalBlocks if the interval's upper bound exceeds the threshold (e.g. 10%)
Regression on an already fixed flawCase replayed identicallyBlocks as soon as it succeeds again

For the rate, count at least 35 trials per scenario if you want to demonstrate a rate below 10% with zero successes (upper bound of the 95% Wilson interval). Three trials prove nothing: models do not always answer the same way, even at temperature 0. Keep the heavy suite for model changes and nightly runs, and a short suite for PRs.

What should go in the test suite?

Each case is a small versioned folder in the repository: a trapped document or message, the task given to the agent and an assertion about what must not happen. Feed the suite three ways: the attacks of the prompt injection category in the OWASP Top 10 for LLM Applications (LLM01), your agent's real incidents, and every fixed flaw, which immediately becomes a regression test. Split it into three levels: a short suite (a few minutes) on every PR, a full suite before every release or model change, an extended suite at night. Record in each report the model version, the prompt and the tool list, so a result can be tied to a specific change.

What pitfalls does the pipeline itself introduce?

The main ones are secrets, caching and untrusted content processed by CI. GitHub's documentation advises avoiding the pull_request_target trigger when it is not necessary, because those workflows may have write access and access to secrets, and not checking out untrusted code in them; it also recommends a read-only default GITHUB_TOKEN and advises against self-hosted runners for public repositories. Use a test key with a capped budget, never a production key, and fake data.

On caching: Promptfoo's documentation shows a response cache (an example with a 24-hour lifetime). A response served from the cache no longer measures the model, so check that your regression runs really call the model. Finally, if your pipeline has a review agent read PRs or tickets, that content is untrusted too: this is the subject of coding agent security.

What does automation not replace?

It detects the return of attacks you already know. It does not replace:

  • The attacker who adapts: they rephrase, chain several steps and exploit business context, where a suite replays fixed cases.
  • Real authorization flaws: knowing whether user A can make the agent act on B's data requires understanding the architecture.
  • Judgment on verdicts: a model grading the results makes mistakes, with false positives and false negatives; part of them must be reviewed.
  • Chains across tools: a harmless read followed by a harmless write can amount to exfiltration.

Our production checklist lists the controls not to leave to automation.

How does CleanIssue fit with your CI/CD?

An engagement delivers a report with reproducible evidence: those are the attack cases to replay afterwards in your pipeline. The Agent Red Team Express (€1,900, 5 days, start within 48 hours after the quote and authorization are signed) covers one agent and its tools; several agents or pipelines fall under the Custom Red Team, quoted individually. Tests run on development or staging by default. For the framework, see AI agent pentesting. The first step is a free 30-minute discovery call.

Does your product ship an AI agent? CleanIssue tests what a stranger can make it do with the Agent Red Team Express (5 days, €1,900), or a custom red team for several agents and MCP servers. First step: a free 30-minute discovery call.

Know what your agent can do before an attacker does.

A free 30-minute discovery call: you describe your agent, I tell you what I would test and what it costs. Five case studies are published.

Book a call