Cost
Lower AI agent cost: shell output compaction in Navin
August 8, 2026 · 3 min read · Navin team
How git, test, docker and Kubernetes output inflate context - and how Navin compacts it before the model, with no external tool.
intro handled in meta - body only
Every time a coding agent runs git status, pytest, docker compose, or kubectl get pods, the model receives the full output. Those logs are often long and repetitive, and only a fraction helps decide the next step. Context fills up, latency rises, and the bill follows.
Navin automatically compacts that output before it enters the model context. No external proxy, no extra binary: compaction is built into the local exec tool.
Where an agent's tokens come from
An agent request is not limited to your message. Each turn usually includes:
- system instructions and project rules;
- tool schemas;
- session history;
- the latest shell command output.
The first three blocks often repeat across turns and benefit from prompt caching when available. The fourth changes on every command. A verbose npm install or kubectl describe therefore hits both cost and context window directly.
That is why a debug session can consume millions of tokens across a few dozen requests, even when your instructions stay short.
What compaction does
Compaction does not hide errors. It keeps useful signal and drops noise:
- progress bars and ANSI sequences;
- secondary columns in
docker psorkubectl get; - low-value events in a
describe; - long green test blocks when only failures matter;
- Git progress that does not change the next decision.
Navin classifies the command family (git, tests, Kubernetes, installs…), applies a matching filter, then exposes a shorter version to the model. When shrinkage is meaningful, the full log remains under .navin/tool-results/exec/.
Coverage
| Area | Examples | What the model keeps |
|---|---|---|
| Git | status, diff, log, push | Dirty files, useful status |
| Tests | pytest, jest, cargo/go test, playwright | Failures and summary |
| Python | ruff, mypy, pip, uv | Findings or install summary |
| JS / build | eslint, tsc, next, npm install | Errors first |
| Containers | docker, podman | Essential columns, deduped logs |
| Kubernetes | kubectl, oc, helm | Compact tables, quieter describe |
| Infra | terraform, make, gradle | Errors and summary |
| Network | curl, gh | Short bodies or tables |
Wrappers such as bash -lc '…' are resolved so the real command is classified.
Behavior in the workbench
| Situation | Effect |
|---|---|
| Synchronous command | Compaction after the process exits |
| Background command | Compaction when the process completes |
| Terminal while running | Live output unchanged |
You keep a readable terminal; the model receives the compacted result once the command finishes. Product docs: Command output compaction.
Cost impact
| Session type | Typical effect |
|---|---|
| Light chat, little shell | Small |
| Heavy git, tests, docker | Often material on the tool-output share |
| Debug with large logs or Kubernetes | Stronger on that same share |
Compaction does not remove the system prompt, tool schemas, or history. It acts on the most volatile part: command output. For Free quotas versus subscription budgets, see free models and plans.
Alongside other Navin levers
| Lever | Role |
|---|---|
exec compaction | Cuts shell tool noise |
| Prompt caching | Reuses the stable prefix (system, tools) |
| Plan / Mission | Fewer exploratory turns |
| Project Brain | Less re-reading the repo on resume |
HTTP response caching (identical response bodies) is a poor fit for agents: every turn has a different body.
FAQ
Are important errors preserved?
Yes. Filters prioritize failures, findings, and useful status. The raw log stays on disk when compaction applies.
Do I need to enable an option?
No. It is the default exec behavior in Navin.
Are Kubernetes and Docker covered?
Yes, including kubectl, oc, helm, and common docker/podman commands (ps, logs, compose).
Does it replace prompt caching?
No. Caching covers the stable prefix; compaction covers variable outputs.
How do I recover the full output?
From the file referenced in the [compacted…] note under .navin/tool-results/exec/.
Next steps
- Download Navin.
- Open a project in the Code module.
- Let the agent run git, tests, or docker: compaction applies automatically.
Download Navin · Features · Documentation
Try Navin on your machine
Local agent, cross-platform. Code, debug, scrape, leads, security and review - without leaving Navin.