Repository navigation
fix(renderers): keep concurrent agent output in one block per agent - #85
Merged
Merged
Conversation
- Track render state per agent so a neighbour's tokens cannot split a block - Hand the terminal to a mid-stream agent so it never buffers invisibly - Refuse the terminal to an agent with outstanding tool calls - Reset state on flush so a reused renderer reprints headers
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.
Description
AnsiRendererkept one set of stream fields, assuming a single writer. strands runs a turn's tool calls concurrently, so agents delegated together interleaved their events and flipped the(agent, mode)pair every few tokens - a headerper chunk, both responses shredded.
State is now per agent: one holds the terminal and streams live, the rest buffer into contiguous blocks.
On release the terminal goes to a mid-stream agent, and an agent awaiting tool results cannot take it.
Otherwise a streaming sub-agent stays invisible, or its block lands after the answer that consumes it.
Also fixes
flush()resetting only_in_stream, which dropped theRESPONDINGheader from turn two onward insca dev.Known tradeoff: a delegator's
TOOL USEline can print after the sub-agent block it started, printing it live would split that agent's block.Related Issues
N/A
Type of Change
YAML / API Impact
None. No schema change,
AnsiRenderer.__init__signature unchanged, new state private. Rendering behaviour only.Testing
uv run just check(lint + type check)uv run just testfor overall testingexamples/still workChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.