From e87037575b09949fe9fbfb2052edf1549428f4c0 Mon Sep 17 00:00:00 2001 From: fre$h Date: Mon, 23 Feb 2026 16:13:34 -0500 Subject: [PATCH] fix: detect truncated LLM responses in apps extension (#7354) Signed-off-by: Cody <166262726+kowirth@users.noreply.github.com> Signed-off-by: Cody <251773092+fresh3nough@users.noreply.github.com> Co-authored-by: Cody <166262726+kowirth@users.noreply.github.com> Co-authored-by: Cody <251773092+fresh3nough@users.noreply.github.com> --- .../goose/src/agents/platform_extensions/apps.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/goose/src/agents/platform_extensions/apps.rs b/crates/goose/src/agents/platform_extensions/apps.rs index 1bba33cf10..f1d8fed305 100644 --- a/crates/goose/src/agents/platform_extensions/apps.rs +++ b/crates/goose/src/agents/platform_extensions/apps.rs @@ -293,11 +293,17 @@ impl AppsManagerClient { let mut model_config = provider.get_model_config(); model_config.max_tokens = Some(16384); - let (response, _usage) = provider + let (response, usage) = provider .complete(&model_config, session_id, &system_prompt, &messages, &tools) .await .map_err(|e| format!("LLM call failed: {}", e))?; + if let (Some(output), Some(max)) = (usage.usage.output_tokens, model_config.max_tokens) { + if output >= max { + return Err("App content generation was truncated because the response hit the token limit. Try simplifying your app description.".to_string()); + } + } + extract_tool_response(&response, "create_app_content") } @@ -327,11 +333,17 @@ impl AppsManagerClient { let mut model_config = provider.get_model_config(); model_config.max_tokens = Some(16384); - let (response, _usage) = provider + let (response, usage) = provider .complete(&model_config, session_id, &system_prompt, &messages, &tools) .await .map_err(|e| format!("LLM call failed: {}", e))?; + if let (Some(output), Some(max)) = (usage.usage.output_tokens, model_config.max_tokens) { + if output >= max { + return Err("App content update was truncated because the response hit the token limit. Try requesting smaller changes.".to_string()); + } + } + extract_tool_response(&response, "update_app_content") }