feat: add PyRIT Crescendo adaptive multi-turn to red-team task - #66
Open
ikrispin wants to merge 7 commits into
Open
feat: add PyRIT Crescendo adaptive multi-turn to red-team task#66ikrispin wants to merge 7 commits into
ikrispin wants to merge 7 commits into
Conversation
Add IntegrationTestScenario support so Konflux applications can run ABEvalFlow A/B evaluations as part of their CI pipeline. Includes: - 9 Tekton tasks adapted for Konflux (parse-snapshot, deploy-agent, prepare, test, evaluate, analyze-scorecard, store, emit-result, cleanup-agent) - PipelineRun definition chaining all tasks with cross-cluster agent deployment on a workload cluster - Makefile and GitHub Actions workflow for publishing Tekton Bundles - Secrets template for workload cluster credentials and LLM config - Google Lightspeed Agent submission as initial POC
Refactor the Konflux integration from a Lightspeed-specific pipeline into a generic evaluation framework that any Konflux application can consume. Changes: - Remove deploy-agent and cleanup-agent tasks from core (moved to the example repo github.com/ikrispin/abevalflow-konflux-example) - Refactor evaluate.yaml to support local/remote eval modes and all engines (a2a, mcpchecker, harbor, ase) with parameterized secrets - Rewrite PipelineRun as a generic 7-stage reference pipeline with standardized parameters (EVAL_ENGINE, AGENT_ENDPOINT, MCP_URL, EVAL_MODE, etc.) - Move Lightspeed submission and IntegrationTestScenario to the separate example repo - Add Konflux integration guide documentation - Update Makefile to publish 7 core task bundles (was 9) - Update secrets template with mode-conditional documentation Tested: Full successful pipeline run on Konflux with the Lightspeed agent example repo (PipelineRun lightspeed-abevalflow-eval-qhx2p, 9/9 tasks succeeded).
Adds adversarial testing via Promptfoo as a new stage in the Konflux evaluation pipeline. The task is fully generic — supports A2A agents, MCP servers, and HTTP endpoints without any application-specific code. - pipeline/tasks/konflux/red-team.yaml: new Tekton task with setup, generate-config, and run-redteam steps - scripts/generate_redteam_config.py: engine-agnostic config generator using --target-url (replaces --agent-endpoint) - konflux-eval-pipelinerun.yaml: inserts red-team between test and evaluate, enabled by default, gated on endpoint availability - aggregate_scorecard.py: consumes redteam-results.json as a security gate in the unified scorecard - Makefile: adds red-team to the Tekton Bundles publish list Modes: "smoke" (~25 tests, basic strategy, ~2 min) and "full" (~1750 tests, all strategies, ~90 min). Only tests plugins relevant to agent behavior (policy, hijacking, prompt-extraction, cybercrime, non-violent-crime) — content safety categories are the LLM's job.
Complement Promptfoo with a full-mode Crescendo step that adapts each turn from live agent responses and scores objectives via LLM-as-judge.
Must-fix (blocking): - Remote mode now clones SUBMISSION_REPO_URL in the eval Pod when it differs from PIPELINE_REPO_URL (was only cloning pipeline repo) - Remote Failed pod now exits 1 instead of silently passing - All task defaults now point to RHEcosystemAppEng/ABEvalFlow (was pointing to ikrispin fork in 4 tasks) - Fail closed: exit 1 when report.json is missing after eval, when engine commands fail with no results, and when log extraction fails Should-fix (nice to have): - Wire llm-credentials Secret via optional SecretKeyRef in evaluate - Add LLM_API_KEY param to reference PipelineRun - Document .components[0] default and multi-component footgun - Document engine x mode validation matrix in guide - Add comments about disabled security/quality in reference pipeline - Remove hardcoded LiteLLM URL and OpenShift console URL defaults - Remove hardcoded mcpchecker model defaults (use mcpchecker defaults) - Track ASE iteration failures; fail if all iterations fail
Must-fix:
- Fix ruff format on aggregate_scorecard.py and generate_redteam_config.py
- Fix GateResult construction: use gate_name (not name), details as dict
(not str), findings as list[Finding] (not list[str]), add policy_key
- Wire MCP_URL into red-team task for mcpchecker engine support
- Fail closed: exit 1 when config missing, generate fails, eval produces
no results, or results file absent (was exit 0 / silent green pass)
- Default RED_TEAM_MODE to smoke (was full ~90min) in both task and
PipelineRun for CI-appropriate defaults
Nice-to-have:
- Fix rstrip("/v1") to removesuffix("/v1") (character vs substring strip)
- Update docs: 8 tasks (was 7), add red-team bundle to table
- Add promptfoo-cloud-credentials to secrets template (optional)
Must-fix:
- CI green: ruff format/check on pyrit_crescendo (I001 import sort, UP017 datetime.UTC)
- Security: remove plaintext LLM API key from generated promptfooconfig.yaml;
use Promptfoo env interpolation {{env:OPENAI_API_KEY}} instead
- Mount promptfoo-cloud-credentials Secret (optional) + OPENAI_API_KEY in
run-redteam step for Promptfoo Cloud auth and LLM judge
- Fix --agent-endpoint alias: --target-url was required=True blocking the
alias from working; now uses post-parse validation with parser.error()
- Crescendo fail-closed: exit 1 when CRESCENDO_EXIT != 0 and no results
file produced (was logging exit code but ignoring it)
Tests:
- Add tests/test_redteam.py with 20 tests covering:
- Generator provider shapes (A2A JSON-RPC, MCP native, HTTP)
- Smoke vs full mode (test count, strategies)
- Metadata handling (full config, disabled, missing, partial)
- Env interpolation for API keys (no plaintext leak)
- URL suffix stripping (removesuffix vs rstrip)
- Scorecard gate construction (GateResult schema, Finding objects)
- Fetch-failed exclusion from findings
- Combined Promptfoo + Crescendo gate
- All-passing and no-results edge cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds PyRIT-style adaptive Crescendo as a second red-team stage on top of #65 (Promptfoo). Promptfoo keeps broad single-turn coverage; Crescendo runs real-time multi-turn attacks where an attacker LLM adapts each turn from the agent's replies and an LLM-as-judge scores objective success.
Builds on top of #65 (generic Konflux red-team / Promptfoo). Merge #65 first; this PR's diff will then show only the Crescendo additions after rebase.
Architecture
Crescendo is skipped when
red-team-mode=smoke,eval-engine=ase, or no endpoint. MCP Crescendo is out of scope for this PR.What's included
scripts/pyrit_crescendo/pipeline/images/pyrit/Containerfilehttpx+PyYAML)pipeline/tasks/konflux/red-team.yamlrun-crescendostep + finding mergepipeline/tasks/phases/red-team.yamlpipeline/pipelines/ci-pipeline.yamlpipeline/integration/konflux-eval-pipelinerun.yamlRED_TEAM_CRESCENDO_MAX_TURNSscripts/generate_redteam_config.py"crescendo"strategy (~125 tests)scripts/aggregate_scorecard.pyabevalflow/schemas.pyRedTeamConfig.crescendo_objectivesImage
quay.io/rh-ee-ikrispin/abevalflow-pyrit:0.1Key design decisions
Complementary, not duplicate — Promptfoo's static
crescendostrategy is removed; adaptive multi-turn lives only in the PyRIT-style step (~125 fewer Promptfoo cases; Crescendo is deeper, fewer objectives).Objectives — Use
red_team.crescendo_objectiveswhen set; otherwise auto-derive 3–5 frompurpose/policy/auth_context.Scoring — LLM-as-judge via LiteLLM (not keyword heuristics). Prefer a capable attacker/judge model (e.g. Sonnet); Haiku often refuses to generate attacker turns.
Gating — No separate enable flag; runs whenever red-team is on and mode is
full.How to enable Crescendo objectives
POC validation
Full Crescendo run against Lightspeed in
itay-evalflow(Promptfoo skipped; 5 objectives × max 7 turns, Sonnet attacker/judge): 2/5 objectives marked achieved. Manual review: both are borderline (CVE advisory "attack chain" wording + RH/OpenShift-adjacent education), not clear hard compromises — judge/policy tuning recommended as follow-up.Known limitations
quay-pull-secreton the pipeline SARelated