Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion cortex-tui/src/runner/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,41 @@ impl EventLoop {
tool_calls_executed.join("\n")
};

// CRITICAL: Handle case where LLM produced no text output
// This can happen when the LLM only makes tool calls without explanation
// In this case, provide a meaningful summary so the parent agent gets feedback
let effective_content = if final_content.trim().is_empty() {
if tool_calls_executed.is_empty() {
// No tools and no content - something went wrong
format!(
"The {} subagent completed but produced no output or tool calls. \
This may indicate an issue with the task or model response.",
subagent_type
)
} else {
// Tools executed but no text explanation - provide summary
let success_count = tool_calls_executed
.iter()
.filter(|s| s.contains("success"))
.count();
let error_count = tool_calls_executed
.iter()
.filter(|s| s.contains("error") || s.contains("failed"))
.count();
format!(
"The {} subagent completed {} tool call(s) ({} successful, {} failed) \
but did not provide a textual summary. Task: {}",
subagent_type,
tool_calls_executed.len(),
success_count,
error_count,
description
)
}
} else {
final_content
};

let output = format!(
"{}\n\n\
Tools executed:\n{}\n\n\
Expand All @@ -852,7 +887,7 @@ impl EventLoop {
agent_type: {}\n\
description: {}\n\
</task_metadata>",
final_content, tools_summary, id, subagent_type, description
effective_content, tools_summary, id, subagent_type, description
);

let duration = started_at.elapsed();
Expand Down
Loading