Include node_repl screenshots in Guardian v2 reviews (#39227)

## Why

`node_repl` screenshots are nested tool results and do not appear in the parent
conversation history, so Guardian v2 transcript image collection could miss
them.

## What changed

- Allow Guardian v2 to enable bounded, thread-scoped `node_repl` image capture
  when transcript images are configured.
- Add retained `node_repl` screenshots to review requests when transcript
  sources include tool outputs, while deduplicating images and keeping them out
  of the parent turn input.

## Testing

- Add an integration test covering screenshot capture without the synchronous
  Guardian transcript feature flags and verifying that screenshots stay out of
  the parent request.

GitOrigin-RevId: 5f70c5f2e80389aa8b2a286c3b7f9b1104865486
This commit is contained in:
jif authored and copyberry committed 2026-08-18 16:38:52 +00:00
1 parent e7e13c68e2
commit 9b9b614b02
6 files changed
+150 -5

No files matched your search

+11 -2
View File
@@ -250,9 +250,15 @@ impl CoreToolRuntime for McpHandler {
return;
};
let evidence_mode = node_repl_review_evidence_mode(&invocation.turn);
let image_capture_enabled = invocation
.session
.services
.thread_extension_data
.get::<NodeReplReviewEvidence>()
.is_some_and(|evidence| evidence.image_capture_enabled());
if self.tool_info.server_name != "node_repl"
|| !result.success_for_logging()
|| evidence_mode == NodeReplReviewEvidenceMode::Disabled
|| evidence_mode == NodeReplReviewEvidenceMode::Disabled && !image_capture_enabled
{
return;
}
@@ -283,7 +289,10 @@ impl CoreToolRuntime for McpHandler {
text: text.to_string(),
text_elements: Vec::new(),
}),
Some("image") if evidence_mode == NodeReplReviewEvidenceMode::Multimodal => {
Some("image")
if evidence_mode == NodeReplReviewEvidenceMode::Multimodal
|| image_capture_enabled =>
{
let payload = item.get("data").and_then(Value::as_str)?;
let mime_type = item.get("mimeType").and_then(Value::as_str)?;
if payload.is_empty()