Token compression · Codex
Fewer tokens for Codex.
Same context.
Edgee compresses what Codex sends to OpenAI on every request: tool result trimming, task-aware tool surface reduction, and output brevity. Fewer input tokens, lower cost per session — semantically lossless on code tasks.
Drop-in CLI · works with your existing API keys and plans · no code changes
tokens the model sees
9,210
of 18,420 uncompressed
−50%
reduction
Toggle a technique to see the bill move.
Install−49.5%
fresh input tokens
1.14M → 574K per session
−35.6%
total session cost
$4.00 → $2.58
100%
semantically lossless
on code-oriented tasks
0
code changes
drop-in CLI wrapper
Measured on a real Codex session in our public compression benchmark. Your mileage may vary by workload.
Where Codex's tokens actually go
Token compression splits in two. Layer 1 (Input) handles what enters the context window — tool results, tool definitions, codebase context — roughly 99% of token volume in a coding session. Layer 2 (Output)trims the model's response: small in volume, high in ROI. Edgee compresses all three before the request hits OpenAI.
edgee gateway
- tool_result_trimmingImproved
- tool_surface_reductionNew
- output_brevityNew
Three techniques, applied per request
Each technique is a named config flag you toggle independently. Percentages below are each technique's share of one illustrative session — measured in tokens, never summed across techniques.
Tool result trimming
Improved in V2tool_result_trimming · Layer 1 (Input)
Filters CLI and tool results before they reach the model — boilerplate, pagination markers, ANSI escape sequences, repeated headers, and verbose framing. Inspired by RTK. V2 trims harder while keeping the output semantically intact for code tasks: a 980-token directory listing becomes a dense 340-token one the model reads just as well.
Tool surface reduction
New in V2tool_surface_reduction · Layer 1 (Input)
Agents send the model the union of every MCP server, skill, and tool definition on every request — even when 95% are irrelevant to the task. V2 runs a small, fast classifier that scores each tool against the classified task, then strips or down-scopes the rest before the request hits the model. Your IDE still exposes everything; the model only sees a curated, task-relevant subset. No more toggling MCP servers on and off by hand like a mixing desk.
Output brevity
New in V2output_brevity · Layer 2 (Output)
Reduces the verbosity of model responses without losing technical content — same answer, fewer tokens. Pick the level (light, medium, hard) to trade aggressiveness against tone. Small in token volume, high in ROI: output is the ~1% of traffic you pay the most for.
Compression is designed to be semantically lossless for code-oriented tasks. We validated this on a suite of coding benchmarks where the compressed prompt produced outputs statistically indistinguishable from the original. Extremely short prompts compress less, tool-use schemas are passed through untouched, and when in doubt Edgee skips compression.
Read the Codex documentation
Full setup, config flags, and the compression deep-dive for running Codex through Edgee.
Drop-in install
Install the CLI once and launch Codex through it. Compression runs per session — your AGENTS.md and MCP servers stay put.
# Install the Edgee CLI
curl -fsSL https://edgee.ai/install.sh | bash
# Launch Codex through the compression proxy
edgee launch codexFull CLI guide in the Edgee documentation.
Measure every saved token
Compression without observability is flying blind. Every Codex session reports its compression ratio, tokens saved, and estimated cost avoided — at developer and team level.
Technical FAQ
Fewer tokens for Codex. Launch it through Edgee.
−49.5% fresh input tokens and −35.6% session cost in our published benchmark ($4.00 → $2.58), semantically lossless on code tasks.
Works with your existing API keys and plans. No lock-in.