Skip to content

fix(tui): provide fallback response when subagent produces no text output#294

Merged
echobt merged 1 commit intomasterfrom
fix/subagent-empty-response-fallback
Jan 27, 2026
Merged

fix(tui): provide fallback response when subagent produces no text output#294
echobt merged 1 commit intomasterfrom
fix/subagent-empty-response-fallback

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Jan 27, 2026

Problem

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 scenarios where:

  1. The research subagent executed tools (TodoWrite, LS, Read)
  2. A Batch call might have failed
  3. No textual report was included in the response - the agent sent nothing back

The user observed this as: "L'agent n'a rien envoyé" (The agent sent nothing)

Root Cause

In spawn_subagent(), the final_content variable captures the LLM's text output from each iteration. However:

  • If the LLM only produces tool calls without any text explanation (Delta events)
  • The iteration_content remains empty
  • final_content is only updated when !iteration_content.is_empty()
  • Result: The output contains only metadata, not a meaningful response

Solution

Added a fallback mechanism that provides meaningful feedback when final_content is empty:

  1. If no tools AND no content: Returns a message indicating potential issues with the task/model
  2. If tools executed but no content: Returns a summary with:
    • Number of tool calls
    • Success/failure counts
    • The original task description

This ensures the parent agent always receives actionable feedback from subagents.

Changes

  • Modified spawn_subagent() in cortex-tui/src/runner/event_loop.rs
  • Added effective_content variable with fallback logic
  • The output now uses effective_content instead of final_content

Testing

  • cargo check -p cortex-tui passes
  • cargo test -p cortex-tui event_loop passes (9 passed, 7 ignored)
  • Unrelated test failures (file icons) are pre-existing

…tput

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.
@echobt echobt merged commit 039cd2a into master Jan 27, 2026
2 of 3 checks passed
@echobt echobt deleted the fix/subagent-empty-response-fallback branch January 27, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants