fix: sub-agent returning empty output when final LLM response has no text#64
Merged
yishuiliunian merged 1 commit intomainfrom Apr 2, 2026
Merged
fix: sub-agent returning empty output when final LLM response has no text#64yishuiliunian merged 1 commit intomainfrom
yishuiliunian merged 1 commit intomainfrom
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
output_len=0) to parents when the final LLM response contained no visible textexecute_turn_innerusedresult.assistant_text(empty) instead oflast_text(accumulated from prior iterations)Changes
crates/loopal-runtime/src/agent_loop/turn_exec.rs— align the no-tool-calls exit path to uselast_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 preservedTest plan
bazel test //crates/loopal-runtime:loopal-runtime_testpasses (including new regression test)