Skip to content

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

@aryanputta

Description

@aryanputta

Two bugs in src/rosa/rosa.py:

Bug 1: _print_usage renders rich markup as literal text

The method uses plain print() with rich markup:

print(f"[bold]Prompt Tokens:[/bold] {cb.prompt_tokens}")

Standard print() does not interpret rich markup. With show_token_usage=True, the output literally prints [bold]Prompt Tokens:[/bold] 100 instead of formatted text. It should use rich.console.Console.print() to render the markup.

Bug 2: astream accumulates tokens with a spurious leading space

final_output += f" {content}"

This prepends a space before every token. When final_output is used as the fallback (no chain_output from on_chain_end), the recorded string starts with a leading space and has an extra space between every token. It should be: final_output += content

I am working on a patch for both issues and will open a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions