Skip to content

fix(ai-red-teaming): collect multimodal attack results via assessment.run()#102

Merged
rdheekonda merged 1 commit into
mainfrom
fix/airt-multimodal-assessment-run
Jul 16, 2026
Merged

fix(ai-red-teaming): collect multimodal attack results via assessment.run()#102
rdheekonda merged 1 commit into
mainfrom
fix/airt-multimodal-assessment-run

Conversation

@rdheekonda

Copy link
Copy Markdown
Contributor

Summary

The generated multimodal workflow reported 0 finished trials (and wrote no analytics) even when the attack ran successfully and traced to the platform.

Root cause: the multimodal template ran each attack with await attack.run() directly on the Study. Only Assessment.run(study) appends the AttackResult to assessment.attack_results (assessment.py). Running the Study directly left that list empty, so _write_local_analytics saw no results → "0 finished trials". Every non-multimodal generator already uses assessment.run(...).

Discovered while probing a real SageMaker Gemma3-vision endpoint: trials executed, judge scored them, yet the CLI showed 0 trials.

Changes

  • await attack.run()await assessment.run(attack) in the multimodal main template (collects + uploads the result; also feeds local analytics).
  • Fix per-set except handler to use the real loop var set_number instead of undefined i (which raised NameError inside the handler, masking real errors).
  • Regression tests (proven red→green): assert the generated script uses assessment.run(attack) and not attack.run(), and that the handler uses set_number.
  • Fix stale test_per_media_prompts_list assertion (PROMPTS[i]set_prompt = PROMPTS[media_idx] after a prior refactor).
  • Bump capability 1.8.0 → 1.9.0 (minor).

Testing

  • TestGenerateMultimodalAttack: 17 passed (editable SDK 2.0.35).
  • Regression tests fail on the pre-fix template, pass after.
  • End-to-end re-run vs the live SageMaker endpoint: analytics now written; 2 trials; ASR reported.

Note

data/mmsafety_illegal_0.png in the workspace is a JPEG mislabeled .png; this is a data-hygiene issue, not the cause here (the workflow re-encodes media via PIL). The 0-trials symptom was purely the attack.run() bug.

….run()

The generated multimodal workflow ran each attack with `await attack.run()`
directly on the multimodal Study. Only `Assessment.run(study)` appends the
AttackResult to `assessment.attack_results`; running the Study directly left
that list empty, so `_write_local_analytics` reported "0 finished trials"
even though the trials executed and traced to the platform.

This produced a confusing false negative: a real SageMaker Gemma3-vision run
completed successfully (trials + judge scores) yet the CLI showed 0 trials and
wrote no analytics file.

Changes:
- Run the attack through `await assessment.run(attack)` so the result is
  collected into `assessment.attack_results` and uploaded (also feeds the
  local analytics writer). Every non-multimodal generator already does this.
- Fix the per-set except handler to reference the real loop variable
  (`set_number`) instead of an undefined `i`, which would raise NameError
  inside the handler and mask the true error.
- Regression tests: assert the generated script uses `assessment.run(attack)`
  and not `attack.run()`, and that the error handler uses `set_number`. Both
  fail on the pre-fix template and pass after.
- Fix a stale assertion in test_per_media_prompts_list (template was
  refactored from `PROMPTS[i]` to `set_prompt = PROMPTS[media_idx]`).
- Bump capability version 1.8.0 -> 1.9.0 (minor).
@rdheekonda
rdheekonda merged commit 95951f8 into main Jul 16, 2026
6 of 9 checks passed
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.

1 participant