Skip to content

Add RTK Directly Into Codex CLI to Reduce Token Usage 60–90% by Filtering Shell Command Output #19001

Description

@klondikemarlen

What version of Codex CLI is running?

codex-cli 0.122.0

What subscription do you have?

Plus

Which model were you using?

gpt-4.5 medium

What platform is your computer?

Linux 6.17.0-22-generic x86_64 unknown

What terminal emulator and version are you using (if applicable)?

Terminal → https://gitlab.gnome.org/chergert/ptyxis

What issue are you seeing?

Token usage grows rapidly during normal coding sessions because raw shell command output is passed directly into the LLM context. Commands like git status, git diff, ls, cargo test, and docker ps produce verbose, repetitive output — often 60–90% noise from the model's perspective — yet every token counts toward the context limit and API cost. Context fills fast, triggering expensive compaction or hitting limits mid-task.

What steps can reproduce the bug?

  1. Start a Codex CLI session on a mid-sized project.
  2. Run a sequence of typical coding commands: git status, git diff, ls, a test run.
  3. Observe token count (uploaded thread: 019db5ee-d016-74d0-9228-76e5b75fbcc0).
  4. Note how quickly context fills relative to actual useful information exchanged.

What is the expected behavior?

Codex CLI should filter and compress shell command output before adding it to the model context — the same way RTK (Rust Token Killer) works as a CLI proxy today. RTK intercepts output, strips noise, and passes a compact semantic equivalent to the model, saving 60–90% tokens on common operations.

Integration could mean: automatically piping shell tool output through RTK if it is installed, or shipping an equivalent built-in output filter so no separate install is needed.

Additional information

I use RTK today with Codex, Claude Code, and Windsurf — it works well, but it requires a separate manual install and per-tool configuration for each CLI. This is friction that shouldn't exist for something so universally useful. Output compression should be a first-class feature of the CLI itself, not an external addon users have to discover and wire up themselves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contextIssues related to context management (including compaction)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions