Skip to content

FEAT: Let the registry copy LiteLLM and Claude targets - #4584

Open
Adrian Gavrila (adrian-gavrila) wants to merge 1 commit into
microsoft:mainfrom
adrian-gavrila:adrian-gavrila-litellm-target-copies
Open

Adrian Gavrila (adrian-gavrila) wants to merge 1 commit into
microsoft:mainfrom
adrian-gavrila:adrian-gavrila-litellm-target-copies

Conversation

@adrian-gavrila

Copy link
Copy Markdown
Contributor

Description

The target registry can now copy LiteLLMChatTarget, ClaudeChatTarget and LiteLLMDecisionTarget, as it copies OpenAI targets. Today it refuses them ("LiteLLMChatTarget does not support reconstruction"), so per-chat temperature copies, attack temperature bindings, and copies that add tools or max_tool_rounds (a target takes tools only through its constructor) don't work with them.

  • LiteLLMChatTarget opts in the way OpenAITarget does (FEAT: Adding Temporary Instance Creation from the Registry #3030). Its constructor, and each subclass's, records its inputs, and get_reconstruction_parameters() returns them along with the values the source resolved: model name, endpoint, API key or token provider, underlying model, and configuration. A copy never reads this server's environment for a value its source already resolved, and keeps capabilities applied after construction.
  • Unlike OpenAITarget, it doesn't merge in identifier.params. A LiteLLM identifier stores tool definitions rather than Tool objects and drops execute_tools=True, so a copy built from it would lose its tools.
  • A copy built from API input can't change model_name, endpoint, api_key, headers or extra_body_parameters (COPY_LOCKED_PARAMETER_NAMES). model_name is locked because its provider prefix chooses where requests, and the key, go.
  • As with OpenAI targets, a copy shares its source's request pacing. A copy is refused when extra_body_parameters sets temperature, because that value would override the copy's own temperature.
  • The backend README and the registry guide list the new locked settings.

Known limitation: if a source's key or endpoint resolved to nothing (LiteLLM then reads the provider's own variables), a copy reads LITELLM_API_KEY and LITELLM_ENDPOINT (ANTHROPIC_API_KEY for Claude) again, as a newly built target would.

Related: #4492 detects capabilities on the live target instead of on a copy. This PR complements it by covering the features above, which still build copies.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 15:16

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 block approval of the target-copying changes.

No open issues 🎉

What changed in this PR

Extends PyRIT’s registry copying support to LiteLLMChatTarget, ClaudeChatTarget, and LiteLLMDecisionTarget, enabling temporary target variants without changing registered instances.

Changes:

  • Captures constructor inputs and preserves resolved authentication, configuration, and tools while sharing request pacing and credential status.
  • Locks connection and routing settings for API-created copies and rejects conflicting temperature settings.
  • Adds reconstruction and backend tests and documents the new copy restrictions.
File Description
tests/​unit/​prompt_target/​target/​test_litellm_chat_target.py Tests reconstruction, preserved settings, tools, and temperature conflicts.
tests/​unit/​backend/​test_temporary_components.py Tests private copies, shared pacing, and connection-setting restrictions.
pyrit/​prompt_target/​litellm_chat_target.py Adds constructor capture, reconstruction support, and copy protections.
pyrit/​backend/​README.md Documents locked LiteLLM settings for API copies.
doc/​code/​registry/​0_registry.md Updates registry guidance with LiteLLM copy restrictions.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants