FEAT: Runtime capability discovery for prompt targets#1699
Queued
hannahwestra25 wants to merge 33 commits into
Queued
FEAT: Runtime capability discovery for prompt targets#1699hannahwestra25 wants to merge 33 commits into
hannahwestra25 wants to merge 33 commits into
Conversation
…lities in verify_target_async
romanlutz
reviewed
May 8, 2026
jsong468
reviewed
May 11, 2026
jsong468
reviewed
May 11, 2026
…ra/query_target_capabilities
jsong468
reviewed
May 11, 2026
jsong468
reviewed
May 11, 2026
jsong468
reviewed
May 11, 2026
jsong468
reviewed
May 11, 2026
jsong468
reviewed
May 11, 2026
…ra/query_target_capabilities
…ra/query_target_capabilities
romanlutz
reviewed
May 12, 2026
jsong468
approved these changes
May 12, 2026
Contributor
jsong468
left a comment
There was a problem hiding this comment.
Great work! see Roman's question about how this feature gets used
rlundeen2
reviewed
May 13, 2026
…ra/query_target_capabilities
…ra/query_target_capabilities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds query_target_capabilities.py, which probes a
PromptTargetat runtime to determine what the underlying endpoint actually accepts. Useful for custom OpenAI-compatible endpoints, gateways that strip features, or any deployment where declared capabilities may not match real behavior.New public API (exported from
pyrit.prompt_target)discover_target_capabilities_async— probes boolean capability flags (SYSTEM_PROMPT,MULTI_MESSAGE_PIECES,MULTI_TURN,JSON_OUTPUT,JSON_SCHEMA).discover_target_modalities_async— probes which input-modality combinations are accepted.discover_target_async— runs both and returns a populatedTargetCapabilities.Each probe is bounded by
per_probe_timeout_s(default 30s) and retried once on transient errors. The target's configuration is temporarily replaced with a permissive one so_validate_requestdoesn't short-circuit. Probe-written memory rows are tagged withprompt_metadata["capability_probe"] == "1".Caveats (in docstrings)
Tests & docs
Also fix a test_common_net_utility.py which was mocking get_httpx_client with a bare MagicMock, which did not match the real async context-manager flow used by make_request_and_raise_if_error_async. That let the mocked response behave like raise_for_status was async, so production’s correct synchronous call triggered the coroutine was never awaited warning. The fix was to mock the async context manager explicitly, keep client.request as an AsyncMock, and return a real httpx.Response so raise_for_status stays synchronous like the real API.