This repository has been archived on 2026-08-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kb-skills/.planning/debug/srt-processor-thinking-mode.md
T
starmen1265 4d2645876b
PR Test / lint (pull_request) Successful in 1s
fix(srt): add disable_reasoning parameter for ASR correction and include title in archive filename
- SimpleAIClient: Add disable_reasoning parameter to control AI thinking mode
- ASRCorrector: Use disable_reasoning=True to get direct correction results
- ArchiveProcessor: Extract title from frontmatter and include in filename

File naming format: {YYYYMMDD}_{content_id}_{title}_analysis.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 22:19:14 +08:00

4.3 KiB
Raw Blame History

status, trigger, created, updated
status trigger created updated
awaiting_human_verify 调查并修复 SRTProcessor 的 ASR 纠错问题:启用思考模式后输出 AI 的思考过程而非纠错后的字幕内容,以及文件命名缺少标题 2026-03-21T22:00:00.000000 2026-03-21T22:30:00.000000

Current Focus

hypothesis: 修复已完成并通过测试 test: 所有自动化测试通过(4/4) expecting: ASR 纠错将使用禁用思考模式,文件命名将包含标题 next_action: 用户需要在实际环境中验证修复效果

自我验证结果

  • ✓ SimpleAIClient 支持 disable_reasoning 参数
  • ✓ ASRCorrector 使用 disable_reasoning=True
  • ✓ ArchiveProcessor 从 frontmatter 提取标题
  • ✓ _call_zhipu 在 disable_reasoning=True 时添加 thinking.type=disabled

Symptoms

expected: |

  1. ASR 纠错后输出纠正和润色后的完整字幕内容
  2. 文件命名包含视频标题 actual: |
  3. 输出包含 AI 的思考过程(Analyze the Request, 分析请求等)
  4. 文件命名格式:20260321_BV1MiPSz2ErY_analysis.md(缺少标题) errors: |
  • AI 返回 reasoning_content 而非 content
  • 文件命名未包含标题 reproduction: | 参考:~/work/zq/30.资源/AI分析/bilibili/20260321_BV1MiPSz2ErY_analysis.md 文件内容显示AI的思考分析过程而非纠错后的字幕 started: | 2026-03-21,修复 DeepAnalyzer 后重新启用思考模式,但 SRTProcessor 也受到相同问题影响

Eliminated

Evidence

  • timestamp: 2026-03-21T22:00:00 checked: 实际输出文件 ~/work/zq/30.资源/AI分析/bilibili/20260321_BV1MiPSz2ErY_analysis.md found: 文件内容包含 AI 的思考分析过程("Analyze the Request", "分析请求" 等),而非纠错后的字幕 implication: 修复代码没有生效,问题仍然存在

  • timestamp: 2026-03-21T22:00:00 checked: DeepAnalyzer._call_zhipu 的修复逻辑(第 110-124 行) found: 代码逻辑是"优先返回 content 字段,如果 content 为空才使用 reasoning_content" implication: 这个逻辑是错误的!当启用思考模式时,content 不为空但包含的是 AI 的分析过程

  • timestamp: 2026-03-21T22:00:00 checked: 智谱 API 文档 found: thinking.type 参数控制是否启用思考模式:enabled(默认)或 disabled implication: 解决方案是在调用 API 时显式设置 thinking.type="disabled" 来禁用思考模式

  • timestamp: 2026-03-21T22:00:00 checked: 提交 7ac4937 的 diff found: 该提交移除了 thinking.type="disabled" 参数,导致启用默认的思考模式 implication: 这就是问题的根源!移除 thinking.type="disabled" 后,AI 返回分析过程而非直接答案

  • timestamp: 2026-03-21T22:00:00 checked: 之前的提交 7903690 found: 这个提交添加了 thinking.type="disabled" 参数来禁用思考模式 implication: 但提交 7ac4937 又移除了它,导致问题重新出现

Resolution

root_cause: | 提交 7ac4937 移除了 thinking.type="disabled" 参数,导致智谱 API 使用默认的思考模式。 当启用思考模式时,AI 返回的内容(content 字段)包含了详细的分析过程(如 "Analyze the Request"), 而非我们期望的直接纠错后的字幕。ASR 纠错需要的是直接结果,不需要分析过程。

fix: |

  1. 在 SimpleAIClient 中添加 disable_reasoning 参数(默认 False)
  2. 在 ASRCorrector 调用时设置 disable_reasoning=True
  3. 在 _call_zhipu 方法中,当 disable_reasoning=True 时添加 thinking.type="disabled" 参数
  4. 在 ArchiveProcessor 中从 frontmatter 提取标题并添加到文件名 files_changed: []
  • kb_workflow/deep_analyzer/__init__.py: 添加 disable_reasoning 参数支持
  • kb_workflow/srt/corrector.py: ASRCorrector 使用 disable_reasoning=True
  • kb_workflow/pipeline/processors/archive.py: 从文件提取标题并添加到文件名

verification: | 自动化测试全部通过(4/4):

  1. ✓ SimpleAIClient 默认 disable_reasoning=False
  2. ✓ 可以设置 disable_reasoning=True
  3. ✓ generate 方法有 disable_reasoning 参数
  4. ✓ ASRCorrector._correct_batch 使用 disable_reasoning=True
  5. ✓ _extract_title_from_file 正确提取标题
  6. ✓ _sanitize_title 清理标题
  7. ✓ _call_zhipu 在 disable_reasoning=True 时添加 thinking.type=disabled
  8. ✓ _call_zhipu 返回 content 字段