mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-03-09 15:25:17 +00:00
5b433f962fbeaeb957c86741014001b3c7508a1d
## 背景 当 Claude Code 发送过多工具信息时,可能超出 Kiro API 请求限制导致 500 错误。 现有的工具描述截断(KiroMaxToolDescLen = 10237)只能限制单个工具的描述长度, 无法解决整体工具列表过大的问题。 ## 解决方案 实现动态工具压缩功能,采用两步压缩策略: 1. 先检查原始大小,超过 20KB 才进行压缩 2. 第一步:简化 input_schema,只保留 type/enum/required 字段 3. 第二步:按比例缩短 description(最短 50 字符) 4. 保留全部工具和 skills 可调用,不丢弃任何工具 ## 新增文件 - internal/translator/kiro/claude/tool_compression.go - calculateToolsSize(): 计算工具列表的 JSON 序列化大小 - simplifyInputSchema(): 简化 input_schema,递归处理嵌套 properties - compressToolDescription(): 按比例压缩描述,支持 UTF-8 安全截断 - compressToolsIfNeeded(): 主压缩函数,实现两步压缩策略 - internal/translator/kiro/claude/tool_compression_test.go - 完整的单元测试覆盖所有新增函数 - 测试 UTF-8 安全性 - 测试压缩效果 ## 修改文件 - internal/translator/kiro/common/constants.go - 新增 ToolCompressionTargetSize = 20KB (压缩目标大小阈值) - 新增 MinToolDescriptionLength = 50 (描述最短长度) - internal/translator/kiro/claude/kiro_claude_request.go - 在 convertClaudeToolsToKiro() 函数末尾调用 compressToolsIfNeeded() ## 测试结果 - 70KB 工具压缩至 17KB (74.7% 压缩率) - 所有单元测试通过 ## 预期效果 - 80KB+ tools 压缩至 ~15KB - 不影响工具调用功能
CLIProxyAPI Plus
English | Chinese
This is the Plus version of CLIProxyAPI, adding support for third-party providers on top of the mainline project.
All third-party provider support is maintained by community contributors; CLIProxyAPI does not provide technical support. Please contact the corresponding community maintainer if you need assistance.
The Plus release stays in lockstep with the mainline features.
Differences from the Mainline
- Added GitHub Copilot support (OAuth login), provided by em4go
- Added Kiro (AWS CodeWhisperer) support (OAuth login), provided by fuko2935, Ravens2121
Contributing
This project only accepts pull requests that relate to third-party provider support. Any pull requests unrelated to third-party provider support will be rejected.
If you need to submit any non-third-party provider changes, please open them against the mainline repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Languages
Go
99.8%
Shell
0.1%