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.

docs(changelog): record turn_id feature; fix import order in new test

Garme8835affb80a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f0f63d3e5..46078d843 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
block, delete it manually and re-run. (#231)
### Added
+- **`turn_id` linking agent-loop API calls to a single user prompt** — a new
+ `compute_turn_id(model, system, messages)` helper in
+ `headroom/proxy/helpers.py` hashes the message prefix up to and including
+ the last user-text message, yielding an id that is stable across every
+ agent-loop iteration of one prompt but rolls over when the user sends a
+ new prompt (or runs `/compact`, `/clear`). `RequestLog` gained a
+ `turn_id: str | None` field, which is stamped at every log site
+ (anthropic handler bedrock + direct branches, and the streaming handler)
+ and surfaced as `turn_id` in `/transformations/feed`. Lets downstream
+ consumers (e.g. the Headroom Desktop Activity tab) aggregate savings per
+ user prompt rather than per API call.
- **Telemetry stack & install-mode identity fields** — anonymous beacon now
reports `headroom_stack` (how Headroom is invoked: `proxy`, `wrap_claude`,
`adapter_ts_openai`, ...) and `install_mode` (`wrapped` / `persistent` /
diff --git a/tests/test_proxy/test_compute_turn_id.py b/tests/test_proxy/test_compute_turn_id.py
index 55d77f71a..fe92cfc4a 100644
--- a/tests/test_proxy/test_compute_turn_id.py
+++ b/tests/test_proxy/test_compute_turn_id.py
@@ -4,7 +4,6 @@ from __future__ import annotations
from headroom.proxy.helpers import compute_turn_id
-
MODEL = "claude-sonnet-4-5"
SYSTEM = "You are helpful."