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>
This commit is contained in:
fre$h
2026-02-23 16:13:34 -05:00
committed by GitHub
parent 5e5e2917c0
commit e87037575b
@@ -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")
}