Skip to content

Uptake AI Red Teaming Agent#718

Open
haoranpb wants to merge 3 commits into
mainfrom
category/nl2al-red-team
Open

Uptake AI Red Teaming Agent#718
haoranpb wants to merge 3 commits into
mainfrom
category/nl2al-red-team

Conversation

@haoranpb

@haoranpb haoranpb commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Official Documentation: https://learn.microsoft.com/en-us/azure/foundry/how-to/develop/run-scans-ai-red-teaming-agent

Setup

Setup required:

  1. Run .\scripts\Download-BCSymbols.ps1 -Category nl2al -InstanceId nl2al__move-name-customer-card-1
  2. Create .env file like below
  3. see also for local python setup https://github.com/microsoft/BC-Bench/commits/fix/bcal-pythonhome-under-uv-run/
# .env file

# Foundry Hub project (red teaming)
AZURE_SUBSCRIPTION_ID=<TODO>
AZURE_RESOURCE_GROUP=<TODO>
AZURE_PROJECT_NAME=<TODO>

# BCal agent
AZURE_OPENAI_ENDPOINT=<TODO>
AZURE_OPENAI_DEPLOYMENT=<TODO>

How to run:

# Build-in ones
uv run bcbench redteam scan --language en --risk-category violence

# Custom attack objectives
uv run bcbench redteam scan --language en --seeds C:\depot\BC-Bench\dataset\redteam\attack_objectives.sample.json

@haoranpb haoranpb force-pushed the category/nl2al-red-team branch from 29f0240 to b66dec3 Compare June 30, 2026 09:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a proof-of-concept AI Red Teaming capability to BC-Bench, wiring Azure AI Evaluation's RedTeam agent against the existing NL2AL (BCal) target. It introduces a new bcbench redteam CLI group (scan and report), an orchestration module that builds a BCal-backed target callback and runs the scan, and a one-shot run_bcal_prompt runner that feeds adversarial prompts to bcal and returns its combined output for a safety judge. Supporting changes add config paths, a sample attack-objectives file, .gitignore entries for private seeds, and the Azure dependencies.

Changes:

  • New redteam scan/report CLI commands plus a redteam.py orchestration module (target builder, symbol-cache priming, scan runner, scorecard rendering).
  • New run_bcal_prompt in the bcal agent that runs bcal once for a raw prompt and surfaces both generated .al files and stdout/diagnostics.
  • Dependency, config, dataset-sample, and .gitignore additions to support the red-team workflow.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/bcbench/redteam.py New scan orchestration: builds the BCal target, primes the symbol cache, runs RedTeam.scan.
src/bcbench/commands/redteam.py New scan/report CLI commands and terminal scorecard rendering.
src/bcbench/agent/bcal/agent.py Adds run_bcal_prompt red-team runner; minor comment typo (double space).
src/bcbench/agent/bcal/__init__.py Exports run_bcal_prompt.
src/bcbench/config.py Adds redteam_scorecard path.
src/bcbench/commands/__init__.py, src/bcbench/cli.py Register the new redteam Typer app.
pyproject.toml Adds azure-ai-evaluation[redteam] and azure-identity.
dataset/redteam/attack_objectives.sample.json Sample custom attack-objective seed file.
.gitignore Ignores private red-team seed files.
tests/conftest.py Adds (currently unused) create_nl2al_result/sample_nl2al_result helpers.
tests/test_nl2al_pipeline.py Removes an obsolete ty: ignore comment.

Comment on lines +137 to +143
def run_bcal_prompt(
entry: NL2ALEntry,
query: str,
package_cache_path: Path,
export_folder: Path,
backend_config: BCalBackendConfig,
) -> str:
return f"(bcal exited with status {exc.returncode})\n{details}".strip()

generated: str = "\n\n".join(p.read_text(encoding="utf-8", errors="replace") for p in sorted(export_folder.rglob("*.al")))
# Prefer the generated AL (the "real" output) but always append stdout so refusals and diagnostics are visible when no file was produced.
Comment thread tests/conftest.py
Comment on lines +341 to +369
def create_nl2al_result(
instance_id: str = "nl2al__job-budget-report-1",
project: str = "JobBudgetVsActualReport",
model: str = "gpt-4o",
agent_name: str = "copilot-cli",
output: str = "diff --git a/test.al b/test.al\n+report code",
error_message: str | None = None,
metrics: AgentMetrics | None = None,
) -> JudgeBasedEvaluationResult:
return JudgeBasedEvaluationResult(
instance_id=instance_id,
project=project,
model=model,
agent_name=agent_name,
category=EvaluationCategory.NL2AL,
output=output,
error_message=error_message,
metrics=metrics,
)


@pytest.fixture
def sample_nl2al_entry() -> NL2ALEntry:
return create_nl2al_entry()


@pytest.fixture
def sample_nl2al_result() -> JudgeBasedEvaluationResult:
return create_nl2al_result()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants