Skip to content

FEAT expand TargetCapabilities#1464

Open
hannahwestra25 wants to merge 7 commits intoAzure:mainfrom
hannahwestra25:hawestra/target_capabilities_p1
Open

FEAT expand TargetCapabilities#1464
hannahwestra25 wants to merge 7 commits intoAzure:mainfrom
hannahwestra25:hawestra/target_capabilities_p1

Conversation

@hannahwestra25
Copy link
Contributor

Description

This PR builds on #1433 to expand the TargetCapabilities class and consolidate the logic in Targets to use the TargetCapabilities class rather than misc variables. This is the first of at least 2 more PRs which will allow users to query target capabilities and add validation to attacks, converters, scorers, etc which have requirements for targets.

TargetCapabilities dataclass — expanded fields:

  • supports_multi_turn (existing)
  • supports_multi_message_pieces — rejects messages with >1 piece when False
  • supports_json_response — whether JSON response format is supported
  • input_modalities — allowed input data types (text, image_path, audio_path, …)
  • output_modalities — produced output data types

Added assert_satisfies() to validate one TargetCapabilities against another. This will be useful later when validating whether a target satisfies the requirements of an attack / scorer / converter


PromptTarget._validate_request() — converted from abstract to a concrete base
implementation that auto-enforces capabilities:

  • Rejects multi-piece messages when supports_multi_message_pieces=False
  • Rejects unsupported converted_value_data_type against input_modalities
  • Rejects follow-up turns when supports_multi_turn=False

All ad-hoc inline validation in individual targets was deleted.
Renamed constructor param capabilitiescustom_capabilities.
Added is_json_response_supported() delegating to capabilities.supports_json_response.


Per-target _DEFAULT_CAPABILITIES declarations added/updated:

Target Notable capabilities
OpenAIChatTarget multi-turn, JSON, text/image/audio in, text/audio out
OpenAICompletionTarget supports_multi_message_pieces=False
OpenAITTSTarget no multi-turn, single-piece, audio out
OpenAIImageTarget no multi-turn, text/image in, image out
OpenAIVideoTarget no multi-turn, text/image in, video out
RealtimeTarget multi-turn, single-piece, text/audio in+out
PlaywrightTarget multi-turn, text/image in
PlaywrightCopilotTarget multi-turn, text/image in+out
WebSocketCopilotTarget multi-turn, text/image in
PromptShieldTarget single-piece
HuggingFaceChatTarget multi-turn, single-piece
CrucibleTarget single-piece

Tests and Documentation

  • New test_target_capabilities.py covering modality declarations, assert_satisfies, and per-target defaults
  • test_supports_multi_turn.py extended with constructor override tests
  • All pytest.raises error message patterns updated to the new unified format
  • Mock memory calls updated: get_conversationget_message_pieces
  • patch_central_database fixture added to HTTP target tests that were missing it

# Whether the target natively supports JSON output (e.g., via a "json" response format).
supports_json_response: bool = False

# The input modalities supported by the target (e.g., "text", "image").
Copy link
Contributor

@rlundeen2 rlundeen2 Mar 13, 2026

Choose a reason for hiding this comment

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

We also likely want editable_history; This let's us set the system history that are not actually responses from the target. We use PromptChatTarget for this currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean targets that inherit from PromptChatTarget have editable history ?

from the actual model. If not provided, `model_name` will be used for the identifier.
Defaults to None.
capabilities (TargetCapabilities, Optional): Override the default capabilities for
custom_capabilities (TargetCapabilities, Optional): Override the default capabilities for
Copy link
Contributor

@rlundeen2 rlundeen2 Mar 13, 2026

Choose a reason for hiding this comment

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

I wonder if we could have a mapping of known default capabilities here, or potentially retrieved from a list in target_capabilites class.

if underlying_model == "gpt-5.1":
  _default = X
elif ...

Copy link
Contributor

Choose a reason for hiding this comment

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

We also talked about a method to discover these which I think will be useful. But the defaults we know could go a long way early on :)

SUPPORTED_DATA_TYPES = {"text", "image_path"}
_DEFAULT_CAPABILITIES: TargetCapabilities = TargetCapabilities(supports_multi_turn=True)
_DEFAULT_CAPABILITIES: TargetCapabilities = TargetCapabilities(
supports_multi_turn=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe only minimal since it's generic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean it only has minimal multi turn support ? as in we should keep the default as false for this one ?

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.

5 participants