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
feat(wrap): allow project RTK instruction opt-out (#2078)
Andrew Barnesf53f720eb5e3
diff --git a/headroom/cli/wrap.py b/headroom/cli/wrap.pyindex a61595da3..12b1b8140 100644--- a/headroom/cli/wrap.py+++ b/headroom/cli/wrap.py@@ -5903,6 +5903,11 @@ def openclaw(is_flag=True,help="Skip CLI context-tool setup",)+ "--no-project-rtk",+ is_flag=True,+ help="Skip rtk instruction injection into the project AGENTS.md",+)@click.option("--no-mcp", is_flag=True, help="Skip headroom MCP server registration")@click.option("--no-serena", is_flag=True, help="Skip Serena MCP server registration")@click.option(@@ -5924,6 +5929,7 @@ def openclaw(def opencode(port: int,no_rtk: bool,+ no_project_rtk: bool,no_mcp: bool,no_serena: bool,code_graph: bool,@@ -5949,6 +5955,7 @@ def opencode(headroom wrap opencode # Start proxy + context tool + opencodeheadroom wrap opencode -- "fix the bug" # Pass prompt to opencodeheadroom wrap opencode --no-context-tool # Skip CLI context-tool setup+ headroom wrap opencode --no-project-rtk # Keep project AGENTS.md unchangedheadroom wrap opencode --no-mcp # Skip MCP retrieve tool registrationheadroom wrap opencode --no-serena # Skip Serena MCP registrationheadroom wrap opencode --port 9999 # Custom proxy port@@ -5968,9 +5975,9 @@ def opencode(click.echo(" Setting up rtk for OpenCode...")rtk_path = _ensure_rtk_binary(verbose=verbose)if rtk_path:- # Inject into project AGENTS.md- project_agents = Path.cwd() / "AGENTS.md"- _inject_rtk_instructions(project_agents, verbose=verbose)+ if not no_project_rtk:+ project_agents = Path.cwd() / "AGENTS.md"+ _inject_rtk_instructions(project_agents, verbose=verbose)# Inject into global OpenCode AGENTS.mdglobal_agents = _opencode_home_dir() / "AGENTS.md"_inject_rtk_instructions(global_agents, verbose=verbose)diff --git a/tests/test_cli/test_wrap_opencode.py b/tests/test_cli/test_wrap_opencode.pyindex 31c512eea..f053c290e 100644--- a/tests/test_cli/test_wrap_opencode.py+++ b/tests/test_cli/test_wrap_opencode.py@@ -241,6 +241,39 @@ def test_wrap_opencode_injects_rtk_into_agents_md(assert wrap_mod._RTK_MARKER in project_agents.read_text(encoding="utf-8")+def test_wrap_opencode_no_project_rtk_only_skips_project_agents_md(+ runner: CliRunner,+ tmp_path: Path,+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ monkeypatch.chdir(tmp_path)+ monkeypatch.delenv("HEADROOM_CONTEXT_TOOL", raising=False)+ _set_test_home(monkeypatch, tmp_path)+ project_agents = tmp_path / "AGENTS.md"+ project_agents.write_text("# Team instructions\n", encoding="utf-8")++ with patch.object(wrap_mod.shutil, "which", return_value="opencode"):+ with patch.object(wrap_mod, "_launch_tool", side_effect=SystemExit(0)):+ with patch.object(wrap_mod, "_ensure_rtk_binary", return_value=Path("/tmp/rtk")):+ result = runner.invoke(+ main,+ [+ "wrap",+ "opencode",+ "--no-project-rtk",+ "--no-proxy",+ "--port",+ "9000",+ "--no-mcp",+ ],+ )++ assert result.exit_code == 0, result.output+ assert project_agents.read_text(encoding="utf-8") == "# Team instructions\n"+ global_agents = tmp_path / ".config" / "opencode" / "AGENTS.md"+ assert wrap_mod._RTK_MARKER in global_agents.read_text(encoding="utf-8")++def test_wrap_opencode_idempotent_no_duplicate_block(runner: CliRunner,tmp_path: Path,