Proposal: reduce token usage for common verbose exec_command outputs
Context
First, thank you for building and maintaining Codex.
I read the contribution policy in docs/contributing.md and understand that external code contributions are currently invitation-only.
I still wanted to share a concrete, tested implementation idea because this appears to be a common token-efficiency pain point in real usage.
Proposal
Reduce model token footprint for very common verbose shell outputs in exec_command responses:
- Strip ANSI escape sequences before truncation.
- Add conservative compaction for high-noise commands:
git status(non-porcelain): compact staged / unstaged / untracked summaryls -l/ls -la: compact file-type + filename listing
- Apply compaction only when it produces meaningful size savings; otherwise fallback to existing output.
Why this may help
In interactive coding sessions, git status and ls -la are frequently emitted.
Their default output often has high formatting overhead relative to decision-relevant signal, which increases context consumption.
A conservative compaction layer can preserve useful signal while reducing token pressure.
Ready Implementation (for reference)
I prepared a working patch on my fork with unit tests.
- Branch:
joey/token-compact-common-command-output - Commit:
9379013baf3f2c1c5242806cb9a9df027868c7ba - Fork branch URL: <https://github.com/joeeeeey/codex/tree/joey/token-compact-common-command-output>
- Commit URL: <https://github.com/joeeeeey/codex/commit/9379013baf3f2c1c5242806cb9a9df027868c7ba>
Files changed:
codex-rs/core/src/tools/context.rscodex-rs/core/src/tools/context_tests.rs
What I am asking
If this direction aligns with Codex priorities, could a maintainer advise whether:
- you would prefer this as a feature request only, or
- you would like to invite an external PR for this scope.
I am happy to adjust design details, naming, or test shape based on maintainer feedback.
Thank you for your time.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗