Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
fix(wrap): keep Codex RTK guidance global (#1240)
Terminal Chai7c26a54d53aa
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3f0632809..9e0dd5d15 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Bug Fixes* **proxy:** route Codex OAuth image generation and edit requests through the ChatGPT Codex image backend, while preserving OpenAI API-key image passthrough ([#1215](https://github.com/chopratejas/headroom/pull/1215)).+* **wrap (codex):** keep RTK guidance in the global Codex `AGENTS.md` instead of modifying the shared project `AGENTS.md` ([#1235](https://github.com/chopratejas/headroom/issues/1235)).* **proxy:** enable SSO credential resolution in the native Bedrock route via the `aws-config` `sso` feature flag, making the credential chain match what `docs/bedrock.md` already documented ([#999](https://github.com/chopratejas/headroom/pull/999)).* **proxy:** route native Bedrock `/model/{id}/converse` requests to the upstream Converse endpoint instead of the hard-coded `/invoke` action — the non-streaming handler now resolves the action from the inbound path, matching the streaming handler ([#999](https://github.com/chopratejas/headroom/pull/999)).* **proxy:** preserve byte-faithful `/v1/messages` forwarding when Anthropic tool arrays are already canonical, and only canonicalize-and-mutate tool lists when sorting changes ordering ([#1042](https://github.com/chopratejas/headroom/issues/1042)).diff --git a/headroom/cli/wrap.py b/headroom/cli/wrap.pyindex 86d2373c6..4335940de 100644--- a/headroom/cli/wrap.py+++ b/headroom/cli/wrap.py@@ -3675,11 +3675,7 @@ def codex(click.echo(" Setting up rtk for Codex...")rtk_path = _ensure_rtk_binary(verbose=verbose)if rtk_path:- # Inject into project AGENTS.md (Codex reads this automatically)- agents_md = Path.cwd() / "AGENTS.md"- _inject_rtk_instructions(agents_md, verbose=verbose)-- # Also inject into global Codex AGENTS.md+ # Keep RTK guidance local to the user's Codex configuration.global_agents = _codex_home_dir() / "AGENTS.md"_inject_rtk_instructions(global_agents, verbose=verbose)diff --git a/tests/test_cli/test_wrap_codex.py b/tests/test_cli/test_wrap_codex.pyindex f1b411035..1fff7eb67 100644--- a/tests/test_cli/test_wrap_codex.py+++ b/tests/test_cli/test_wrap_codex.py@@ -662,6 +662,39 @@ def test_wrap_codex_prepare_only_respects_codex_home(assert not (tmp_path / ".codex" / "config.toml").exists()+def test_wrap_codex_injects_rtk_globally_without_changing_project_agents(+ runner: CliRunner, monkeypatch: pytest.MonkeyPatch, tmp_path: Path+) -> None:+ _set_test_home(monkeypatch, tmp_path)+ project_dir = tmp_path / "project"+ project_dir.mkdir()+ project_agents = project_dir / "AGENTS.md"+ original = "# Project instructions\n\nUse the repository conventions.\n"+ project_agents.write_text(original, encoding="utf-8")+ original_bytes = project_agents.read_bytes()+ monkeypatch.chdir(project_dir)++ with patch(+ "headroom.cli.wrap._ensure_rtk_binary",+ return_value=tmp_path / "rtk",+ ):+ result = runner.invoke(+ main,+ [+ "wrap",+ "codex",+ "--prepare-only",+ "--no-mcp",+ "--no-serena",+ ],+ )++ assert result.exit_code == 0, result.output+ assert project_agents.read_bytes() == original_bytes+ global_agents = tmp_path / ".codex" / "AGENTS.md"+ assert wrap_mod._RTK_MARKER.encode() in global_agents.read_bytes()++def test_unwrap_codex_without_codex_home_warns_on_ambiguous_noop(runner: CliRunner, monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: