Skip to content

fix: sub-agent returning empty output when final LLM response has no text#64

Merged
yishuiliunian merged 1 commit intomainfrom
fix/sub-agent-empty-output
Apr 2, 2026
Merged

fix: sub-agent returning empty output when final LLM response has no text#64
yishuiliunian merged 1 commit intomainfrom
fix/sub-agent-empty-output

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Sub-agents that perform multi-round tool+LLM cycles could return empty output (output_len=0) to parents when the final LLM response contained no visible text
  • Root agent then re-did all the research itself, wasting ~3 minutes of sub-agent work
  • Root cause: the normal exit path in execute_turn_inner used result.assistant_text (empty) instead of last_text (accumulated from prior iterations)

Changes

  • crates/loopal-runtime/src/agent_loop/turn_exec.rs — align the no-tool-calls exit path to use last_text, consistent with all other exit paths (cancel, stream error, max tokens, observer abort)
  • crates/loopal-runtime/tests/agent_loop/turn_completion_edge_test.rs — regression test: tool+text → empty final LLM response → output preserved

Test plan

  • bazel test //crates/loopal-runtime:loopal-runtime_test passes (including new regression test)
  • CI passes

…text

The normal exit path in execute_turn_inner (no tool calls, no special
conditions) returned result.assistant_text from the current LLM call.
When the final LLM response was empty (has_text=false, tool_calls=0),
accumulated last_text from prior iterations was discarded, causing
ephemeral sub-agents to return output_len=0 to their parent.

All other exit paths (cancel, stream error, max tokens, observer abort)
already used last_text. Align the normal path to match, so earlier
meaningful text is preserved when the final response is empty.
@yishuiliunian yishuiliunian merged commit 300002f into main Apr 2, 2026
3 checks passed
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.

1 participant