• keh4l's avatar
    feat(claude): add ttl to cache_control with default 5m · 48433683
    keh4l authored and 陈曦's avatar 陈曦 committed
    Real Claude CLI traffic sends cache_control as
    `{"type":"ephemeral","ttl":"1h"}`. Our previous payload only
    sent `{"type":"ephemeral"}`, which is a bytewise mismatch with
    the official CLI and one more third-party detection signal.
    
    Policy: client-provided ttl is always passed through unchanged.
    Proxy-generated cache_control blocks default to 5m (vs Parrot's 1h)
    to avoid burning the 1h cache budget on automatic breakpoints while
    still aligning with the `ttl` field being present.
    
      - claude/constants.go: DefaultCacheControlTTL = "5m"
      - apicompat/types.go: new AnthropicCacheControl type with TTL field;
        AnthropicTool gains optional CacheControl pointer so the mimicry
        path can attach a cache breakpoint to tools[-1] later.
      - service/gateway_service.go: anthropicCacheControlPayload gains TTL;
        marshalAnthropicSystemTextBlock and rewriteSystemForNonClaudeCode
        emit ttl=5m by default.
    48433683
constants.go 7.45 KB