Add ollama filter to strip ANSI spinners and keep only final text output
#624 opened on Mar 16, 2026
Repository metrics
- Stars
- (48,085 stars)
- PR merge metrics
- (Avg merge 11d 1h) (45 merged PRs in 30d)
Description
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.