Skip to content

FIX: Detect capabilities on the live target so every target type works - #4492

Merged
Richard Lundeen (richlundeen) merged 6 commits into
microsoft:mainfrom
richlundeen:richlundeen-rebuild-decision-promptshield
Dec 3, 2026
Merged

Richard Lundeen (richlundeen) merged 6 commits into
microsoft:mainfrom
richlundeen:richlundeen-rebuild-decision-promptshield

Conversation

@richlundeen

@richlundeen Richard Lundeen (richlundeen) commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

The GUI's capability detection failed for LiteLLMDecisionTarget (microsoft_decision) and PromptShieldTarget (azure_content_safety) with "does not support reconstruction". Detection probed a private rebuilt copy of each target so that its temporary probe settings could not leak into other requests, so only target types that support rebuilding could be checked. Detection now probes the live target, with the probe settings scoped to its own task, so every target type can be checked.

  • PromptTarget._probe_scope sets a configuration and tool settings for the current task only. The configuration uses the existing task-local configuration scope (the same mechanism as capabilities_scope, without its masking). The tool settings that probes switch off (_extra_body_parameters, _execute_tools, _suppress_tools) become task-local attributes, so a concurrent send on the same target keeps the target's own values. No code that reads these settings changes.
  • Discovery no longer modifies the target, and TargetService no longer builds and releases a copy. Probes use the target's own client, rate limit, and credential status.
  • Discovery sends a target's capability_probe_text (default "test") for text probes. The decision target overrides it with a valid state/questions request in DecisionScorer's format and is not treated as a chat adapter, so detection sends one decision request and keeps its declared capabilities. Prompt Shield passes the plain-text control request and keeps its declarations.

Related: #4486 also edits target_service.py and discover_target_capabilities.py, in different hunks.

LiteLLMDecisionTarget and PromptShieldTarget now supply reconstruction
parameters, reusing the source's resolved key or token provider, with
connection settings copy-locked. Discovery sends a target-provided probe
text so the decision target's control request is a valid decision request,
and the decision target no longer runs chat probes. Detection rejects
targets that can't be rebuilt with a clear message before probing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 21, 2026 05:31

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.

🟢 Approval recommended

No active review issues remain for the target capability-detection changes.

No open issues 🎉

What changed in this PR

Enables GUI capability detection for LiteLLMDecisionTarget and PromptShieldTarget by making them safely rebuildable as private probe copies.

Changes:

  • Adds reconstruction that preserves resolved credentials and locks connection settings.
  • Uses target-specific probe text and preserves declared capabilities for non-chat adapters.
  • Rejects unrebuildable targets before probing and shares request pacing through the base target class.
File Description
tests/​unit/​prompt_target/​target/​test_prompt_shield_target.py Tests reconstruction, credential reuse, and connection locks.
tests/​unit/​prompt_target/​target/​test_litellm_decision_target.py Tests reconstructed requests and connection locks.
tests/​unit/​backend/​test_target_detection.py Covers detection for both targets and unsupported-target errors.
pyrit/​prompt_target/​prompt_shield_target.py Adds credential-preserving reconstruction and connection locks.
pyrit/​prompt_target/​openai/​openai_target.py Removes pacing-sharing logic now handled by the base class.
pyrit/​prompt_target/​litellm_decision_target.py Adds reconstruction, connection locks, and a valid probe payload.
pyrit/​prompt_target/​common/​prompt_target.py Defines default probe text and shares reconstruction pacing.
pyrit/​prompt_target/​common/​discover_target_capabilities.py Uses custom probe text and excludes decision targets from chat probes.
pyrit/​backend/​services/​target_service.py Checks reconstruction support before detection begins.

Review effort: Balanced

Capability detection built a private copy of each target so its probe
settings could not leak into other requests. That only worked for target
types that support rebuilding. Probes now run on the live target inside a
task-local scope: the permissive configuration uses the existing
configuration contextvar, and the tool settings probes switch off are
task-local attributes, so concurrent sends keep the target's own values.

This removes the Decision and Prompt Shield reconstruction support and the
not-rebuildable check; any target type can now be detected. Decision keeps
its valid capability probe text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@richlundeen Richard Lundeen (richlundeen) changed the title FIX: Rebuild decision and Prompt Shield targets for capability detection FIX: Detect capabilities on the live target so every target type works Nov 21, 2026
@hannahwestra25 hannahwestra25 self-assigned this Nov 30, 2026

@hannahwestra25 hannahwestra25 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Automated review of ed28617. The inclusion check approves this change: probing the live target with task-local probe settings covers every target type with less code than making each type rebuildable. Two inline comments need a change before merge.

Update the backend README for live-target detection. pyrit/backend/README.md (lines 77, 79 and 86, outside this diff) still says detection probes a private copy and that targets without reconstruction return 400. Detection now probes the live target, and a 400 comes only from unsupported composite targets. Update these lines to match.

The branch also conflicts with main in discover_target_capabilities.py. Note that main (#4595) now also turns off _execute_tools and _suppress_tools for OpenAIChatTarget during probes, so _probe_tool_settings must keep that after the merge.

Resolve discover_target_capabilities.py: keep the task-local probe scope and have
_probe_tool_settings reuse main's without_tool_settings, turning off tool
execution and tools for OpenAIChatTarget, OpenAIResponseTarget and
LiteLLMChatTarget without changing the shared target.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…pport

Reset every capability and modality probe conversation on the live target after discovery, including failure and cancellation, and replace the LiteLLMDecisionTarget class check with a declared _SUPPORTS_CHAT_CAPABILITY_PROBES flag. Update the backend README for live-target detection.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@richlundeen

Copy link
Copy Markdown
Contributor Author

review:6114529989

Both are fixed. The backend README now says detection probes the registered target with task-local probe settings and releases its probe conversations, that only an unsupported composite target returns 400, and that round-robin children are checked the same way. The merge with main keeps the task-local _probe_scope. For OpenAIChatTarget, OpenAIResponseTarget and LiteLLMChatTarget, _probe_tool_settings now sets the tool-free body plus _execute_tools=False and _suppress_tools=True, all task-local.

Verified on published commit 2bc3700db35990f7e0fd840f6945488f314b6357.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated review completed. No blocking concerns remain. This review records source coverage; merging is handled separately.

@hannahwestra25 hannahwestra25 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

added a few minor comments / potential improvements but overall looks good

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ailures

Replace the class list in discovery with a PromptTarget._capability_probe_attributes hook,
overridden by the Chat Completions tool loop and OpenAIResponseTarget. Log each failed
probe-conversation reset at debug and emit one summary warning.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@richlundeen
Richard Lundeen (richlundeen) added this pull request to the merge queue Dec 3, 2026
Merged via the queue into microsoft:main with commit b639387 Dec 3, 2026
72 checks passed
@richlundeen
Richard Lundeen (richlundeen) deleted the richlundeen-rebuild-decision-promptshield branch December 3, 2026 02:14
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