Repository navigation
FEAT: Let complete stored tool messages decide absence - #4362
Richard Lundeen (richlundeen) merged 7 commits into
Conversation
MessageToolCallScorer never returned false, because stored messages miss tools the provider runs itself, response sections PyRIT does not model, and calls a target returns without running. Some targets do store every execution, and can say so. ToolCaptureCoverage in pyrit.models records, on a model response, whether the stored messages show every tool that ran for it, and otherwise which ToolCaptureGap applies: hosted_tool_call, unrecognized_output or calls_not_executed. OpenAIResponseTarget records it on each model response. Function calls it runs itself are captured; any other output section is a gap, and execute_tools=False with pending calls is one. A tool loop that stops early still answers every call with its dispatch status, so its error response records complete coverage. The scorer treats the stored messages as complete only when every outbound request through the scored message has a stored response and every model response recorded complete coverage. Prepended and simulated history are neither. Then a required tool with no matching execution is false, and an exhaustive condition can be true. Otherwise verdicts are unchanged. The identifier gains capture_coverage_version. One existing test changes on purpose: a response-target loop where the model called an unregistered tool is now a failure, not undetermined.
There was a problem hiding this comment.
🟡 Changes recommended
Critical scoring flaws allow incomplete or inherited coverage and unreadable arguments to produce false absence verdicts or incorrectly passing exhaustive checks.
3 open issues
What changed in this PR
Adds tool-execution capture metadata so PyRIT’s message-based scorer can distinguish incomplete evidence from evidence that a required tool did not run.
Changes:
- Introduces coverage models and records coverage gaps in
OpenAIResponseTarget. - Enables absence and exhaustive verdicts when stored evidence is considered complete, and versions the scorer identifier.
- Adds coverage-focused tests and updates the paired documentation without changing its executable examples.
| File | Description |
|---|---|
tests/unit/score/test_message_tool_call_scorer.py |
Adds coverage, target-recording, and scoring cases; updates the unregistered-tool outcome. |
pyrit/score/true_false/message_tool_call_scorer.py |
Checks capture completeness and adds definitive absence and exhaustive verdicts. |
pyrit/prompt_target/openai/openai_response_target.py |
Records coverage and gaps for model responses and tool-loop stops. |
pyrit/models/target/tool_execution_metadata.py |
Defines coverage and gap models with metadata serialization and validation. |
pyrit/models/__init__.py |
Exposes the new models through lazy exports. |
doc/code/scoring/5_tool_call_scorer.py |
Updates documentation comments describing coverage-dependent verdicts. |
doc/code/scoring/5_tool_call_scorer.ipynb |
Mirrors the documentation changes in notebook markdown. |
Review effort: Balanced
A response no longer inherits coverage from the request it answers, and a target drops any coverage a request carries before sending it. A function call whose dispatch result is not in scope now blocks absence verdicts, and an executed call whose stored arguments cannot be read stays undetermined under complete capture.
Main moved the Responses tool loop into the shared run_tool_loop_async, so the complete coverage on a loop stop is now recorded in tool_loop_error, which answers every pending call before it returns, and the unexecuted-calls gap is added on the execute_tools=False path.
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
|
At candidate Verified on published commit |
Richard Lundeen (richlundeen)
left a comment
There was a problem hiding this comment.
Automated review completed. No blocking concerns remain. This review records source coverage; merging is handled separately.
Resolve pyrit/prompt_target/common/prompt_target.py by keeping both request sanitizations: the PR's ToolCaptureCoverage removal and main's ProviderTraceReference clearing. Co-authored-by: Copilot App <[email protected]>

Description
This answers the tool-coverage question for message-side evidence.
MessageToolCallScorernever returned false, because stored messages miss tools the provider runs itself, response sections PyRIT does not model, and calls a target returns without running. Some targets do store every execution, and can say so.ToolCaptureCoverageinpyrit.modelsrecords on a model response whether the stored messages show every tool that ran for it, and otherwise whichToolCaptureGapapplies:hosted_tool_call,unrecognized_outputorcalls_not_executed.OpenAIResponseTargetrecords it on each model response. Function calls it runs itself are captured; any other output section is a gap, andexecute_tools=Falsewith pending calls is one. The shared tool loop answers every call with its dispatch status before it stops early, so its error response records complete coverage.capture_coverage_version.Tests and Documentation
tests/unit/score/test_message_tool_call_scorer.py, covering the model, the target's recording and the scorer's verdicts. 19 mutations, all caught.tymatches main. The same unit suites pass, with the same single environment failure as main.5_tool_call_scorerare updated (markdown only).