Add ollama filter to strip ANSI spinners and keep only final text output
#624 aberto em 16 de mar. de 2026
Métricas do repositório
- Stars
- (48.085 stars)
- Métricas de merge de PR
- (Mesclagem média 11d 1h) (45 fundiu PRs em 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.