Skip to content

In CI and in production

Fail a pull request when an agent gets weaker, and keep checking it once it is live.

Before you start

  • Suites and baselines live in the AgentFox database. The CLI gate needs that database: the CI job sets AGENTFOX_DATABASE_URL (a secret) to the one you created them in.
  • With an account key and no database access (AgentFox Cloud, or a server CI can only reach over HTTP), gate over HTTP instead: see Gate over HTTP.
  1. Fail the build when an attack gets through

    test redteam exits 1 when any attack got through. With --adaptive it also retries blocked attacks in disguised forms (encodings, role-play, look-alike tool names) and compares with the last run: WEAKER, STRONGER or UNCHANGED.

    bash
    agentfox test redteam support-triage --adaptive

    The first adaptive run is the baseline. Keep the probe list and --budget the same between runs, or each run starts a new baseline.

  2. Keep a test suite

    A suite is a set of prompts and what a good answer contains. Create one on Testing → Test suites, then add cases on its page. To turn a real failure into a case, paste its trace id (trc_…) under Promote a trace. The case asks what the run's user asked: runs keep the user's message and the reply, with personal data and secrets masked. A run with no recorded message (one from an older version) can't be promoted, and says so.

  3. Pin a baseline, then gate on it

    Run the suite once with your real model and save that run as the baseline. In CI, test gate runs it again and exits 1 if a score drops by more than 0.05, or if any case errored.

    .github/workflows/agent-tests.yml (steps)
    - run: pip install "agentfox[postgres]"
    - run: agentfox test redteam support-triage --adaptive
    - run: agentfox test gate support-quality --provider openai --model gpt-4o-mini --junit reports/junit.xml --sarif reports/agentfox.sarif

    Save the baseline with agentfox test baseline RUN_ID. The gate creates the reports/ folder if it isn't there. The CI tab on Testing shows these commands, and the HTTP one with your server filled in. A real provider needs AGENTFOX_ALLOW_EGRESS=true and its key.

  4. Gate over HTTP

    POST /api/eval/gate runs the same gate with an API key. A gate that fails answers 412 with the result (passed: false, JUnit, SARIF), so curl --fail-with-body fails the step and still saves it. Without --fail (or --fail-with-body) curl exits 0 and the build passes.

    bash
    curl --fail-with-body -sS -X POST "$AGENTFOX_URL/api/eval/gate" \
      -H "Authorization: Bearer $AGENTFOX_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"suite": "support-quality", "baseline_run_id": "RUN_ID", "min_pass_rate": 0.9}' \
      -o gate.json
    jq -r .junit gate.json > junit.xml

    min_pass_rate is a share from 0 to 1.

  5. Scan each pull request

    The AgentFox GitHub Action comments on risky tool combinations, poisoned skills and model calls without guardrails, and fails the check on the first two. It is static: nothing is run or sent. See Discover.

    yaml
    - uses: actions/checkout@v4
    - uses: architsharm/agentfox@main
      with:
        fail-on: trifecta,skills
  6. Score real traffic against a target

    On Testing → Reliability, Score real traffic grades recent runs with the same scorers as a suite. Add target sets a goal for one agent and one measure, such as 95% of answers grounded over 7 days, and shows how much budget is left. Only runs with a recorded reply are scored; the summary counts the ones it skipped.

    bash
    agentfox test online support-triage
    agentfox report drift support-triage --scorer groundedness

Probe a live agent

AgentFox can send a small, fixed set of attacks (9 attacks and 2 ordinary questions) to a deployed agent's endpoint on a schedule. When an attack that was stopped last time gets through, it opens an issue; when a later run stops it again, it closes the issue.

  • Set it up over the API: register the endpoint (POST /api/probes/targets, created off), then opt in with the exact warning text from GET /api/probes/warning. The opt-in is recorded on the audit trail. See the probes routes.
  • Your endpoint takes {"message": …} and answers with the reply, any tool_calls, and blocked.
  • At most one scheduled run an hour and one manual run every ten minutes. Only the host you opted in for is contacted. AGENTFOX_LIVE_PROBES_ENABLED=false stops every target.

If something goes wrong

You seeDo this
unknown suite in CIAGENTFOX_DATABASE_URL points at a different database from the one you created the suite in.
GATE FAIL with errored casesThe model was not reached. Check egress and the provider key.
"No previous adaptive campaign" on every runThe probe list or --budget changed. Keep them fixed.
A target reads "No data"Press Score real traffic for that agent first.