pub struct AdversarialTestCase {
pub name: String,
pub description: String,
pub test_type: AdversarialTestType,
pub expect_rejection: bool,
}Expand description
A structured adversarial test scenario.
Use one of the constructor methods (prompt_injection, ambiguous_instruction,
etc.) on this type to construct, then hand off to whatever evaluation harness
you use to run it against an agent.
Fields§
§name: StringHuman-readable identifier (used as the case name in reports).
description: StringLonger description of what this test is checking.
test_type: AdversarialTestTypeThe specific adversarial scenario.
expect_rejection: boolWhen true, the test expects the agent to reject or refuse the
adversarial input rather than comply with it.
Implementations§
Source§impl AdversarialTestCase
impl AdversarialTestCase
Sourcepub fn prompt_injection(
name: impl Into<String>,
payload: impl Into<String>,
expect_rejection: bool,
) -> Self
pub fn prompt_injection( name: impl Into<String>, payload: impl Into<String>, expect_rejection: bool, ) -> Self
Create a prompt-injection adversarial case.
Sourcepub fn ambiguous_instruction(
name: impl Into<String>,
variants: Vec<String>,
) -> Self
pub fn ambiguous_instruction( name: impl Into<String>, variants: Vec<String>, ) -> Self
Create an ambiguous-instruction adversarial case.
Sourcepub fn missing_context(
name: impl Into<String>,
missing_key: impl Into<String>,
expected_value: Option<String>,
) -> Self
pub fn missing_context( name: impl Into<String>, missing_key: impl Into<String>, expected_value: Option<String>, ) -> Self
Create a missing-context adversarial case.
Sourcepub fn budget_exhaustion(
name: impl Into<String>,
max_steps: usize,
task_description: impl Into<String>,
) -> Self
pub fn budget_exhaustion( name: impl Into<String>, max_steps: usize, task_description: impl Into<String>, ) -> Self
Create a budget-exhaustion adversarial case.
Sourcepub fn with_expect_rejection(self, expect: bool) -> Self
pub fn with_expect_rejection(self, expect: bool) -> Self
Override the expect_rejection flag.
Sourcepub fn injection_payload(&self) -> Option<&str>
pub fn injection_payload(&self) -> Option<&str>
Return the injection payload if this is a PromptInjection case.
Trait Implementations§
Source§impl Clone for AdversarialTestCase
impl Clone for AdversarialTestCase
Source§fn clone(&self) -> AdversarialTestCase
fn clone(&self) -> AdversarialTestCase
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more