小海
|
ecf4fa82ee
|
{ "message": "fix: stop renaming file_path to path implicitly, and remove compression tests" }
|
2026-03-11 09:55:15 +08:00 |
|
小海
|
5f0f9b7936
|
feat: v2.5.1 - 上下文智能压缩 + 截断检测 + tolerantParse 增强
🗜️ 智能压缩
- 长对话老消息压缩而非丢弃,保留因果链语义
- 工具结果压缩为摘要,助手消息保留工具名
- 压缩率 70-80%,解决 Cursor 上下文溢出问题
⚠️ 截断检测
- 代码块/XML 未闭合时返回 stop_reason=max_tokens
- Claude Code 自动继续,无需手动点击"继续"
🔧 tolerantParse
- 新增正则兜底层,处理未转义双引号的 JSON
- 解决 position 5384 等长参数解析崩溃
🛡️ 拒绝 fallback 优化
- 工具模式下返回极短引导文本
|
2026-03-10 17:29:49 +08:00 |
|
小海
|
f12ca30893
|
feat(v2.5.0): Cursor IDE 完整适配 + 工具参数自动修复 + 增量流式优化
🖥️ Cursor IDE 适配:
- 新增 /v1/responses 端点(Responses API → Chat Completions 自动转换)
- 兼容 Cursor 扁平工具格式 { name, input_schema }
- 扩展 /v1/models 模型列表(claude-sonnet-4-5/4/3.5)
- 连续同角色消息自动合并(mergeConsecutiveRoles)
- content 数组中 tool_use/tool_result 块直接透传
🔧 工具参数自动修复 (tool-fixer.ts):
- normalizeToolArguments: file_path → path 字段名映射
- replaceSmartQuotes: 中文/法文智能引号替换
- repairExactMatchToolArguments: 模糊匹配修复
- extractToolResultNatural: 自然语言 tool_result 转换
🚀 流式增量优化:
- input_json_delta / tool_calls 按 128 字节分块
- 拒绝重试扩展到工具模式
- 极短响应自动重试
🧪 新增 44 个单元测试 (tool-fixer + openai-compat)
|
2026-03-10 16:27:19 +08:00 |
|
小海
|
c072795528
|
feat: 修复流式中断 + JSON 解析 + tool_choice 强制工具调用
核心修复:
- cursor-client.ts: 固定总超时 → 空闲超时,防止长输出被截断 (#12)
- converter.ts: tolerantParse 三级修复策略,处理截断 JSON (#13)
- types.ts: 新增 AnthropicToolChoice 类型,补齐 tool_choice 字段
- converter.ts: buildToolInstructions 支持 tool_choice,注入 MANDATORY 约束
- handler.ts: tool_choice=any 时检测无工具调用 → 自动追加强制消息重试
测试覆盖:
- test/unit-tolerant-parse.mjs: 18 个单元测试(tolerantParse/parseToolCalls)
- test/e2e-chat.mjs: 16 个 E2E 测试(基础问答、工具调用、流式、边界防御)
- test/e2e-agentic.mjs: 7 个 Agentic 压测(完整 Claude Code 工具链模拟)
- package.json: 新增 test:unit / test:e2e / test:agentic 快捷命令
|
2026-03-10 15:11:51 +08:00 |
|