Open
Conversation
Add `rtk codex` command that filters OpenAI Codex CLI review output, achieving ~70% token savings by stripping preamble headers, intermediate tool call output, and metadata while preserving the review text. State machine parser (Preamble → UserPrompt → ExecBlock → Body) is designed to be easily extensible for future codex subcommand support. - New src/codex_cmd.rs with run(), filter, and 9 unit tests - Registered in command router (main.rs) and discovery rules - Discovery scoped to codex review
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
rtk codexcommand that filters OpenAI Codex CLIreviewoutput, stripping preamble, intermediate tool calls, and metadata while preserving the actual review text. Achieves ~70% token savings.Partial implementation of #169 — scoped to
codex reviewfor now, with the implementation designed to be easily extensible for full codex support later.What it does
When an LLM agent runs
codex review --base ${branch}, the raw output includes ~30 lines of CLI preamble, echoed user prompt, intermediate exec blocks (diffs, file reads), and the actual review buried at the end.rtk codex review --base ${branch}strips all that and returns only the review text.Before (raw codex review output → LLM context)
After (rtk codex review → LLM context)
Implementation
State machine parser in
src/codex_cmd.rs:mcp startuplinesFiles changed
src/codex_cmd.rsrun(),filter_codex_output()state machine,is_preamble_line(), 9 testssrc/main.rsmod codex_cmd,Commands::Codexvariant, dispatch armsrc/discover/rules.rs^codex\s+review(\s|$)and RtkRule (category: AI, 70% savings)Tests (9)
test_filter_codex_review_output— full review output filteringtest_filter_codex_output_no_exec_blocks— review without tool callstest_filter_alternating_exec_codex_blocks— multiple exec→codex cyclestest_filter_codex_skips_user_prompt— user prompt strippedtest_filter_preserves_blank_lines_in_body— paragraph formatting preservedtest_filter_codex_fallback_to_raw_for_help— help text passthroughtest_filter_codex_fallback_to_raw_for_errors— error passthroughtest_filter_codex_output_empty— empty input handlingtest_token_savings— verifies ≥60% token reductionScope and future work
codex reviewsupport with token-optimized filteringTest plan
cargo fmt --all --checkcargo clippy --all-targets(no new warnings)cargo test codex_cmd::— 9 tests passcargo test discover::— 154 tests passrtk codex review --base ${branch}on real repo, verified filtered output