Repository navigation
FEAT: Let the registry copy LiteLLM and Claude targets - #4584
Open
Adrian Gavrila (adrian-gavrila) wants to merge 1 commit into
Open
Adrian Gavrila (adrian-gavrila) wants to merge 1 commit into
Adrian Gavrila (adrian-gavrila) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 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
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
The target registry can now copy
LiteLLMChatTarget,ClaudeChatTargetandLiteLLMDecisionTarget, 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 addtoolsormax_tool_rounds(a target takes tools only through its constructor) don't work with them.LiteLLMChatTargetopts in the wayOpenAITargetdoes (FEAT: Adding Temporary Instance Creation from the Registry #3030). Its constructor, and each subclass's, records its inputs, andget_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.OpenAITarget, it doesn't merge inidentifier.params. A LiteLLM identifier stores tool definitions rather thanToolobjects and dropsexecute_tools=True, so a copy built from it would lose its tools.model_name,endpoint,api_key,headersorextra_body_parameters(COPY_LOCKED_PARAMETER_NAMES).model_nameis locked because its provider prefix chooses where requests, and the key, go.extra_body_parameterssetstemperature, because that value would override the copy's own temperature.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_KEYandLITELLM_ENDPOINT(ANTHROPIC_API_KEYfor 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.