Inspiration

AI coding agents are powerful, but they’re expensive to run. Multi‑turn conversations quickly inflate context windows — generating code, running it, fixing errors, iterating again — and every turn resends the entire history. That drives LLM API costs up fast. To make agentic coding viable, we needed a way to compress conversational context without losing meaning. That’s where Paritok comes in, and paritok‑cli proves the approach works in a real agent loop.

What it does

paritok‑cli is a cost‑optimized interactive coding agent CLI. It gives you a terminal chat interface where you can ask the agent to write code, read files, edit them, run commands, and iterate.
Every message — user or model — is compressed before being sent, typically saving 60–70% tokens per turn.

Flow:

  1. User enters a prompt
  2. CLI compresses it via the Paritok cloud API
  3. Sends compressed context to a local Paritok proxy
  4. Proxy forwards to NVIDIA’s API
  5. Model streams back text or tool calls (read, write, edit, grep, bash, etc.)
  6. CLI executes the tools and returns results to the agent

How we built it

The CLI is written in Go 1.26.5.
The TUI is built using the Charmbracelet ecosystem:

  • Bubbletea for the Elm‑style architecture
  • Bubbles for text input and viewport components
  • Lipgloss for styling and layout
  • Glamour for markdown rendering with syntax‑highlighted code blocks

The CLI framework uses Cobra + Pflags.
Tool‑calling is powered by mark3labs/mcp‑go, an implementation of the Model Context Protocol.

Compression pipeline:
Client → Paritok API → compressed JSON → local proxy → NVIDIA API (openai/gpt‑oss‑20b).
The proxy handles authentication and forwards the compressed payload.

Challenges

  • Streaming + tool calls: NVIDIA streams tokens, but tool calls arrive as deltas. We had to reconstruct tool call arguments across multiple SSE chunks without breaking the streaming UX.
  • Agent loop state management: Coordinating Bubbletea’s message pump with goroutine‑based streaming required careful channel design to avoid deadlocks and stale UI updates.
  • Compression fidelity: Early compression dropped important instructions. Tuning Paritok parameters to hit ~70% compression while preserving semantics took extensive testing.

Accomplishments

  • ~70% compression in real agent loops, not synthetic benchmarks.
  • A fully functional opencode‑class agent in Go: seven tools (read, write, edit, remove, glob, grep, bash), multi‑turn tool‑calling, streaming, markdown rendering — all in a single binary with no runtime dependencies.
  • Paritok credit + badge integration: visible in the README and a live token‑savings counter inside the TUI.

What we learned

  • Token economics matter: Agentic loops multiply token usage by 5–10× compared to single prompts. Compression isn’t optional — it’s the difference between affordable and unusable.
  • Go TUI architecture: Building a responsive terminal app with concurrent streaming taught us how Bubbletea and goroutines interact under load.

What’s next

  • Session persistence: SQLite‑backed conversation history.
  • Subagents & plugins: Parallel task execution and extensible tool sets.
  • LSP integration: Hover, go‑to‑definition, diagnostics via the agent.
  • Server mode: Run paritok‑cli as a long‑lived daemon for editors and CI pipelines.

Built With

  • bubbles
  • bubbletea
  • cobra
  • glamour
  • go
  • lipgloss
  • pflags
Share this project:

Updates