Handle standalone tool outputs as external context (#39791)

## What changed

- Treat standalone `function_call_output` items without a `call_id` as external context, including items injected into new and forked threads, and mark the thread memory mode polluted when `memories.disable_on_external_context` is enabled.
- Include these outputs in guardian transcripts with their namespaced tool name and a placeholder for non-text content.
- Allow image generation to reuse images from standalone and otherwise unpaired function or custom-tool outputs.

## Testing

- Cover injected thread items, external-context detection, guardian transcript rendering, and recent-image selection.

GitOrigin-RevId: ca4e8c16a4b731e1256a5956908d00f785b4feb1
This commit is contained in:
rka-oai authored and copyberry committed 2026-08-20 19:46:29 +00:00
1 parent 43526b8561
commit aead844f64
10 files changed
+170 -49

No files matched your search

+6 -6
View File
@@ -138,10 +138,10 @@ async fn recent_image_fallback_selects_newest_images_in_chronological_order() {
},
ResponseItem::FunctionCallOutput {
id: None,
call_id: Some("orphan-call".to_string()),
name: None,
namespace: None,
output: image_output("orphan"),
call_id: None,
name: Some("notifications".to_string()),
namespace: Some("slack".to_string()),
output: image_output("standalone"),
internal_chat_message_metadata_passthrough: None,
},
];
@@ -151,7 +151,7 @@ async fn recent_image_fallback_selects_newest_images_in_chronological_order() {
&ImagegenArgs {
prompt: "change the lighting".to_string(),
referenced_image_paths: None,
num_last_images_to_include: Some(4),
num_last_images_to_include: Some(5),
},
&history,
&[],
@@ -160,7 +160,7 @@ async fn recent_image_fallback_selects_newest_images_in_chronological_order() {
.expect("history-backed edit request should build"),
ImageRequest::Edit(expected_edit_request(
"change the lighting",
&["user-2", "mcp", "code-mode", "generated"],
&["user-2", "mcp", "code-mode", "generated", "standalone"],
))
);
}