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
Investigate the best way to integrate, e.g., as an attack, and propose a high-level plan here. Then, maintainers will provide feedback and help with questions during the implementation phase.
Describe alternatives you've considered, if relevant
Looks like endpoints and the corresponding APIs don't provide logprobs anymore nowadays so I think we can pretty much close this. Wdyt Dan Jones (@donebydan)?
Actually, I found a couple models that still do provide logprobs according to the documentation so maybe still worth doing? We would need someone to investigate a bit on this.
Roman Lutz (@romanlutz) — taking up the investigation request. Quick survey of logprob exposure across mainstream APIs and open-model serving as of today, plus the relevant PyRIT integration points.
Logprob availability (2026)
Provider
Logprobs?
Notes
OpenAI Chat Completions
Yes
logprobs: true + top_logprobs (1–20) on standard chat models
Anthropic Messages API
No
No logprobs parameter; usage only carries token counts (docs)
Google Gemini generateContent
No
No logprobs / responseLogprobs parameter in the current API reference
The technique requires logprob feedback for suffix optimization, so it's no longer universal — but coverage is still meaningful: works against OpenAI's main chat models and against any open model served via vLLM/TGI (locally hosted Llama, Qwen, Mistral, etc. — exactly the targets red-teamers most need to evaluate). It's a partial-coverage attack now, not an all-targets attack.
Relevant PyRIT integration points
A few things I noticed reading the current code:
PromptChatTargetis deprecated in v0.14.0 in favor ofPromptTarget+TargetConfigurationcapabilities (perpyrit/prompt_target/common/prompt_chat_target.py). New work should target thePromptTargetinterface.
Neitheropenai_chat_target.pynoropenai_completion_target.pycurrently passeslogprobs=Trueor processes logprob arrays — target-side opt-in would be needed.
MessagePiece.prompt_metadatais typeddict[str, Union[str, int]]— too restrictive for logprob arrays. Integration would need either a new field onMessagePiece(e.g.,response_logprobs), or a separate carrier model.
One question before going further
Given the partial coverage, is the team open to landing this as an attack class that's explicit about target compatibility — checks for a supports_logprobs capability on the target and raises clearly when not supported — rather than requiring universal support?
If yes, I'd be happy to put up a small spike: minimal target-side opt-in (return_logprobs on OpenAIChatTarget), the MessagePiece extension to carry the data, and a stub attack that consumes it. ~200–300 LOC, additive, easy to review — with credit to Dan Jones (@donebydan)'s [DRAFT] PR #537 where applicable. The Andriushchenko adaptive search itself would be a follow-up once the plumbing is in place.
If the team would rather close this as "not viable enough to warrant the plumbing," also a clean answer — happy to file the closing rationale as a comment for future readers.
Implement the adaptive jailbreaking attack from Andriushchenko et al. 2024 (arXiv:2404.02151, tml-epfl/llm-adaptive-attacks) as a PyRIT single-turn attack strategy. Gate it on a new TargetCapabilities flag that advertises logprob support, so the attack cleanly skips targets that do not expose token-level probabilities (Anthropic, Gemini) and runs against the ones that do (OpenAI Chat Completions with logprobs=True, vLLM, TGI, Together, Fireworks, OpenRouter).
Why
The technique searches over token-level insertions and suffix completions, ranking candidate jailbreak prompts by the target model's logprob assigned to a chosen affirmative continuation. It is the canonical "white-box-ish via logprobs" attack and complements the gradient-based GCG already in pyrit/auxiliary_attacks/gcg/ (GCG needs full white-box; adaptive attacks need only the top-N logprobs that hosted APIs expose). PyRIT users running broad red-team sweeps can include this against any provider that exposes logprobs, without needing local weights.
This issue was on the verge of being closed in 2025-12 when logprobs were thought to be uniformly retired, but my prior investigation in this thread confirmed they are still available on OpenAI Chat Completions, vLLM, TGI, Together, Fireworks, and OpenRouter as of 2026-05. Targeting the subset of capable endpoints via TargetCapabilities makes the issue tractable today.
Proposed architecture
Three small additions, each with clear seams.
1. New capability flag
In pyrit/prompt_target/common/target_capabilities.py, add to CapabilityName:
LOGPROBS="supports_logprobs"
OpenAIChatTarget advertises it (and respects the new logprobs=True, top_logprobs=N request params). Other targets default to absent. The attack uses the standard TargetCapabilities.requires(...) check, so it raises a clear error against an incompatible target.
2. Logprob carrier on the response
The attack needs per-token logprobs from the assistant message. Today nothing in PyRIT carries them. Two viable options for the design discussion (open question below), but the proposal is to add a typed logprobs: Optional[list[TokenLogprob]] field on MessagePiece where TokenLogprob is a small dataclass holding the token string, its logprob, and the top-N alternatives. prompt_metadata is currently typed dict[str, str | int | float] which is too narrow.
3. Attack strategy
New file pyrit/executor/attack/single_turn/adaptive_jailbreak.py containing AdaptiveJailbreakAttack(SingleTurnAttackStrategy). Modeled on the size and shape of skeleton_key.py (185 lines) and flip_attack.py (107 lines), not the larger orchestrators. Constructor accepts objective_target, the search budget (max_iterations), the affirmative continuation template, an optional adversarial-suffix seed, and a stopping criterion. The strategy registers CapabilityName.LOGPROBS as a required capability so PyRIT's existing target-compatibility check enforces it.
Scope: variants in v1 vs deferred
The paper has three main components. Proposed split:
In v1 (this PR): Random search over token insertions, with logprob-driven candidate ranking. This is the technique's core and produces the headline numbers in the paper.
In v1 (this PR): Adversarial suffix optimization, paired with the affirmative-continuation template. Same scoring path as variant 1.
Deferred to a follow-on issue/PR: Self-transfer (cross-model prompt reuse). It adds another orchestrator-level wiring (carrying a successful prompt across targets) and is independently testable; keeping it out of v1 keeps the PR focused.
Where do logprobs live on the response. Proposal above: a new typed MessagePiece.logprobs field with a TokenLogprob dataclass. Alternative: relax prompt_metadata to allow nested lists and put logprobs there. The typed field is cleaner but is a wider change. Which would you prefer?
Capability semantics.LOGPROBS advertises "this target can return logprobs if asked." Should we also encode the top_logprobs cap (OpenAI is 20, some are lower)? Easiest is a separate max_top_logprobs: int = 0 field on the capability descriptor that is only meaningful when LOGPROBS is set.
Unsupported-capability behavior. Default to RAISE so a user pointing the attack at Anthropic gets a clear error immediately, rather than silently running a degraded version. Confirm?
GCG sibling placement. GCG lives under pyrit/auxiliary_attacks/, separate from the modern pyrit/executor/attack/ tree. Adaptive jailbreaking is a closer fit for executor/attack/single_turn/ because it works against hosted models without local weights. Confirm that is the right home.
Test fixtures. Real logprob captures from a hosted endpoint cost API calls and are not reproducible in CI. Plan: mock the chat target with deterministic logprob arrays, plus a small offline fixture file with a recorded response shape so the parser path is exercised against real data once.
Implementation plan
This PR (v1): capability flag, OpenAIChatTarget logprob plumbing, MessagePiece carrier, AdaptiveJailbreakAttack with random-search and suffix-optimization variants, unit tests with mocked logprobs, one notebook in doc/code/executor/attack/ showing usage against OpenAIChatTarget pointed at OpenAI or a vLLM-serving endpoint.
Follow-on PR (separate issue): self-transfer variant. Adds an orchestrator step that carries a successful jailbreak prompt across multiple AdaptiveJailbreakAttack runs against different targets.
Out of scope: logprob plumbing on non-OpenAI hosted targets (Together, Fireworks, OpenRouter, vLLM HTTP). They use the same OpenAI-compatible interface, so they inherit OpenAIChatTarget's logprob support transparently, but I will not write per-provider integration tests in this PR.
References
Andriushchenko, Croce, Flammarion, Jailbreaking Leading Safety-Aligned LLMs with Simple Adaptive Attacks, arXiv:2404.02151 (2024), reference implementation at https://github.com/tml-epfl/llm-adaptive-attacks
Prior thread investigation in this issue (logprob availability sweep across providers, 2026-05-24)
Bumping this. Happy to start coding once you can weigh in on the design questions above, especially Q1 (where logprobs live on the response) and Q3 (RAISE vs ADAPT for unsupported targets). If a different direction works better, also fine to redirect.
Sorry for the slow reply Imran Ahamed (@immu4989) we've been flooded with issues and PRs 😆 The overall plan makes sense. Answers below, with one caveat: the proposal is from June and the codebase has moved quite a bit since (including a change merged just now that affects Q1/Q2), so expect some drift from the file paths you referenced.
Q1 (where logprobs live): Since you wrote this, #3506 landed, which added runtime generation configuration. Please follow that pattern rather than adding a new field to MessagePiece:
Request side: add logprobs/top_logprobs fields to RequestGenerationConfig (pyrit/models/target/request_generation_config.py), mapped to the new capability via FIELD_CAPABILITIES the same way temperature maps to CapabilityName.TEMPERATURE.
Response side: a small typed pydantic model (your TokenLogprob idea) serialized into prompt_metadata under its own key, following the RequestGenerationInfo precedent. prompt_metadata is dict[str, Any] now, so no schema change is needed, and the typed model keeps it from becoming a loose dict.
Q2 (encoding the top-N cap): No — that varies a lot by provider/model and would go stale quickly. Keep the capability a boolean and let the provider's own error surface if a request asks for more than the endpoint supports.
Q3 (unsupported behavior): Yes, RAISE. Logprobs can't be adapted around, and non-adaptable capabilities always raise in the current design (CapabilityHandlingPolicy), so this is consistent.
Q4 (placement):pyrit/auxiliary_attacks/ is gone; GCG now lives under pyrit/executor/promptgen/gcg, and the Fuzzer is under promptgen as well. This attack is the same shape as both — an iterative search loop that generates candidate prompts, queries the target, and scores the candidates (here by logprob of the affirmative continuation) — so executor/promptgen is the right home, not executor/attack/single_turn. The optimized prompt can then be sent/validated via PromptSendingAttack like we do for GCG suffixes.
Q5 (tests): Yes — unit tests with mocked logprob payloads plus the recorded response fixture sounds right. We also typically have integration tests for real targets and end-to-end tests for full scenarios, so plan on at least an integration test against a real logprob-capable endpoint.
Activity
donebydan commentedon Sep 16, 2024
I'd be keen to explore this Open Issue! 🙏
[-]Add adaptive jailbreaking[/-][+]FEAT Add adaptive jailbreaking[/+]romanlutz commentedon Dec 8, 2025
Looks like endpoints and the corresponding APIs don't provide logprobs anymore nowadays so I think we can pretty much close this. Wdyt Dan Jones (@donebydan)?
donebydan commentedon Dec 8, 2025
Happy to close. I don't have permission to do so - could you? 🙏
romanlutz commentedon Dec 11, 2025
Actually, I found a couple models that still do provide logprobs according to the documentation so maybe still worth doing? We would need someone to investigate a bit on this.
immu4989 commentedon May 24, 2026
Roman Lutz (@romanlutz) — taking up the investigation request. Quick survey of logprob exposure across mainstream APIs and open-model serving as of today, plus the relevant PyRIT integration points.
Logprob availability (2026)
Implication for the Andriushchenko-style attack
The technique requires logprob feedback for suffix optimization, so it's no longer universal — but coverage is still meaningful: works against OpenAI's main chat models and against any open model served via vLLM/TGI (locally hosted Llama, Qwen, Mistral, etc. — exactly the targets red-teamers most need to evaluate). It's a partial-coverage attack now, not an all-targets attack.
Relevant PyRIT integration points
A few things I noticed reading the current code:
PromptChatTargetis deprecated in v0.14.0 in favor ofPromptTarget+TargetConfigurationcapabilities (perpyrit/prompt_target/common/prompt_chat_target.py). New work should target thePromptTargetinterface.openai_chat_target.pynoropenai_completion_target.pycurrently passeslogprobs=Trueor processes logprob arrays — target-side opt-in would be needed.MessagePiece.prompt_metadatais typeddict[str, Union[str, int]]— too restrictive for logprob arrays. Integration would need either a new field onMessagePiece(e.g.,response_logprobs), or a separate carrier model.One question before going further
Given the partial coverage, is the team open to landing this as an attack class that's explicit about target compatibility — checks for a
supports_logprobscapability on the target and raises clearly when not supported — rather than requiring universal support?If yes, I'd be happy to put up a small spike: minimal target-side opt-in (
return_logprobsonOpenAIChatTarget), theMessagePieceextension to carry the data, and a stub attack that consumes it. ~200–300 LOC, additive, easy to review — with credit to Dan Jones (@donebydan)'s [DRAFT] PR #537 where applicable. The Andriushchenko adaptive search itself would be a follow-up once the plumbing is in place.If the team would rather close this as "not viable enough to warrant the plumbing," also a clean answer — happy to file the closing rationale as a comment for future readers.
romanlutz commentedon Jun 3, 2026
We have TargetCapabilities now so this would just be one more! I can assign the item to you.
romanlutz commentedon Jun 3, 2026
Actually Imran Ahamed (@immu4989) has the first right to pick it up I suppose 🙂 I think it's still relevant for targets that expose the logprobs.
immu4989 commentedon Jun 3, 2026
Thanks Roman Lutz (@romanlutz), I will work on it.
@sajisanchu1913-source appreciate the courtesy.
immu4989 commentedon Jun 7, 2026
What this proposes
Implement the adaptive jailbreaking attack from Andriushchenko et al. 2024 (arXiv:2404.02151, tml-epfl/llm-adaptive-attacks) as a PyRIT single-turn attack strategy. Gate it on a new
TargetCapabilitiesflag that advertises logprob support, so the attack cleanly skips targets that do not expose token-level probabilities (Anthropic, Gemini) and runs against the ones that do (OpenAI Chat Completions withlogprobs=True, vLLM, TGI, Together, Fireworks, OpenRouter).Why
The technique searches over token-level insertions and suffix completions, ranking candidate jailbreak prompts by the target model's logprob assigned to a chosen affirmative continuation. It is the canonical "white-box-ish via logprobs" attack and complements the gradient-based GCG already in
pyrit/auxiliary_attacks/gcg/(GCG needs full white-box; adaptive attacks need only the top-N logprobs that hosted APIs expose). PyRIT users running broad red-team sweeps can include this against any provider that exposes logprobs, without needing local weights.This issue was on the verge of being closed in 2025-12 when logprobs were thought to be uniformly retired, but my prior investigation in this thread confirmed they are still available on OpenAI Chat Completions, vLLM, TGI, Together, Fireworks, and OpenRouter as of 2026-05. Targeting the subset of capable endpoints via
TargetCapabilitiesmakes the issue tractable today.Proposed architecture
Three small additions, each with clear seams.
1. New capability flag
In
pyrit/prompt_target/common/target_capabilities.py, add toCapabilityName:OpenAIChatTargetadvertises it (and respects the newlogprobs=True, top_logprobs=Nrequest params). Other targets default to absent. The attack uses the standardTargetCapabilities.requires(...)check, so it raises a clear error against an incompatible target.2. Logprob carrier on the response
The attack needs per-token logprobs from the assistant message. Today nothing in PyRIT carries them. Two viable options for the design discussion (open question below), but the proposal is to add a typed
logprobs: Optional[list[TokenLogprob]]field onMessagePiecewhereTokenLogprobis a small dataclass holding the token string, its logprob, and the top-N alternatives.prompt_metadatais currently typeddict[str, str | int | float]which is too narrow.3. Attack strategy
New file
pyrit/executor/attack/single_turn/adaptive_jailbreak.pycontainingAdaptiveJailbreakAttack(SingleTurnAttackStrategy). Modeled on the size and shape ofskeleton_key.py(185 lines) andflip_attack.py(107 lines), not the larger orchestrators. Constructor acceptsobjective_target, the search budget (max_iterations), the affirmative continuation template, an optional adversarial-suffix seed, and a stopping criterion. The strategy registersCapabilityName.LOGPROBSas a required capability so PyRIT's existing target-compatibility check enforces it.Scope: variants in v1 vs deferred
The paper has three main components. Proposed split:
Open design questions
Need Roman Lutz (@romanlutz) steer before coding:
MessagePiece.logprobsfield with aTokenLogprobdataclass. Alternative: relaxprompt_metadatato allow nested lists and put logprobs there. The typed field is cleaner but is a wider change. Which would you prefer?LOGPROBSadvertises "this target can return logprobs if asked." Should we also encode thetop_logprobscap (OpenAI is 20, some are lower)? Easiest is a separatemax_top_logprobs: int = 0field on the capability descriptor that is only meaningful whenLOGPROBSis set.RAISEso a user pointing the attack at Anthropic gets a clear error immediately, rather than silently running a degraded version. Confirm?pyrit/auxiliary_attacks/, separate from the modernpyrit/executor/attack/tree. Adaptive jailbreaking is a closer fit forexecutor/attack/single_turn/because it works against hosted models without local weights. Confirm that is the right home.Implementation plan
OpenAIChatTargetlogprob plumbing,MessagePiececarrier,AdaptiveJailbreakAttackwith random-search and suffix-optimization variants, unit tests with mocked logprobs, one notebook indoc/code/executor/attack/showing usage againstOpenAIChatTargetpointed at OpenAI or a vLLM-serving endpoint.AdaptiveJailbreakAttackruns against different targets.OpenAIChatTarget's logprob support transparently, but I will not write per-provider integration tests in this PR.References
immu4989 commentedon Jun 26, 2026
Bumping this. Happy to start coding once you can weigh in on the design questions above, especially Q1 (where logprobs live on the response) and Q3 (RAISE vs ADAPT for unsupported targets). If a different direction works better, also fine to redirect.
romanlutz commentedon Nov 11, 2026
Sorry for the slow reply Imran Ahamed (@immu4989) we've been flooded with issues and PRs 😆 The overall plan makes sense. Answers below, with one caveat: the proposal is from June and the codebase has moved quite a bit since (including a change merged just now that affects Q1/Q2), so expect some drift from the file paths you referenced.
Q1 (where logprobs live): Since you wrote this, #3506 landed, which added runtime generation configuration. Please follow that pattern rather than adding a new field to
MessagePiece:logprobs/top_logprobsfields toRequestGenerationConfig(pyrit/models/target/request_generation_config.py), mapped to the new capability viaFIELD_CAPABILITIESthe same waytemperaturemaps toCapabilityName.TEMPERATURE.TokenLogprobidea) serialized intoprompt_metadataunder its own key, following theRequestGenerationInfoprecedent.prompt_metadataisdict[str, Any]now, so no schema change is needed, and the typed model keeps it from becoming a loose dict.Q2 (encoding the top-N cap): No — that varies a lot by provider/model and would go stale quickly. Keep the capability a boolean and let the provider's own error surface if a request asks for more than the endpoint supports.
Q3 (unsupported behavior): Yes, RAISE. Logprobs can't be adapted around, and non-adaptable capabilities always raise in the current design (
CapabilityHandlingPolicy), so this is consistent.Q4 (placement):
pyrit/auxiliary_attacks/is gone; GCG now lives underpyrit/executor/promptgen/gcg, and the Fuzzer is underpromptgenas well. This attack is the same shape as both — an iterative search loop that generates candidate prompts, queries the target, and scores the candidates (here by logprob of the affirmative continuation) — soexecutor/promptgenis the right home, notexecutor/attack/single_turn. The optimized prompt can then be sent/validated viaPromptSendingAttacklike we do for GCG suffixes.Q5 (tests): Yes — unit tests with mocked logprob payloads plus the recorded response fixture sounds right. We also typically have integration tests for real targets and end-to-end tests for full scenarios, so plan on at least an integration test against a real logprob-capable endpoint.
Looking forward to the PR!