Skip to content

fix: 清洗 Claude 工具 schema 并改写被 Antigravity 误判的身份前缀 - #412

Open
neverforget-1 wants to merge 1 commit into
su-kaka:masterfrom
neverforget-1:feat/converter-tool-schema-fixes
Open

neverforget-1 wants to merge 1 commit into
su-kaka:masterfrom
neverforget-1:feat/converter-tool-schema-fixes

Conversation

@neverforget-1

Copy link
Copy Markdown

背景 / Background

两类上游 429 误判:

  1. 不完整工具 schema:部分对话式客户端(Agent 框架)会把空属性/缺字段的工具 schema 原样传入,Antigravity 侧校验失败后返回 429,看起来像限流,实际是请求结构问题。
  2. 系统身份前缀误判:某些 Agent 的系统提示词开头(如 "You are X, an intelligent AI assistant..." 模式)会命中 Antigravity 的滥用判定,正常请求被 429 拦截。

方案 / Solution

  • _ensure_empty_tool_schema_for_claude:对进入 antigravity 转换层的工具声明做结构清洗(补全空 schema 的 type/properties 字段)
  • 身份前缀改写:识别被 Antigravity 拒绝的系统提示词开头模式,在保持语义等价的前提下改写措辞(例如 "You are X, an assistant" → "X is an assistant"),绕过误判
  • 附带测试覆盖改写逻辑

测试 / Testing

  • pytest tests/test_gemini_fix.py:3 passed

English TL;DR: Sanitize incomplete tool schemas from conversational agent clients into structures Antigravity accepts, and reword system-identity prefixes that Antigravity's abuse heuristic misjudges as 429s (semantically equivalent rephrasing). Includes tests.

Note: 另外注意到上游 master 的 tests/test_gemini_fix.py 引用了 gemini_fix._ensure_empty_tool_schema_for_claude,但该函数实际定义在 antigravity_fix.py,上游当前 master 测试存在 ImportError——本 PR 合并后可修复该问题(本 PR 的测试文件包含正确定义与导入)。

- 新增 _ensure_empty_tool_schema_for_claude: 对话式客户端传入的不完整工具 schema 清洗为 Antigravity 接受的结构
- 识别并改写触发 Antigravity 429 误判的系统身份前缀,避免正常请求被当作滥用拦截
- 补充对应测试

This branch has not been deployed

No deployments
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