Merge pull request #56 from Askhz/chore/remove-attribution-header

chore: remove x-anthropic-billing-header from system prompt
This commit is contained in:
geroge 2026-05-12 10:11:03 +08:00 committed by GitHub
commit ba39b17a7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,11 +1,6 @@
// Critical system constants extracted to break circular dependencies
import { feature } from 'bun:bundle'
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../services/analytics/growthbook.js'
import { logForDebugging } from '../utils/debug.js'
import { isEnvDefinedFalsy } from '../utils/envUtils.js'
import { getAPIProvider } from '../utils/model/providers.js'
import { getWorkload } from '../utils/workloadContext.js'
const DEFAULT_PREFIX = `You are Claude Code, Anthropic's official CLI for Claude.`
const AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX = `You are Claude Code, Anthropic's official CLI for Claude, running within the Claude Agent SDK.`
@ -45,51 +40,6 @@ export function getCLISyspromptPrefix(options?: {
return DEFAULT_PREFIX
}
/**
* Check if attribution header is enabled.
* Enabled by default, can be disabled via env var or GrowthBook killswitch.
*/
function isAttributionHeaderEnabled(): boolean {
if (isEnvDefinedFalsy(process.env.CLAUDE_CODE_ATTRIBUTION_HEADER)) {
return false
}
return getFeatureValue_CACHED_MAY_BE_STALE('tengu_attribution_header', true)
}
/**
* Get attribution header for API requests.
* Returns a header string with cc_version (including fingerprint) and cc_entrypoint.
* Enabled by default, can be disabled via env var or GrowthBook killswitch.
*
* When NATIVE_CLIENT_ATTESTATION is enabled, includes a `cch=00000` placeholder.
* Before the request is sent, Bun's native HTTP stack finds this placeholder
* in the request body and overwrites the zeros with a computed hash. The
* server verifies this token to confirm the request came from a real Claude
* Code client. See bun-anthropic/src/http/Attestation.zig for implementation.
*
* We use a placeholder (instead of injecting from Zig) because same-length
* replacement avoids Content-Length changes and buffer reallocation.
*/
export function getAttributionHeader(fingerprint: string): string {
if (!isAttributionHeaderEnabled()) {
return ''
}
const version = `${MACRO.VERSION}.${fingerprint}`
const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? 'unknown'
// cch=00000 placeholder is overwritten by Bun's HTTP stack with attestation token
const cch = feature('NATIVE_CLIENT_ATTESTATION') ? ' cch=00000;' : ''
// cc_workload: turn-scoped hint so the API can route e.g. cron-initiated
// requests to a lower QoS pool. Absent = interactive default. Safe re:
// fingerprint (computed from msg chars + version only, line 78 above) and
// cch attestation (placeholder overwritten in serialized body bytes after
// this string is built). Server _parse_cc_header tolerates unknown extra
// fields so old API deploys silently ignore this.
const workload = getWorkload()
const workloadPair = workload ? ` cc_workload=${workload};` : ''
const header = `x-anthropic-billing-header: cc_version=${version}; cc_entrypoint=${entrypoint};${cch}${workloadPair}`
logForDebugging(`attribution header ${header}`)
return header
export function getAttributionHeader(_fingerprint: string): string {
return ''
}