Fix sub-agent stalling after first tool call#542
Draft
szmania wants to merge 3 commits into
Draft
Conversation
Co-authored-by: cecli (openai/gemini_cli_local/gemini-2.5-pro)
added 2 commits
May 30, 2026 18:55
Co-authored-by: cecli (openai/gemini_cli_local/gemini-2.5-pro)
Author
|
that seems to have fixed the issue |
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
This PR fixes the sub-agent stalling issue that occurred after the first tool call. It also addresses a TUI rendering issue with tool call arguments and updates the
/spawn-agentand/switch-agentcommands to no longer show completion notifications.Changes Made
1.
cecli/coders/base_coder.py— Refactored_run_parallel,output_task, andinput_task_run_parallel: Thewith_messagepath now routes throughoutput_task(preproc, single_run=True)instead of callingrun_one()directly. This unifies lifecycle management so that single-message execution uses the same task infrastructure as the interactive loop. The main loop was also restructured to useasyncio.wait(return_when=FIRST_COMPLETED)instead ofFIRST_EXCEPTION, with explicit handling ofSwitchCoderSignaland proper task cancellation/cleanup in thefinallyblock.output_task: Added asingle_runparameter. WhenTrue, the loop breaks after one iteration, allowingwith_messagecalls to complete without stalling. The method was also simplified — it now directly creates and awaits agenerate_taskrather than pollingcmd_running_eventand managing spinner state.input_task: The docstring was moved to the correct position (it was previously placed after thefinallyblock of_run_parallel).2.
cecli/commands/spawn_agent.py— Suppress completion notificationAdded
show_completion_notification = Falseto theSpawnAgentCommandclass, preventing unnecessary completion notifications when spawning agents.3.
cecli/commands/switch_agent.py— Suppress completion notificationAdded
show_completion_notification = Falseto theSwitchAgentCommandclass, preventing unnecessary completion notifications when switching agents.4.
cecli/tools/utils/output.py— Simplified tool argument renderingUpdated
tool_body_unwrappedto combine argument keys and values into a single output line (f"{key}: {value}") instead of sending them as separate output calls. This ensures proper association between keys and values in the TUI output.5.
cecli/tui/widgets/output.py— Robust argument parsing regexReplaced the argument parsing regex in
add_tool_callfromre.split(r"(^\S+:)", clean_line, maxsplit=1)tore.match(r"(\S+?):\s*(.*)", clean_line, re.DOTALL). The new pattern correctly handles whitespace and multiline values, eliminating rendering artifacts like the▆character.6.
cecli/tui/app.py— Refactored input routing logicRestructured
_on_input_submittedto clearly separate primary agent and sub-agent input routing paths. The logic now:agent_service.sub_agents.get(foreground_coder.uuid)with explicit handling for idle vs. busy sub-agentsinput_queuewhen idle, or adds to conversation when busyTextualInputOutput._per_coder_queues7.
tests/coders/test_pr542_subagent_fixes.py— New test fileAdded tests covering:
with_message(single-run mode) returnspartial_response_contentoutput_task(single_run=True)breaks after one iterationDiff
Testing
tests/coders/test_pr542_subagent_fixes.pycovers sub-agent single and multi-tool-call scenarios.Notes
All changes are backward compatible and do not affect existing functionality.