DeepSeek!
将每轮动态上下文(频道信息、语言偏好、话题提示、历史摘要)从系统 prompt 前缀中剥离,移入用户消息体。系统前缀在整个对话窗口内完全稳定不变,DeepSeek 前缀缓存命中率从 0% 提升至接近 100%。
- 首次对话冷启动无缓存,正常计费
- 第二轮起命中前缀缓存,输入 token 费用降低约 90%
- 长对话窗口(10+ 轮工具调用)预计单窗口节省约 20 元
- 其他支持前缀缓存的 AI 服务(Claude、ChatGPT、MiMo等)同样受益
- 新增 prefix fingerprint 追踪机制
39 项修复与改进
WebSocket 实时流
- 修复
get_runtime_store未导入导致的 NameError 崩溃 - 新增
live_turn_snapshot接口返回活跃回合状态及时间戳 - 新增
subscribe_live_stream支持刷新后事件缓冲重放 - 对话任务 detach 化:浏览器断连不再中断后端推理
- 添加
stream_end哨兵事件标记对话完成 - 刷新后自动重连活跃流式回合
- 修复管道事件中空 delta 的无效转发
- 内部 LLM 模式下跳过管道事件转发避免重复
状态栏时钟
- 两个时钟(窗口时间 / 回合时间)改为实时计算
- 冻结在结束时刻不再偷跑
- 新增后端轮询探测:即使事件丢失也能正确停表
- 从后端恢复
turn_start_time和window_start_time精确续接 - 后端存储
turn_start_times/window_start_timesper conversation
工具系统
GetSkillIndex工具执行器 fallback 查找修复(不再返回 Unknown tool)- 将
GetDateTime、GetSkillIndex、HassGetDateTime加入官方意图白名单 - 移除
HassToggle(已被原生覆盖无需白名单) - 运行时工具列表缓存化避免重复构建
- 插件工具排序保证确定性
前端 UI
- 屏蔽
.claw-md h1-h6大写加粗渲染问题 - 工具卡片颜色统一为灰色(流式和刷新后一致)
- 关闭连续对话时不注入 DOM 到官方默认气泡
- 修复
claw-ta-card/claw-ta-panel被 em 样式意外覆盖
Agent 容错与错误处理
- 新增瞬态错误关键词库(断连/超时/502/503/429 等)
- 新增不可用错误关键词库(not found / not loaded 等)
- 瞬态错误后保留已有部分输出而非全部丢弃
- 新增 agent 错误自修复机制(自动 reload 集成后重试)
- 错误信息美化格式化输出给用户
- 对话结束时清理
live_response_parts避免内存泄漏
Prompt 架构重构
build_base_prompt拆分为稳定前缀 + 动态build_turn_context_prompt- 频道检测(语音/IM/手机/桌面)抽取为独立函数
- 动态上下文通过
<turn-context>XML 标签包裹注入用户消息 - 历史摘要、配置审批、IM 审批 prompt 移至动态段
- 动态段有独立 budget 上限(8000 字符)避免挤占前缀
对话历史与状态
- 新增
mark_turn_in_progress/clear_in_progress实时标记 /stop命令增强:扫描所有 detached task 并取消/stop清理 live event buffer 和 in-progress 标记chat_history_api新增display_depth参数支持- 自适应记忆增加 graph cleanup hooks
其他
- Hook 事件系统新增
UserPromptSubmit钩子支持请求拦截
Core Architecture Change
Moved per-turn dynamic context (channel info, language preference, topic hints, history summary) out of the system prompt prefix and into the user message body. The system prefix is now completely stable across the entire conversation window, boosting DeepSeek prefix cache hit rate from 0% to near 100%.
- First-turn cold start incurs no cache, billed normally
- Second turn onward hits prefix cache, reducing input token cost by ~90%
- Long conversation windows (10+ tool call rounds) expected to save ~20 CNY per window
- Other prefix-cache-capable AI services (Claude, ChatGPT, MiMo, etc.) benefit equally
- Added prefix fingerprint tracking mechanism
39 Fixes & Improvements
WebSocket Real-time Streaming
- Fixed
get_runtime_storeNameError crash due to missing import - Added
live_turn_snapshotendpoint returning active turn state and timestamps - Added
subscribe_live_streamwith event buffer replay after refresh - Conversation tasks detach-ified: browser disconnect no longer aborts backend inference
- Added
stream_endsentinel event to mark conversation completion - Auto-reconnect to active streaming turn after refresh
- Fixed invalid forwarding of empty deltas in pipeline events
- Skipped pipeline event forwarding in internal LLM mode to prevent duplication
Status Bar Clocks
- Both clocks (window time / turn time) now calculate in real time
- Frozen at end moment, no longer creeping forward
- Added backend polling probe: stops correctly even if events are lost
- Restores
turn_start_timeandwindow_start_timefrom backend for precise resumption - Backend stores
turn_start_times/window_start_timesper conversation
Tool System
- Fixed
GetSkillIndextool executor fallback lookup (no longer returns "Unknown tool") - Added
GetDateTime,GetSkillIndex,HassGetDateTimeto official intent whitelist - Removed
HassToggle(already natively covered, no whitelist needed) - Runtime tool list cached to avoid repeated construction
- Plugin tool ordering made deterministic
Frontend UI
- Suppressed
.claw-md h1-h6uppercase bold rendering issue - Unified tool card color to gray (consistent between streaming and post-refresh)
- Prevented DOM injection into official default bubble when continuous conversation is off
- Fixed
claw-ta-card/claw-ta-panelbeing accidentally overridden by em styles
Agent Resilience & Error Handling
- Added transient error keyword library (disconnect / timeout / 502 / 503 / 429, etc.)
- Added unavailable error keyword library (not found / not loaded, etc.)
- Retains partial existing output after transient errors instead of discarding everything
- Added agent error self-healing mechanism (auto reload integration then retry)
- Error messages formatted and beautified for user display
- Cleans up
live_response_partsat conversation end to prevent memory leak
Prompt Architecture Refactor
- Split
build_base_promptinto stable prefix + dynamicbuild_turn_context_prompt - Extracted channel detection (voice / IM / mobile / desktop) into standalone function
- Dynamic context injected into user message wrapped by
<turn-context>XML tag - History summary, config approval, IM approval prompts moved to dynamic segment
- Dynamic segment has independent budget cap (8000 chars) to avoid crowding prefix
Conversation History & State
- Added
mark_turn_in_progress/clear_in_progressreal-time markers - Enhanced
/stopcommand: scans all detached tasks and cancels them /stopcleans up live event buffer and in-progress markerschat_history_apiaddeddisplay_depthparameter support- Adaptive memory added graph cleanup hooks
Misc
- Hook event system added
UserPromptSubmithook for request interception
Full Changelog: v8.7.0...v8.8.0