mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
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:
@@ -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")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user