Skip to content

FEAT: Let complete stored tool messages decide absence - #4362

Merged
Richard Lundeen (richlundeen) merged 7 commits into
microsoft:mainfrom
WatchTree-19:feat/message-tool-capture
Nov 24, 2026
Merged

Richard Lundeen (richlundeen) merged 7 commits into
microsoft:mainfrom
WatchTree-19:feat/message-tool-capture

Conversation

@WatchTree-19

@WatchTree-19 WatchTree-19 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

This answers the tool-coverage question for message-side evidence. 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. The shared tool loop answers every call with its dispatch status before it stops early, so its error response records complete coverage.
  • The scorer treats 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 count as 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.

Tests and Documentation

  • 57 new tests in 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.
  • ty matches main. The same unit suites pass, with the same single environment failure as main.
  • The "Score tool calls without traces" and "Require that nothing else ran" sections of 5_tool_call_scorer are updated (markdown only).

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.
Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:05

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.

🟡 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.
WatchTree-19 and others added 4 commits November 19, 2026 14:41
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.
@richlundeen

Copy link
Copy Markdown
Contributor

review:5942128667

At candidate d76db015cccc70a34a6b341824df9429b718786c, all three concerns in this review are addressed: coverage no longer propagates from requests or synthetic responses, every in-scope call needs an in-scope dispatch result, and unreadable argument matches remain undetermined. The repaired round-robin fallback also removes a completeness claim after discarding an earlier target attempt. The 445-test affected suite passes at this head.

Verified on published commit d76db015cccc70a34a6b341824df9429b718786c.

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.

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]>
@richlundeen
Richard Lundeen (richlundeen) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into microsoft:main with commit ec6b64f Nov 24, 2026
71 of 72 checks passed
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.

3 participants