Skip to content

agents: route claude to the headroom proxy root, not /v1 - #32

Merged
andrewthomaslee merged 1 commit into
mainfrom
headroom-claude-base-url
Nov 9, 2026
Merged

andrewthomaslee merged 1 commit into
mainfrom
headroom-claude-base-url

Conversation

@andrewthomaslee

Copy link
Copy Markdown
Member

What

  • flake-parts/homeModules/agents/agents.nix: with homeSpec.agents.mcp.headroom.routeProviders, claude's ANTHROPIC_BASE_URL is now the proxy root (http://127.0.0.1:8787), not …/v1.
  • tests/flake-module.nix: agents-wiring asserts that value.

Why

Claude Code appends /v1/messages to ANTHROPIC_BASE_URL. With …:8787/v1 every request went to /v1/v1/messages. The headroom proxy passes that through, and api.anthropic.com answers 404, so claude fails with "There's an issue with the selected model" whenever the proxy is on. The proxy has been off in home since the 0.42 package broke, so nobody hit this. Re-enabling it in home would have broken claude.

opencode (AI SDK baseURL, default https://api.anthropic.com/v1) and kimi (KIMI_CODE_BASE_URL, an OpenAI-style /v1 base) are right with /v1 and keep it. pi already uses the root.

Checks

Against headroom-lean 0.43.1 on this machine, with claude -p on a subscription login:

  • ANTHROPIC_BASE_URL=http://127.0.0.1:PORT/v1: proxy log shows POST /v1/v1/messages → 404 twice; claude errors.
  • ANTHROPIC_BASE_URL=http://127.0.0.1:PORT: POST /v1/messages → 200; claude answers; proxy /stats reports 461 tokens saved.
  • agents-wiring fails on the old value ("claude not routed to the headroom proxy root") and passes with the fix.
  • fmt: no changes. check: all checks passed.

Merge order

pkgs (external-systems/pkgs#27, merged) → modules (#31 merged, this PR) → home (bumps modules org-pkgs, re-enables the headroom proxy).

🤖 Generated with Claude Code

claude appends /v1/messages to ANTHROPIC_BASE_URL, so the proxy URL with
/v1 became /v1/v1/messages, which the proxy passes through and
api.anthropic.com answers 404: every claude request failed with the proxy
on ("issue with the selected model"). opencode (AI SDK) and kimi expect a
/v1 base and keep it; pi already used the root. agents-wiring asserts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrewthomaslee
andrewthomaslee enabled auto-merge (squash) November 9, 2026 13:44
@andrewthomaslee
andrewthomaslee merged commit 5e8005f into main Nov 9, 2026
3 checks passed
andrewthomaslee added a commit to external-systems/home that referenced this pull request Nov 9, 2026
)

## What

- `users/netsa/default.nix`, `users/matt/default.nix`:
`homeSpec.programs.headroom.enable = true` (was `false`).
- `flake.lock`, `devenv.lock`, `devenv.yaml`: `nix flake update modules
org-pkgs` → modules `main` 5e8005f, org-pkgs `main` 1188419, then
`sync-locks`.

## Why

The headroom proxy was turned off because the 0.42 wheel package broke.
It now comes from:
- external-systems/pkgs#27: headroom 0.43.1 built with uv2nix
(`headroom`, `headroom-lean`, `headroom-sandbox`).
- external-systems/modules#31: `homeSpec.programs.headroom.package`
defaults to `headroom-lean`, the torch-free profile (1.1 GiB closure).
- external-systems/modules#32: claude's `ANTHROPIC_BASE_URL` is the
proxy root. Before that fix, every claude request went to
`/v1/v1/messages` and failed.

With headroom enabled,
`homeSpec.agents.mcp.headroom.{enable,routeProviders}` (both default on)
give every agent the headroom MCP server and send its provider traffic
through the `headroom-proxy` user service on 127.0.0.1:8787:
- claude: `ANTHROPIC_BASE_URL`.
- opencode: anthropic `baseURL`.
- pi: models.json.
- kimi: `KIMI_CODE_BASE_URL`.

### Behaviour

- netsa (nixos, kamrui-h1, ghost, beelink) and matt (beelink) get a
`headroom-proxy` systemd user service.
- `claude` started from a login shell uses the proxy.
- Claude Desktop: the headroom MCP server is synced into
`claude_desktop_config.json`. The desktop chat talks to claude.ai, so it
can't use the proxy. The desktop app's Code tab sets its own
`ANTHROPIC_BASE_URL`, so it isn't routed yet.

## Checks

- `fmt`: no changes. `check`: all checks passed.
- `nix build` of
`nixosConfigurations.{nixos,kamrui-h1,ghost,beelink}.config.system.build.toplevel`:
OK. Each closure has `headroom-lean-0.43.1` and
`headroom-proxy.service`.
- kamrui-h1 netsa: `ANTHROPIC_BASE_URL=http://127.0.0.1:8787`,
`KIMI_CODE_BASE_URL=http://127.0.0.1:8787/v1`. Proxy ExecStart:
`headroom proxy --host 127.0.0.1 --port 8787 --mode cache
--openai-api-url https://api.kimi.ai/coding/v1`.

## Merge order

pkgs (#27, merged) → modules (#31, #32, merged) → **home (this PR)**.

## Deploy

The owner approved deploying kamrui-h1 after merge (`clan machines
update kamrui-h1`). Other machines are the owner's call:

```
clan machines update nixos ghost beelink
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
andrewthomaslee added a commit that referenced this pull request Nov 13, 2026
pkgs#31/#32: parallel vm-test --all, fresh --rebuild, CACHED results,
preparation retry. skills#19: the vm-tests, remote-builder,
clanservices and external-systems skills for that runner and the
converged clanServices. sync-locks in the same commit.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant