Skip to content

v1.6.10 - Fix Duplicate Response Display

Choose a tag to compare

@jwesleye jwesleye released this 31 Dec 20:10
· 86 commits to main since this release

What's Fixed

Critical Bug Fix: Eliminates duplicate agent response display during conversations

The Issue

Agent responses were appearing twice in the terminal:

  1. First as raw text (streaming output)
  2. Then as formatted markdown (final render)

This affected ALL agent responses, causing confusing double-display of every message.

Root Cause

Complex conditional logic in the response rendering code (chat_loop.py:2096-2109) could allow both the streaming print loop AND the final render to execute in certain edge cases, particularly:

  • When rich markdown rendering was enabled
  • During streaming responses
  • With specific configuration combinations

The previous logic relied on nested if/elif conditions that could be bypassed:

if self.use_rich and display_text.strip() and self.console:
    # Rich markdown
    print markdown
elif not self.use_rich and response_text:
    if not first_token_received:
        # Plain text
        print plain text

The Fix

Introduced explicit tracking flag to guarantee single display:

# Track if already printed during streaming
already_printed_streaming = first_token_received and not self.use_rich

# Render final response (only if not already printed)
if not already_printed_streaming:
    if self.use_rich:
        print markdown
    else:
        print plain text

This ensures:
✅ Streaming with rich disabled: prints during stream, skips final render
✅ Streaming with rich enabled: skips stream print, renders markdown once at end
✅ Non-streaming: renders once at end (rich or plain)
✅ All edge cases: explicit flag prevents any double-rendering

Testing

  • All 318 tests passing
  • Verified single display across all combinations:
    • Streaming + rich enabled
    • Streaming + rich disabled
    • Non-streaming + rich enabled
    • Non-streaming + rich disabled

Installation:

pip install --upgrade basic-agent-chat-loop

Verify version:

pip show basic-agent-chat-loop | grep Version
# Should show: Version: 1.6.10

🤖 Generated with Claude Code