Skip to content

feat(harness): enable Claude Code gateway hint headers - #122

Merged
FredLiu876 merged 2 commits into
mainfrom
fredliu/labs-312-cli-harness-setup-for-routers
Oct 6, 2026
Merged

FredLiu876 merged 2 commits into
mainfrom
fredliu/labs-312-cli-harness-setup-for-routers

Conversation

@FredLiu876

@FredLiu876 FredLiu876 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

LABS-312, spec section 3: https://app.notion.com/p/3e691d2472738103a4b5f6ae8964114d

baseten harness setup sets CLAUDE_CODE_GATEWAY_HINT_HEADERS=1 for Claude Code, so it sends its request-class headers (x-claude-code-request-class and friends) to the gateway. They default to off when ANTHROPIC_BASE_URL is a custom origin, which is what setup writes. The SEG classifier (basetenlabs/baseten#31752, LABS-304) reads them.

No X-Baseten-Harness after all (thanks @youngzheng-oss): every harness already identifies itself with X-Baseten-Client (#110), SEG forwards it, and the classifier keys on it with User-Agent fallback. A second duplicate header adds nothing today, and if the two concerns ever diverge, adding a new header then is additive.

Also here: a test pins a target.type: ROUTER route as the default route in all three harness pickers, and as the background route in Claude Code and OpenCode. Seeing the router route for real depends on the server-side routes API (basetenlabs/baseten#31292), already merged.

Testing: go fmt, go vet, go test ./..., including the real-harness test against Claude Code 2.1.289 and Codex, which confirmed Claude Code sends x-claude-code-request-class with the new env set.

Review notes: CLAUDE_CODE_GATEWAY_HINT_HEADERS is spelled out in both claudePaths and the setup list on purpose, matching how every other Claude env key in that file is written.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@linear

linear Bot commented Sep 30, 2026

Copy link
Copy Markdown

LABS-312

@youngzheng-oss

Copy link
Copy Markdown
Contributor

@FredLiu876 is this still needed given we already have X-Baseten-Client?

Setup sets CLAUDE_CODE_GATEWAY_HINT_HEADERS=1 so Claude Code sends its
request-class headers to the gateway, and teardown manages the key
through claudePaths. The real-binary test checks the header arrives.

LABS-312
…t type

The router picker test and the API-format test both decoded the Codex
catalog into untyped maps to read slugs. One test-only helper decodes it
into a named struct and both tests call it.

The routes API reports the router target as ROUTER, uppercase like the
other target types, so the fixture now matches.
@FredLiu876
FredLiu876 marked this pull request as ready for review October 6, 2026 01:09
Copilot AI balanced review requested due to automatic review settings October 6, 2026 01:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The configuration changes are consistent across harnesses and adequately covered by focused tests.

Review effort: Balanced
Findings: None

What changed in this PR

Adds explicit harness identification headers and Claude Code gateway hints.

Changes:

  • Configures X-Baseten-Harness across all harnesses.
  • Enables Claude Code gateway hint headers.
  • Tests header propagation, cleanup, and router-route selection.
File Description
internal/​harness/​harness.go Defines the harness header.
internal/​harness/​claude_code.go Configures headers and gateway hints.
internal/​harness/​codex.go Adds the header to Codex requests.
internal/​harness/​opencode.go Adds the header to OpenCode requests.
internal/​harness/​harness_test.go Tests configuration and teardown.
internal/​cmd/​command.harness_test.go Tests real requests and router routes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@FredLiu876
FredLiu876 force-pushed the fredliu/labs-312-cli-harness-setup-for-routers branch from f64e198 to 745851c Compare October 6, 2026 01:14
@FredLiu876 FredLiu876 changed the title feat(harness): send X-Baseten-Harness and enable Claude Code gateway hints feat(harness): enable Claude Code gateway hint headers Oct 6, 2026

@cretz cretz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(approving from user POV, deferring to others on runtime behavior)

@FredLiu876
FredLiu876 merged commit aebc5b1 into main Oct 6, 2026
3 checks passed
@FredLiu876
FredLiu876 deleted the fredliu/labs-312-cli-harness-setup-for-routers branch October 6, 2026 18:00
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.

5 participants