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 Windows Unicode crash and Bedrock Claude 4.6 model IDs

chopratejas91a9969ab547
diff --git a/headroom/backends/litellm.py b/headroom/backends/litellm.py
index 296aba53b..98e3617be 100644
--- a/headroom/backends/litellm.py
+++ b/headroom/backends/litellm.py
@@ -96,8 +96,8 @@ def _build_bedrock_fallback_map(region: str) -> dict[str, str]:
# Base model IDs without region prefix
_CLAUDE_MODELS = [
# Claude 4.6
- ("claude-opus-4-6", "anthropic.claude-opus-4-6-v1:0"),
- ("claude-sonnet-4-6", "anthropic.claude-sonnet-4-6-v1:0"),
+ ("claude-opus-4-6", "anthropic.claude-opus-4-6-v1"),
+ ("claude-sonnet-4-6", "anthropic.claude-sonnet-4-6"),
# Claude 4.5
("claude-sonnet-4-5-20250929", "anthropic.claude-sonnet-4-5-20250929-v1:0"),
("claude-opus-4-5-20251101", "anthropic.claude-opus-4-5-20251101-v1:0"),
diff --git a/headroom/cli/wrap.py b/headroom/cli/wrap.py
index 6d7b60932..1ddebdb8e 100644
--- a/headroom/cli/wrap.py
+++ b/headroom/cli/wrap.py
@@ -12,6 +12,7 @@ Usage:
from __future__ import annotations
+import io
import os
import shutil
import signal
@@ -22,6 +23,12 @@ import time
from pathlib import Path
from typing import Any
+# Fix Windows cp1252 encoding — box-drawing characters require UTF-8
+if sys.platform == "win32" and hasattr(sys.stdout, "buffer"):
+ if sys.stdout.encoding and sys.stdout.encoding.lower().replace("-", "") != "utf8":
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
+ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
+
import click
from .main import main
@@ -68,10 +75,15 @@ def _start_proxy(port: int, *, learn: bool = False) -> subprocess.Popen:
log_path = _get_log_path()
log_file = open(log_path, "a") # noqa: SIM115
+ # Ensure proxy subprocess uses UTF-8 (Windows defaults to cp1252)
+ proxy_env = os.environ.copy()
+ proxy_env["PYTHONIOENCODING"] = "utf-8"
+
proc = subprocess.Popen(
cmd,
stdout=log_file,
stderr=log_file,
+ env=proxy_env,
)
# Wait for proxy to be ready (up to 15 seconds)
diff --git a/headroom/rtk/installer.py b/headroom/rtk/installer.py
index 1abcd99df..7283f9b2a 100644
--- a/headroom/rtk/installer.py
+++ b/headroom/rtk/installer.py
@@ -125,6 +125,8 @@ def download_rtk(version: str | None = None) -> Path:
[str(RTK_BIN_PATH), "--version"],
capture_output=True,
text=True,
+ encoding="utf-8",
+ errors="replace",
timeout=5,
)
if result.returncode != 0:
@@ -153,6 +155,8 @@ def register_claude_hooks(rtk_path: Path | None = None) -> bool:
[str(rtk_path), "init", "--global", "--auto-patch"],
capture_output=True,
text=True,
+ encoding="utf-8",
+ errors="replace",
timeout=10,
)
if result.returncode == 0: