Skip to content

fix(antigravity): strip the Claude Code dual-use security sentence that triggers a fake 429 - #8829

Open
yanhexiong wants to merge 1 commit into
Wei-Shaw:mainfrom
yanhexiong:fix/antigravity-strip-dual-use-sentence
Open

yanhexiong wants to merge 1 commit into
Wei-Shaw:mainfrom
yanhexiong:fix/antigravity-strip-dual-use-sentence

Conversation

@yanhexiong

Copy link
Copy Markdown

Claude Code 的 system prompt 里有一句 Dual-use security tools (C2 frameworks, credential testing, exploit development) require clear authorization context: …,Antigravity 上游对包含这句话的 systemInstruction 直接返回裸 429 RESOURCE_EXHAUSTED(无 quotaResetDelay / RetryInfo),随后账号进入冷却,后续请求全部 503。和 #8791 / #7410 / #7307 是同一类上游规则,但这次命中的不是身份句,NeutralizeSystemIdentity 已把身份句改写掉之后仍然 429。

受控实验(同一 key、同一 endpoint、同一模型,只改 system,每次在账号无冷却时发送):

system 结果
Claude Code 2.1.325 完整请求 429(稳定复现)
同一请求去掉 Dual-use… 这一句 200
该句改写成 Tools with both offensive and defensive uses need a clear, authorized purpose. 200
该句的 126 字符片段单独发送 429
片段里每个关键词单独发送 200
片段里 9 个关键词首字母后插入 U+200B 429(零宽字符无效)

改动:

  • NeutralizeSystemIdentity 先删除这句话。它已经是 Claude /v1/messages、Gemini native、Responses/Chat 兼容三条链路的共同入口,一处改动全覆盖。
  • 新增 upstream_trigger_filter.go:默认只带这一条正则;支持环境变量 SUB2API_ANTIGRAVITY_STRIP_PATTERNS(每行一个 Go 正则,非法的跳过并记日志),上游以后再拦别的句子时运维可以直接配置,不必等发版。

验证:gofmt、go vet、golangci-lint v2.14.0(antigravity 包)均无问题;go test -tags=unit ./internal/service/... ./internal/handler/... ./internal/pkg/... 全部通过(含新增 5 个用例,其中一个走完整的 TransformClaudeToGemini)。已在线上以补丁版本跑通:之前稳定 429 的 Claude Code 请求(gemini-3-flash 与 gemini-4-carbon-medium)现在返回 200。

不在本 PR 范围:#8824 里提到的「裸 429(无 quotaResetDelay)不要冷却整个 antigravity:gemini scope」。

Refs #8824

🤖 Generated with Claude Code

…at triggers a fake 429

The Antigravity upstream answers system instructions containing Claude Code's
"Dual-use security tools (C2 frameworks, credential testing, exploit
development) require clear authorization context: ..." sentence with a bare
429 RESOURCE_EXHAUSTED (no quotaResetDelay/RetryInfo). It is not the identity
sentence NeutralizeSystemIdentity already rewrites, and inserting zero-width
characters into its keywords does not avoid it.

Drop the sentence in NeutralizeSystemIdentity, which every Antigravity path
already goes through, and let operators add further patterns through
SUB2API_ANTIGRAVITY_STRIP_PATTERNS without a rebuild.

Refs Wei-Shaw#8824

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@yanhexiong

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Nov 15, 2026
doublepi123 added a commit to doublepi123/sub2api that referenced this pull request Nov 17, 2026
Port upstream Wei-Shaw#8829, Wei-Shaw#8894, Wei-Shaw#8793 and Wei-Shaw#8878.

Antigravity answers some ordinary system-prompt text with a bare
429 RESOURCE_EXHAUSTED ("Resource has been exhausted (e.g. check quota).")
although quota is available; the identical request without the text
returns 200 (Wei-Shaw#8824, Wei-Shaw#8791). On 152 this hit devbox's Claude Code sessions on
gemini-4-carbon since 11-15 while minimal prompts to the same tier succeed.

- Wei-Shaw#8829/Wei-Shaw#8894: drop Claude Code's dual-use security sentence and its
  pasted-content sentence; extra patterns can be supplied without a rebuild
  through SUB2API_ANTIGRAVITY_STRIP_PATTERNS (one regexp per line).
- Wei-Shaw#8793: neutralize Pi's leading identity sentence.
- Wei-Shaw#8878: neutralize DeepSeek Harness's opener and rewrite its two mid-prompt
  sentences.

NeutralizeSystemIdentity now strips trigger sentences, rewrites one leading
identity, then applies the sentence redactions; it remains the shared entry
for the Claude, Gemini native and compat forwarding paths.
Warren-W pushed a commit to Warren-W/sub2api that referenced this pull request Nov 20, 2026
…al-use security sentence that triggers a fake 429

Upstream PR: Wei-Shaw#8829 (squashed from 297a212)
Warren-W pushed a commit to Warren-W/sub2api that referenced this pull request Nov 20, 2026
…de pasted-content sentence that triggers a fake 429

Upstream PR: Wei-Shaw#8894 (squashed from dbe4008); conflict with Wei-Shaw#8829 resolved by keeping both patterns.
Warren-W pushed a commit to Warren-W/sub2api that referenced this pull request Nov 20, 2026
…de pasted-content sentence that triggers a fake 429

Upstream PR: Wei-Shaw#8894 (squashed from dbe4008); conflict with Wei-Shaw#8829 resolved by keeping both patterns.
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.

1 participant