CCR workspace resolver misses Claude Code 2.x env block (now sent as isMeta user message, not body["system"])
Summary
extract_system_prompt in headroom/memory/storage_router.py:408-451 only scans
body["system"] (string or content-block list) and OpenAI-style messages[].role == "system"
for the cwd:-family prefixes defined in _CWD_PREFIXES (storage_router.py:46-50):
_CWD_PREFIXES: tuple[str, ...] = (
"Primary working directory:", # Claude Code (current)
"Working directory:", # Claude Code (older) / Codex
"cwd:", # Generic / debug format
)
Claude Code 2.1.272 no longer places this block in system. It now ships the
# Environment block (which contains Primary working directory: ...) as a user-turn
meta message (isMeta: true), consistent with the mid-conversation-system-2026-04-07
beta the client advertises via anthropic-beta. The string headroom greps for is present
in the request — just in messages[], not in system.
Effect
_resolve_ccr_workspace (proxy/handlers/anthropic.py:1533-1563) always fails to resolve
a workspace for Claude Code clients, so proxy.log floods with:
CCR: workspace unresolved; skipping track_compression (fail-closed — no x-headroom-cwd /
x-headroom-project-id header and no cwd: in system prompt)
on every single request, and per-workspace track_compression / proactive expansion never
fires for any Claude Code user who hasn't manually set x-headroom-cwd /
x-headroom-project-id headers.
Suggested fix
extract_system_prompt should also scan messages[].content[].text (or wherever
isMeta: true meta blocks land in the parsed body) for the same _CWD_PREFIXES, not just
body["system"].
Workaround (client-side, in case it helps others)
Setting x-headroom-cwd / x-headroom-project-id explicitly via
ANTHROPIC_CUSTOM_HEADERS works around this, but shouldn't be necessary given the prefix
table already anticipates Claude Code's current wording.
Env: headroom-ai 0.28.0 (pipx), macOS, Claude Code 2.1.272.
Source: headroomlabs-ai/headroom