Skip to content

feat(session-title): 注入式 Prompt 载荷剥离与历史标题回填,Session 标题恢复业务语义 - #290

Open
ThreeFish-AI wants to merge 4 commits into
feature/1.x.xfrom
session-title-from-messages
Open

ThreeFish-AI wants to merge 4 commits into
feature/1.x.xfrom
session-title-from-messages

Conversation

@ThreeFish-AI

Copy link
Copy Markdown
Owner

变更摘要

Session 标题提取新增「注入式 Prompt 载荷剥离」能力,并附带基于 Claude Code 转录的历史标题回填脚本,解决 Dashboard Sessions 页 Title 不可识别的问题(You are a memory... 模板 600 字截断 / 无 session_meta 行显示 -)。

机制层(executor.py)

  • 新增注入式模板家族表:记忆压缩 / 会话命名 / 分支命名 / 单命令 / 通用 You are 兜底。命中后剥离固定话术头,按 User query: / First request: 等分隔符截取真实业务载荷,产出 [家族标签] 载荷 形式标题(如 [记忆压缩] Agent "四测 T4 学通迁移" finished);具名家族无分隔符则跳过该条继续查找,通用家族无分隔符按真实输入处理(防误伤手打 You are ... 的用户消息)。
  • task-notification 载荷凝缩:实体解码先行(转义形态不绕过守卫),<summary> 提取限定在通知块内;无 summary 时剥块取残余文本。
  • 整条 task-notification / 会话续接摘要消息直接跳过;[Image #N] 占位符与 <pasted_content> 外壳剥离;ide_opened_file 纳入噪声白名单。
  • 豁免前缀(title_exempt_prefixes)同时作用于清洗文本与派生的注入式标题,命中时逐条跳过而非丢弃 Level 1。
  • Level 1 提取重构为 _derive_title_from_user_texts,供请求路径与历史回填共用(单一事实源)。

回填脚本(scripts/backfill_session_titles.py)

  • 扫描 ~/.claude/projects/*/<session_id>.jsonl 转录,复用请求路径同一推导逻辑重算标题;干跑预览 → sqlite3 backup API 备份 → 仅 UPDATE/INSERT session_meta,不触碰 usage_log。
  • 读取运行配置:title_exempt_prefixes 透传推导器;title_vendor_bindings 绑定前缀默认并入保护集,不改写参与供应商绑定的标题。
  • loader 过滤 isMeta / sidechain / CC 本地 slash 命令记录(运行时请求路径不可见的行),有效候选计数上限。

动机

全量数据分析(7986 个活跃 session):24h 窗口 87% 的标题是注入式 Prompt;2268 个可回溯 session 中 82% 首条 user 消息为注入式模板(OpenViking 记忆压缩器子会话 1681 个),真实任务内嵌在模板分隔符之后;1781 个 session 因全层级候选为空从未写入标题。剥离模板头、截取载荷即可恢复业务语义。

验证

  • 单测:新增注入式载荷提取 15 例 + 回填 loader 10 例;合并 feature/1.x.x 后全量 2046 passed。
  • 对抗验证 workflow(2 独立评审 + 32 样本忠实性抽检 31/32 + 完备性批判):findings 已全部修复(含回填脚本透传配置豁免前缀的 major、实体解码次序、通用家族误伤面、豁免标签逐条跳过语义)。
  • 本机实机回填 1807 条后 Dashboard Sessions 页实测:Title 列全部为带家族标签的可读标题,无模板残留、无横杠。

风险点

  • 提取为启发式:具名家族 opener 高度特异(本机 2279 个 session 中误伤率 0);通用 You are 家族已通过句界锚定分隔符 + 无分隔符回退真实输入收窄误伤面。
  • 回填仅覆盖有转录的 session(无转录者无数据源,保持现状);运行中实例需随版本升级后机制层才对未来 session 生效。

ThreeFish-AI and others added 4 commits September 10, 2026 17:32
release(1.x.x): v0.5.2a7 → v0.5.2 —— 流式错误日志乱码修复 / 供应商状态复位 / v0.5.2 周期收口
- 新增注入式模板家族表(记忆压缩/会话命名/分支命名/单命令/通用 You are),
  剥离固定话术头、按 User query: 等分隔符截取真实业务载荷,产出
  「[家族标签] 载荷」标题;通用家族无分隔符时按真实输入处理防误伤
- task-notification 载荷凝缩:实体解码先行、summary 提取限定通知块内
- 整条通知/续接摘要消息跳过;[Image #N] 与 <pasted_content> 外壳剥离;
  ide_opened_file 纳入噪声白名单
- 豁免前缀同时作用于清洗文本与注入式标题,命中时逐条跳过
- Level 1 提取重构为 _derive_title_from_user_texts,供请求路径与历史回填共用

🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
- 扫描 ~/.claude/projects 转录、复用请求路径同一推导逻辑重算标题,
  干跑预览 + sqlite3 backup API 备份后仅回写 session_meta
- 读取运行配置:title_exempt_prefixes 透传推导器、title_vendor_bindings
  绑定前缀默认并入保护集,避免改写参与供应商绑定的标题
- loader 过滤 isMeta/sidechain/本地 slash 命令记录,有效候选计数上限
- 本机已回填 1807 条:You are a memory... 模板类全部转为
  「[记忆压缩] 载荷」等可识别标题

🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist)
Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant