Repository navigation
MAINT: Document TargetSendContext as a supported send hook - #4825
Open
Adrian Gavrila (adrian-gavrila) wants to merge 2 commits into
Open
Adrian Gavrila (adrian-gavrila) wants to merge 2 commits into
Adrian Gavrila (adrian-gavrila) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Three existing TargetSendContext imports still violate check-public-imports after the export change, leaving CI failing until they use the public import path.
1 open issue
What changed in this PR
Makes TargetSendContext a supported public hook for callers that manage conversation history outside PyRIT memory, without changing send behavior.
Changes:
- Exports
TargetSendContextthrough the public target package. - Documents history selection and send lifecycle semantics.
- Adds a test for caller-supplied history without memory persistence.
| File | Description |
|---|---|
| tests/unit/prompt_target/target/test_prompt_target.py | Tests caller-owned history and no persistence. |
| pyrit/prompt_target/common/target_send_context.py | Documents the supported context contract. |
| pyrit/prompt_target/common/prompt_target.py | Updates send-context parameter documentation. |
| pyrit/prompt_target/__init__.py | Adds the public lazy export. |
| pyrit/prompt_normalizer/prompt_normalizer.py | Uses the public import and updates documentation. |
| doc/code/targets/11_message_normalizer.py | Removes the protocol’s internal-only description. |
| doc/code/targets/11_message_normalizer.ipynb | Mirrors the documentation wording change. |
| doc/code/targets/0_prompt_targets.md | Describes the supported history-selection hook. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
3051ceaffd14a9a7be6e820ce0c563e7a2d7ad36↑
check_public_importsis clean across all tracked files, fixing the failedpre-commitjob.↑ The prompt_target, prompt_normalizer, message_send_service, request tracing, and lazy-import tests pass (603), and the changed modules import cleanly in any order.
↑ All CI checks pass on this head.
Description
A caller that keeps a conversation outside PyRIT memory can pass
send_contexttoPromptTarget.send_prompt_asyncto choose the history a send uses, butTargetSendContextwas internal and its contract wasn't written down. This makes it a supported hook. The Co-PyRIT Agent pane, in a follow-up PR, keeps its conversations in their own tables and sends them this way.TargetSendContextfrompyrit.prompt_target.select_historyreturns a new list the target appends the request to, andtarget_invocation_counttells the normalizer whether a failed send raises or is saved.PromptTarget,PromptNormalizer, and the targets docs.