Add ollama filter to strip ANSI spinners and keep only final text output
#624 aperta il 16 mar 2026
Metriche repository
- Star
- (48.085 star)
- Metriche merge PR
- (Merge medio 11g 1h) (45 PR mergiate in 30 g)
Descrizione
Problem
When running ollama run <model> "prompt" via SSH or in a terminal, the raw output contains hundreds of ANSI escape sequences (spinners ⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏, cursor control [?25l, [?2026h, [K, etc.) before the actual text response.
This is extremely token-wasteful when consumed by an LLM agent — a simple 2-sentence refusal from a model generates ~15KB+ of raw terminal noise vs ~200 bytes of actual content.
Proposed solution
Add an ollama filter (TOML-based or built-in) that:
- Strips all ANSI escape sequences and spinner characters
- Keeps only the final generated text output
- Optionally shows model name and basic stats (tokens/s, duration) in compact form
Example
# Before (raw, ~15KB of ANSI noise)
ollama run phi4:14b "Hello"
# After (rtk filtered, ~50 bytes)
rtk ollama run phi4:14b "Hello"
# → Hello! How can I help you today?
Context
Discovered while running safety audits on local LLMs via SSH — the ANSI overhead from ollama's streaming UI makes LLM-agent consumption impractical without filtering.