Repository navigation
fix(issue#162): 恢复注入边界花括号转义(v0.7.4 修复在 v0.7.11 误删)+ hot memory 跳过 reasoning - #165
Conversation
…reasoning in hot memory - escapePromptVars restored at all three injection exits (memory block / hot context / user settings) with config escapePromptVariables (default on), resurrected from the v0.7.4 #40 fix that v0.7.11's refactor deleted wholesale - textOf now skips reasoning parts (type !== 'text'): assistant reasoning carrying Go-template/Vue/Handlebars fragments like docker --format "{{.Server.Version}}" was being injected into hot memory and crashing the turn via DSH interpolate()'s illegal-variable throw (sticky, unrecoverable) - 6 regression tests (5 restored from #40 + 1 new reasoning-path for #162) - lib/ synced; 978 tests green on the v0.8.0 batch-A baseline Co-authored-by: Anans-Ivresse <[email protected]> Co-authored-by: Claude <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough新增 Changes提示词注入保护
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to The prompt escaping, reasoning filtering, and opt-out behavior are implemented across the intended injection paths and covered by regression tests. No current merge-blocking risk is identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
issue slow-stack#334:注入路径 4 处截断点(热上下文查询/回复 500/800、 lastUserQuery 500、记忆条目 injectContentMaxChars)UTF-16 slice 切在代理对中间留下孤立高位代理项,序列化成非法 UTF-8 后 DeepSeek API 每轮 400,且畸形文本永久写入会话历史。新增 safeSlice(尾字符 为高位代理即丢弃),4 处截断点全部换用;测试以「孤立代理项不存在」 锁语义,附变异阴性对照。 issue slow-stack#333(issue #34 恢复):injectTimePrefix 于 v0.7.11 面板 大改版时随一次批量删除静默消失(CHANGELOG 无登记,同刀的 escapePromptVars 已随 slow-stack#162/slow-stack#165 恢复、本函数漏了)。按 v0.7.2 语义原样恢复:键名/默认值/格式不变,per-session 闩锁每会话一次, 时间前缀排记忆块最前(时间 → 热上下文 → 长期记忆)。settings 白名单、面板双语、FEATURE_GROUPS、配置计数锁同步。 全量 1429/1428/0。
背景(issue #162)
DSH 核心的
interpolate()会扫描注入文本里所有{{...}},变量名不匹配/^[a-z][a-z0-9_]*$/即 throw。v0.7.4(#40)曾修复过:在注入边界转义花括号,但该修复在 v0.7.11 的重构中被整块误删(escapePromptVars函数 + config schema + 三处调用全部消失,v0.7.10 有 6 处、v0.7.11 起 0 处)。本次完整找回。触发面扩大(#162 新增)
hot memory 的
textOf会把 assistant 的 reasoning part({type:"reasoning", text})也拼进注入文本——模型思考里写 docker--format "{{.Server.Version}}"(或 Go template / Vue / Handlebars / 正则 / 日志原文)就进 prompt →interpolate()抛错 → 整轮失败,且因 hot memory 每轮从会话日志重建,该消息一直留在窗口内,会话永久卡死。修复(三层)
src/inject.jsescapePromptVars(v0.7.4 原文):连续 2+ 个花括号中间插\,{{a}}→{\{a\}\},奇数连括号{{{a}}}也不残留字面{{;三处注入出口(memory 块 / 短期上下文 / 用户设置)全部包裹转义src/inject.jstextOf跳过 reasoning part(只取type==="text"或字符串)——直接掐断触发源,比 v0.7.4 只做转义更彻底src/config.jsescapePromptVariables(默认true,关闭时原样透传)test/inject.test.js--format "{{.Server.Version}}"场景)测试
lib/已npm run sync同步,lib-smoke 通过🆕 fix: 恢复注入边界花括号转义 + hot memory 跳过 reasoning
🆕 test: 6 个回归测试(5 找回 + 1 reasoning 路径)
🐛 issue #162: 会话被
{{.Server.Version}}卡死的根因(v0.7.11 回归 + reasoning 触发源)