Skip to content

[BUG] REPL renderer opens empty RESPONDING/REASONING section for whitespace-only tokens #68

Description

@galuszkm

Checks

  • I have updated to the latest version of strands-compose
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

strands-compose Version

0.9.0

strands-agents Version

1.47.0

Python Version

3.13

Operating System

Any

Installation Method

uv

Relevant YAML Config

N/A

Steps to Reproduce

Run REPL with AnsiRenderer

Expected Behavior

Empty events like token are not printed

Actual Behavior

Empty messages are not printed out.
In this case ── agent — RESPONDING ── separator is also not emitted!

Additional Context

AnsiRenderer._handle_token calls _ensure_mode(..., "responding") before inspecting the token text. Some models emit a lone {"text": "\n"} token right before a tool call. This prints an empty ── agent — RESPONDING ── separator with no content under it, which is confusing in multi-agent runs (looks like the sub-agent "said nothing").

Possible Solution

Skip the mode switch (and output) for whitespace-only tokens that arrive before any real content, for both _handle_token and _handle_reasoning. Once content is already streaming for that agent, whitespace tokens still
pass through so multi-line formatting is preserved.

text = event.data.get("text", "")
already = self._mode == "responding" and self._active_agent == event.agent_name
if not already and not text.strip():
   return

Related Issues

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions