ZqinKing
5b433f962f
feat(kiro): 实现动态工具压缩功能
...
## 背景
当 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
- 不影响工具调用功能
2026-01-14 11:07:07 +08:00
Ravens2121
d687ee2777
feat(kiro): implement official reasoningContentEvent and improve metadat
2025-12-18 04:38:22 +08:00
Ravens2121
e889efeda7
fix: add signature field to thinking blocks for non-streaming mode
...
- Add generateThinkingSignature() function in kiro_claude_response.go
2025-12-16 05:21:49 +08:00
Ravens2121
0a3a95521c
feat: enhance thinking mode support for Kiro translator
...
Changes:
2025-12-16 05:01:40 +08:00
Ravens2121
c3ed3b40ea
feat(kiro): Add token usage cross-validation and simplify thinking mode handling
2025-12-14 16:40:33 +08:00
Ravens2121
9c04c18c04
feat(kiro): enhance request translation and fix streaming issues
...
English:
- Fix <thinking> tag parsing: only parse at response start, avoid misinterpreting discussion text
- Add token counting support using tiktoken for local estimation
- Support top_p parameter in inference config
- Handle max_tokens=-1 as maximum (32000 tokens)
- Add tool_choice and response_format parameter handling via system prompt hints
- Support multiple thinking mode detection formats (Claude API, OpenAI reasoning_effort, AMP/Cursor)
- Shorten MCP tool names exceeding 64 characters
- Fix duplicate [DONE] marker in OpenAI SSE streaming
- Enhance token usage statistics with multiple event format support
- Add code fence markers to constants
中文:
- 修复 <thinking> 标签解析:仅在响应开头解析,避免误解析讨论文本中的标签
- 使用 tiktoken 实现本地 token 计数功能
- 支持 top_p 推理配置参数
- 处理 max_tokens=-1 转换为最大值(32000 tokens)
- 通过系统提示词注入实现 tool_choice 和 response_format 参数支持
- 支持多种思考模式检测格式(Claude API、OpenAI reasoning_effort、AMP/Cursor)
- 截断超过64字符的 MCP 工具名称
- 修复 OpenAI SSE 流中重复的 [DONE] 标记
- 增强 token 使用量统计,支持多种事件格式
- 添加代码围栏标记常量
2025-12-14 11:57:16 +08:00
Ravens2121
01cf221167
feat(kiro): 代码优化重构 + OpenAI翻译器实现
2025-12-14 06:58:50 +08:00
Ravens
8d5f89ccfd
fix(kiro): fix translator format mismatch for OpenAI protocol
...
Amp-Thread-ID: https://ampcode.com/threads/T-019b092b-f2de-72a1-b428-72511c0de628
Co-authored-by: Amp <amp@ampcode.com >
2025-12-11 01:15:00 +08:00
Ravens
084e2666cb
fix(kiro): add SSE event: prefix for Claude client compatibility
...
Amp-Thread-ID: https://ampcode.com/threads/T-019b08fc-ff96-766e-a942-63dd35ed28c6
Co-authored-by: Amp <amp@ampcode.com >
2025-12-11 00:14:20 +08:00
Mansi
02d8a1cfec
feat(kiro): add AWS Builder ID authentication support
...
- Add --kiro-aws-login flag for AWS Builder ID device code flow
- Add DoKiroAWSLogin function for AWS SSO OIDC authentication
- Complete Kiro integration with AWS, Google OAuth, and social auth
- Add kiro executor, translator, and SDK components
- Update browser support for Kiro authentication flows
2025-12-05 22:46:24 +03:00