Skip to content

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.

fix(learn): run the claude-cli analysis with no tools (#3892)

gglucassdb90b93da9f8
diff --git a/headroom/learn/analyzer.py b/headroom/learn/analyzer.py
index 1627a19b9..ab9f84f5e 100644
--- a/headroom/learn/analyzer.py
+++ b/headroom/learn/analyzer.py
@@ -60,6 +60,13 @@ _MIN_DIGEST_TOKENS = 10_000
# --include-partial-messages adds incremental "stream_event" ticks during the
# assistant's response; without it claude only emits ~3 events total (system
# init, one assistant message, result) — too sparse to report live progress.
+# --tools "" and --strict-mcp-config leave the analysis session with zero tools:
+# the digest is the whole input and the answer is one JSON object, but a
+# headless `claude -p` is otherwise a full agent (Bash, Edit, Task, every MCP
+# server) under the user's own permissions. A model that goes off to read or
+# verify things keeps streaming, so the idle cap never fires and the run dies
+# at the hard cap with nothing written. Both flags are needed: --tools "" alone
+# leaves the MCP servers' tools.
_CLI_BACKENDS: list[tuple[str, str, list[str]]] = [
(
"claude",
@@ -71,6 +78,9 @@ _CLI_BACKENDS: list[tuple[str, str, list[str]]] = [
"stream-json",
"--verbose",
"--include-partial-messages",
+ "--tools",
+ "",
+ "--strict-mcp-config",
],
),
("gemini", "gemini-cli", ["gemini", "-p"]),
diff --git a/tests/test_learn/test_analyzer.py b/tests/test_learn/test_analyzer.py
index de2f79e88..1215fc907 100644
--- a/tests/test_learn/test_analyzer.py
+++ b/tests/test_learn/test_analyzer.py
@@ -792,6 +792,9 @@ class TestCallCliLlm:
"stream-json",
"--verbose",
"--include-partial-messages",
+ "--tools",
+ "",
+ "--strict-mcp-config",
]
def test_claude_cli_progress_callback_is_throttled(self):