From 02159bc40ec4f62fdc586a8b2d19dc9cf5bac8cd Mon Sep 17 00:00:00 2001 From: jh-block Date: Tue, 10 Mar 2026 17:44:54 +0100 Subject: [PATCH] fix: serialize non-string text_result in pure ref path text_result can be a JSON object/number/boolean, not just a string. Serialize non-string values to text instead of dropping them. Co-Authored-By: Claude Opus 4.6 --- .../src/agents/platform_extensions/code_execution.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/goose/src/agents/platform_extensions/code_execution.rs b/crates/goose/src/agents/platform_extensions/code_execution.rs index a36b1f37f8..fb7738ee14 100644 --- a/crates/goose/src/agents/platform_extensions/code_execution.rs +++ b/crates/goose/src/agents/platform_extensions/code_execution.rs @@ -318,10 +318,13 @@ impl CodeExecutionClient { .output .as_ref() .and_then(|v| v.get("text_result")) - .and_then(|v| v.as_str()) - .filter(|s| !s.is_empty()) - .unwrap_or("Tool returned rich content."); - let mut contents = vec![Content::text(text_fallback)]; + .and_then(|v| match v { + Value::String(s) if !s.is_empty() => Some(s.clone()), + Value::Null | Value::String(_) => None, + other => Some(other.to_string()), + }) + .unwrap_or_else(|| "Tool returned rich content.".to_string()); + let mut contents = vec![Content::text(&text_fallback)]; contents.extend(rich_contents); Ok(contents) } else {