fix(antigravity): strip billing header from system instruction before upstream call#2817
Conversation
… upstream call The x-anthropic-billing-header block in the Claude system array is client-internal metadata and should not be forwarded to the Gemini upstream as part of systemInstruction.parts.
There was a problem hiding this comment.
Code Review
This pull request introduces a filter to skip system prompts starting with 'x-anthropic-billing-header:' during Claude request translation. The review feedback suggests improving the robustness of this check by normalizing the input string (trimming whitespace and lowercasing) and applying the same logic to other request formats for consistency.
| if strings.HasPrefix(systemPrompt, "x-anthropic-billing-header:") { | ||
| continue | ||
| } |
There was a problem hiding this comment.
The check for the billing header is case-sensitive and does not account for potential leading or trailing whitespace. Normalizing the string before checking the prefix makes the stripping more robust. Additionally, this logic should also be applied to the case where the system instruction is a single string (lines 115-119) to ensure consistent behavior across different request formats.
| if strings.HasPrefix(systemPrompt, "x-anthropic-billing-header:") { | |
| continue | |
| } | |
| if strings.HasPrefix(strings.ToLower(strings.TrimSpace(systemPrompt)), "x-anthropic-billing-header:") { | |
| continue | |
| } |
Summary
x-anthropic-billing-headerblock from the Claude system array before forwarding to Gemini upstreamsystemInstruction.partsTest plan