Skip to content

Commit 039cd2a

Browse files
echobtfactorydroid
andauthored
fix(tui): provide fallback response when subagent produces no text output (#294)
When a subagent (Task tool) executes tool calls but the LLM produces no textual response (only tool calls), the parent agent previously received an empty response with just metadata. This caused confusion as the subagent appeared to have done nothing. This fix adds a meaningful fallback message when final_content is empty: - If no tools were executed AND no content: indicates potential issue - If tools were executed but no content: provides a summary with success/failure counts and the original task description This ensures the parent agent always receives actionable feedback from subagents, preventing silent failures where tools ran but no report was generated. Fixes the issue where research subagents could complete tool execution (TodoWrite, LS, Read, Batch) but return nothing to the orchestrating agent. Co-authored-by: Droid Agent <droid@factory.ai>
1 parent 736aeb2 commit 039cd2a

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

cortex-tui/src/runner/event_loop.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,41 @@ impl EventLoop {
844844
tool_calls_executed.join("\n")
845845
};
846846

847+
// CRITICAL: Handle case where LLM produced no text output
848+
// This can happen when the LLM only makes tool calls without explanation
849+
// In this case, provide a meaningful summary so the parent agent gets feedback
850+
let effective_content = if final_content.trim().is_empty() {
851+
if tool_calls_executed.is_empty() {
852+
// No tools and no content - something went wrong
853+
format!(
854+
"The {} subagent completed but produced no output or tool calls. \
855+
This may indicate an issue with the task or model response.",
856+
subagent_type
857+
)
858+
} else {
859+
// Tools executed but no text explanation - provide summary
860+
let success_count = tool_calls_executed
861+
.iter()
862+
.filter(|s| s.contains("success"))
863+
.count();
864+
let error_count = tool_calls_executed
865+
.iter()
866+
.filter(|s| s.contains("error") || s.contains("failed"))
867+
.count();
868+
format!(
869+
"The {} subagent completed {} tool call(s) ({} successful, {} failed) \
870+
but did not provide a textual summary. Task: {}",
871+
subagent_type,
872+
tool_calls_executed.len(),
873+
success_count,
874+
error_count,
875+
description
876+
)
877+
}
878+
} else {
879+
final_content
880+
};
881+
847882
let output = format!(
848883
"{}\n\n\
849884
Tools executed:\n{}\n\n\
@@ -852,7 +887,7 @@ impl EventLoop {
852887
agent_type: {}\n\
853888
description: {}\n\
854889
</task_metadata>",
855-
final_content, tools_summary, id, subagent_type, description
890+
effective_content, tools_summary, id, subagent_type, description
856891
);
857892

858893
let duration = started_at.elapsed();

0 commit comments

Comments
 (0)