From fc26afe4b5e3faac679a6c77b11d36fd41ec4ebd Mon Sep 17 00:00:00 2001 From: jh-block Date: Tue, 10 Mar 2026 17:28:44 +0100 Subject: [PATCH] fix: add text fallback for pure rich content tool results Providers that only serialize text content (OpenAI, Codex, Anthropic) would produce no tool output for the model when execute returns only rich content. Always include a text placeholder so the model sees a valid tool result. Co-Authored-By: Claude Opus 4.6 --- .../src/agents/platform_extensions/code_execution.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/goose/src/agents/platform_extensions/code_execution.rs b/crates/goose/src/agents/platform_extensions/code_execution.rs index 61e1e688c9..f1a62d4ffe 100644 --- a/crates/goose/src/agents/platform_extensions/code_execution.rs +++ b/crates/goose/src/agents/platform_extensions/code_execution.rs @@ -310,7 +310,13 @@ impl CodeExecutionClient { }); if is_pure_ref && !rich_contents.is_empty() { - Ok(rich_contents) + // Always include a text fallback so providers that only serialize + // text content (OpenAI, Codex, Anthropic) still produce a tool result + // for the model. The rich content carries audience metadata and will + // be filtered by downstream audience logic. + let mut contents = vec![Content::text("Tool returned rich content.")]; + contents.extend(rich_contents); + Ok(contents) } else { let return_val = serde_json::to_string_pretty(&output.output) .unwrap_or_else(|_| json!(&output.output).to_string());