• alfadb's avatar
    fix(gateway): return 404 instead of fake 200 for unsupported count_tokens endpoint · 94895314
    alfadb authored
    PR #635 returned HTTP 200 with {"input_tokens": 0} when upstream doesn't
    support count_tokens (404). This caused Claude Code CLI to trust the zero
    value, believing context uses 0 tokens, so auto-compression never triggers.
    
    Fix: return 404 with proper error body so CLI falls back to its local
    tokenizer for accurate estimation. Return nil (not error) to avoid
    polluting ops error metrics with expected 404s.
    
    Affected paths:
    - Passthrough APIKey accounts: upstream 404 now passed through as 404
    - Antigravity accounts: same fix (was also returning fake 200)
    94895314
gateway_anthropic_apikey_passthrough_test.go 29 KB