Skip to content

fix(free-tier): hide client tool names from shaped requests - #161

Merged
jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
cheerc:fix/anonymous-tool-name-fingerprint
Oct 29, 2026
Merged

jasonxu114514 merged 1 commit into
jasonxu114514:mainfrom
cheerc:fix/anonymous-tool-name-fingerprint

Conversation

@cheerc

@cheerc cheerc commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What

Shaped free-tier requests now send client tools under an opaque wire name (clint_ + 12 hex of the SHA-256 of the client name) instead of clint_<client name>.

Why

The free tier refuses a shaped body whose tool list still reads as another client's session, and answers with 429 FreeUsageLimitError — the exact message a genuinely exhausted IP receives.

A Claude Code request (claude-cli/2.1.312 → CLIProxyAPI → gateway) declares 14 tools. Two of them, ReportFindings and ScheduleWakeup, are enough on their own:

shaped body result
official 13 tools 200
official 13 + ReportFindings 200
official 13 + ScheduleWakeup 200
official 13 + both 429
both, one renamed 200
two empty placeholder tools with just those two names 429
22 tools / 120 KB body, neither name 200

So it is the names, not the schema, the size or the tool count. Because the gateway renames client tools as clint_<name>, every Claude Code session behind a proxy hit this, while the official CLI (which sends its own tool set) kept working and small hand-written requests through the gateway were fine.

Verification

Same daemon, same config, same minute, against the captured Claude Code body (95 898 bytes, 14 tools):

  • before: 3/3 429 anon:429
  • after: 3/3 200 anon:200, in=28254

End to end through CLIProxyAPI (/v1/messages → chat → /inference), replaying the original captured client request: 200, normal SSE stream.

Response path unchanged in behaviour: a call to a renamed client tool still comes back under the client's name, streaming fragments included ("name":"Read" observed), and non-streaming tool_calls restore too.

go build ./..., go vet ./..., go test ./... pass.

Notes

  • Session ids are untouched. CanonicalSessionID already re-encodes foreign sessions, and an implausible session timestamp is a separate 429 trigger documented in internal/identity/request.go; the follow-up identity work stays in fix(identity): salt derived session ids per process so a restart re-mints them #160.
  • Coverage: internal/protocol/tools_test.go pins opacity, stability and collision suffixes; internal/gateway/toolshape_test.go pins that a shaped body never spells the client tool names while still carrying the official set.

Closes #163. Related: #158 (umbrella tracking), #156 / #162 (probe and bench identity), #159 / #160 (session identity).

The free tier refuses a shaped body whose tool list still reads as another
client's session. A Claude Code request that declares both ReportFindings and
ScheduleWakeup is answered with FreeUsageLimitError — the same 429 a genuinely
exhausted IP receives — and the refusal is deterministic: rename either name
and the same request succeeds, and two empty placeholder tools carrying just
those two names reproduce it. Schema, size and tool count do not matter.

The gateway forwarded client tools as clint_<name>, so every Claude Code
session behind CLIProxyAPI was refused (14 tools, both markers present) while
the official CLI kept working and small requests through the gateway were
fine.

Client tools now get an opaque wire name: clint_ plus 12 hex characters of the
name's SHA-256, collision-suffixed like before. Descriptions and schemas are
untouched, so the model still knows what a tool does, and the response path
still restores the names the client declared, streaming included.

Verified against the captured Claude Code request (95 KB, 14 tools):
3/3 429 before the change, 3/3 200 after, and the same request replayed
through CLIProxyAPI (Anthropic /v1/messages -> chat -> /inference) returns
200. Session ids are unaffected: they are normalized by CanonicalSessionID,
and an implausible session timestamp is a separate 429 trigger documented
there.
@jasonxu114514
jasonxu114514 merged commit 4a4db10 into jasonxu114514:main Oct 29, 2026
5 checks passed
jasonxu114514 added a commit that referenced this pull request Oct 29, 2026
The repository ships without test files; strips the tests that arrived
with #160, #161 and #162 after their squash merges.
@cheerc
cheerc deleted the fix/anonymous-tool-name-fingerprint branch October 29, 2026 14:21
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.

Shaped free-tier requests still carry client tool names, so proxied Claude Code sessions 429 as FreeUsageLimitError

2 participants