From 3accc29987eb48e73e8f1aeb2e0fe8e705ba1324 Mon Sep 17 00:00:00 2001 From: Droid Agent Date: Tue, 27 Jan 2026 15:29:19 +0000 Subject: [PATCH] fix(tui): provide fallback response when subagent produces no text output 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. --- cortex-tui/src/runner/event_loop.rs | 37 ++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/cortex-tui/src/runner/event_loop.rs b/cortex-tui/src/runner/event_loop.rs index 49527c0f..14f21a7a 100644 --- a/cortex-tui/src/runner/event_loop.rs +++ b/cortex-tui/src/runner/event_loop.rs @@ -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\ @@ -852,7 +887,7 @@ impl EventLoop { agent_type: {}\n\ description: {}\n\ ", - final_content, tools_summary, id, subagent_type, description + effective_content, tools_summary, id, subagent_type, description ); let duration = started_at.elapsed();