You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The following blog describes an interesting attack technique of randomly appending tokens to evade detection. We should explore if it works well and consider adding to PyRIT.
I'm marking this not ready yet and unassigning Adrian Gavrila (@adrian-gavrila). Before another implementation starts, we need to resolve the design and correctness issues identified in #1346, especially:
keeping execution state and conversation IDs isolated per beam/objective;
preserving caller target settings, including store=False;
preferring a beam that actually reaches the objective instead of selecting only by an auxiliary score;
clearing or removing failed beams so stale state cannot win;
making identifiers and scoring configuration capture behavior-defining settings;
continuing from original output rather than response-converted output; and
keeping auxiliary scorers as telemetry rather than letting them silently control the attack.
The original issue describes random appended-token search, while #1346 explored grammar-constrained beam search. We should also settle which technique and contract we actually want before reopening this for implementation.
I'd like to take the next pass on this now that #1346 is closed and the issue is marked not ready yet.
Before coding, I propose settling the open design/correctness points from Roman Lutz (@romanlutz)'s note (2026-09-22), then confirming which contract we want:
Technique: original random appended-token search (Google blog) vs grammar-constrained beam search from FEAT Beam Search for OpenAIResponseTarget #1346 — or a shared interface that can host both.
Correctness gates from FEAT Beam Search for OpenAIResponseTarget #1346: per-beam/objective isolation of execution state and conversation IDs; preserve caller target settings including store=False; prefer a beam that reaches the objective over auxiliary-score-only selection; clear/remove failed beams so stale state cannot win; identifiers/scoring config capture behavior-defining settings; continue from original output (not response-converted); auxiliary scorers as telemetry only.
I'll post a short design note covering those points for maintainer feedback before any implementation PR. Please assign me for the design thread if that works.
The main issue that made me block the previous PR was recreating the target over and over again. However, #3506 may allow us to reuse a single target with different params per request. I suggest waiting until that's merged. Julio César Suástegui (@juliosuas)
Roman Lutz (@romanlutz)#3506 is merged, so I'd like to pick this up. One gap first: RequestGenerationConfig only carries temperature, while #1346 re-created the target to swap each beam's Lark grammar tool. Plan: a small first PR adding a request-local grammar option to RequestGenerationConfig (Responses target only, capability-gated, validated like temperature), then BeamSearchAttack on one shared target with isolated conversation IDs per beam, caller settings like store=False preserved, beams that reach the objective winning over the auxiliary score, and failed beams pruned. Does extending the config that way work for you, or would you prefer a different mechanism? If it works, could you assign me?
Julio César Suástegui (@juliosuas) yes, this works, and with #3506 merged the reason for not ready yet is gone. Assigning you and removing the label. A few things to pin down so the two PRs land cleanly.
Technique. Let's go with grammar-constrained beam search, as explored in #1346. The random appended-token search from the original description stays out of scope here.
Acceptance criteria for BeamSearchAttack. Your Nov 11 plan lists four of the seven points from my Sept 22 note; all seven apply:
execution state and conversation IDs isolated per beam and per objective;
caller target settings preserved, including store=False;
a beam that actually reaches the objective wins over one selected only by an auxiliary score;
failed beams are cleared or removed so stale state cannot win;
identifiers and scoring configuration capture behavior-defining settings;
beams continue from the original output, not the response-converted output;
auxiliary scorers are telemetry and never silently steer the attack.
First PR (request-local grammar). This is a bit more than a field validated like temperature:
Today OpenAIResponseTarget reads the grammar tool's name into self._grammar_name in __init__ and uses it to interpret responses. With a request-local grammar, that name has to travel with the request. Nothing per-request may live on the instance, otherwise concurrent beams on one shared target corrupt each other.
RequestGenerationConfig is currently shaped around numeric sampling parameters (ParameterResolution is typed as floats). A grammar is an output-shape constraint, closer to how JSON-schema response formats already travel in message metadata. Either home can work; pick one and say why in the PR description, and keep the evidence model coherent.
A target that cannot honor the grammar must raise. Never adapt by dropping it; beam search without the grammar is a different attack.
Define what happens when the target was constructed with a grammar tool and a request also supplies one (today the target rejects multiple grammar tools).
A request-local grammar changes behavior without changing the target's identifier, so the attack's identifier has to capture it.
Keep the first PR to the mechanism plus tests, including one that runs two different grammars concurrently on the same target instance.
Activity
adrian-gavrila commentedon Aug 4, 2025
Sounds interesting, I'd like to give this a shot if others aren't already working on this issue.
romanlutz commentedon Aug 5, 2025
Please do! Nobody is on it to the best of my knowledge.
romanlutz commentedon Sep 22, 2026
Prior implementation work:
BeamSearchAttackon top of that support.I'm marking this not ready yet and unassigning Adrian Gavrila (@adrian-gavrila). Before another implementation starts, we need to resolve the design and correctness issues identified in #1346, especially:
store=False;The original issue describes random appended-token search, while #1346 explored grammar-constrained beam search. We should also settle which technique and contract we actually want before reopening this for implementation.
juliosuas commentedon Nov 5, 2026
I'd like to take the next pass on this now that #1346 is closed and the issue is marked not ready yet.
Before coding, I propose settling the open design/correctness points from Roman Lutz (@romanlutz)'s note (2026-09-22), then confirming which contract we want:
store=False; prefer a beam that reaches the objective over auxiliary-score-only selection; clear/remove failed beams so stale state cannot win; identifiers/scoring config capture behavior-defining settings; continue from original output (not response-converted); auxiliary scorers as telemetry only.I'll post a short design note covering those points for maintainer feedback before any implementation PR. Please assign me for the design thread if that works.
romanlutz commentedon Nov 5, 2026
The main issue that made me block the previous PR was recreating the target over and over again. However, #3506 may allow us to reuse a single target with different params per request. I suggest waiting until that's merged. Julio César Suástegui (@juliosuas)
juliosuas commentedon Nov 11, 2026
Roman Lutz (@romanlutz) #3506 is merged, so I'd like to pick this up. One gap first:
RequestGenerationConfigonly carriestemperature, while #1346 re-created the target to swap each beam's Lark grammar tool. Plan: a small first PR adding a request-local grammar option toRequestGenerationConfig(Responses target only, capability-gated, validated like temperature), thenBeamSearchAttackon one shared target with isolated conversation IDs per beam, caller settings likestore=Falsepreserved, beams that reach the objective winning over the auxiliary score, and failed beams pruned. Does extending the config that way work for you, or would you prefer a different mechanism? If it works, could you assign me?romanlutz commentedon Nov 20, 2026
Julio César Suástegui (@juliosuas) yes, this works, and with #3506 merged the reason for not ready yet is gone. Assigning you and removing the label. A few things to pin down so the two PRs land cleanly.
Technique. Let's go with grammar-constrained beam search, as explored in #1346. The random appended-token search from the original description stays out of scope here.
Acceptance criteria for
BeamSearchAttack. Your Nov 11 plan lists four of the seven points from my Sept 22 note; all seven apply:store=False;First PR (request-local grammar). This is a bit more than a field validated like temperature:
OpenAIResponseTargetreads the grammar tool's name intoself._grammar_namein__init__and uses it to interpret responses. With a request-local grammar, that name has to travel with the request. Nothing per-request may live on the instance, otherwise concurrent beams on one shared target corrupt each other.RequestGenerationConfigis currently shaped around numeric sampling parameters (ParameterResolutionis typed as floats). A grammar is an output-shape constraint, closer to how JSON-schema response formats already travel in message metadata. Either home can work; pick one and say why in the PR description, and keep the evidence model coherent.Keep the first PR to the mechanism plus tests, including one that runs two different grammars concurrently on the same target instance.