[BUG] Proxy CONNECT requests are missing the claude-cli User-Agent (inconsistent with tunneled requests)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code identifies itself with User-Agent: claude-cli/<version> (external, cli) on its API requests — but when those requests go through an HTTP proxy, the CONNECT request that opens the tunnel carries no User-Agent at all. The unexpected behavior: a client that sets a UA everywhere else silently omits it on the one hop a non-intercepting proxy can actually read.
Example request as seen by proxy:
CONNECT api.anthropic.com:443 HTTP/1.1
Host: api.anthropic.com:443
The claude-cli UA is only sent on the real request inside the TLS tunnel, so a proxy that isn't doing full MITM interception cannot see it — and thus cannot attribute the connection to Claude Code at all.
Corporate/egress proxies that deliberately avoid TLS interception rely on the CONNECT preamble as the only visible layer. Because Claude Code is indistinguishable from a bare Node client there, allowlisting, auditing, and per-application routing of Claude Code traffic silently break.
What Should Happen?
The CONNECT request includes the same UA used for the API call, so the tunnel-establishment hop is attributable to Claude Code:
CONNECT api.anthropic.com:443 HTTP/1.1
Host: api.anthropic.com:443
User-Agent: claude-cli/2.1.197 (external, cli)
This is what other HTTP clients do — e.g. curl through the same proxy:
CONNECT api.anthropic.com:443 HTTP/1.1
Host: api.anthropic.com:443
User-Agent: curl/8.19.0
Proxy-Connection: Keep-Alive
Error Messages/Logs
Steps to Reproduce
- Start a minimal logging proxy:
node -e 'require("net").createServer(c=>c.once("data",d=>console.log("\n--- CONNECT ---\n"+d.toString().trim()))).listen(8888,()=>console.log("listening 8888"))'
- Point Claude Code at it (
HTTPS_PROXY=http://127.0.0.1:8888) and make any request. - Observe the logged CONNECT preamble.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.197 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Windows Terminal
Additional Information
_No response_