Skip to content

fix: use Console().print for token usage and remove spurious space in…#76

Open
aryanputta wants to merge 1 commit into
nasa-jpl:mainfrom
aryanputta:fix-rosa-print-and-astream
Open

fix: use Console().print for token usage and remove spurious space in…#76
aryanputta wants to merge 1 commit into
nasa-jpl:mainfrom
aryanputta:fix-rosa-print-and-astream

Conversation

@aryanputta
Copy link
Copy Markdown

@aryanputta aryanputta commented Mar 21, 2026

Fixes #75

Two bugs in src/rosa/rosa.py are fixed in this PR.

Purpose

_print_usage was calling print() with rich markup strings. Plain print() does not interpret rich markup, so show_token_usage=True printed literal bracket tags instead of formatted text. Replaced with Console().print() and added the missing Console import from rich.console.

In astream, the token accumulation read final_output += f" {content}", prepending a space before every token. When no on_chain_end event provides a final output, the fallback string recorded to chat history started with a leading space. Changed to final_output += content.

Proposed Changes

  • [FIX] _print_usage: replaced print() with Console().print() so rich markup renders correctly
  • [ADD] from rich.console import Console
  • [FIX] astream: removed spurious leading space in token accumulation

Issues

Testing

  • Verified _print_usage with show_token_usage=True renders bold labels correctly in terminal
  • Verified astream chat history entries no longer start with a leading space
  • No existing tests broken

… astream

_print_usage called print() with rich markup syntax, which plain print() renders as literal text. Replaced with Console().print() so the markup is actually interpreted. Also added the missing Console import. In astream, final_output += f" {content}" prepended a space before every token. Changed to final_output += content. Fixes nasa-jpl#75.
@areporeporepo areporeporepo mentioned this pull request Apr 5, 2026
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: _print_usage renders rich markup as plain text and astream accumulates tokens with spurious leading spaces

1 participant