Skip to content

fix(always-on): tolerate H1 section headers in report markdown - #157

Merged
Kaguya-19 merged 1 commit into
mainfrom
fix/report-h1-section-downgrade
Jun 4, 2026
Merged

fix(always-on): tolerate H1 section headers in report markdown#157
Kaguya-19 merged 1 commit into
mainfrom
fix/report-h1-section-downgrade

Conversation

@Gucc111

@Gucc111 Gucc111 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • LLM 在调用 always_on_report 工具时,有时使用 # Plan Reference(H1)而非 ## Plan Reference(H2)作为章节标题,导致 parseReportMarkdown 无法识别任何 section,所有章节被填充为 (empty),实际详尽的 report 内容被完全丢弃。
  • parseReportMarkdown 现在会将 # SectionName(当 SectionName 匹配 required section 名称时)自动降级为 ## SectionName,并在 fallbacks 中记录 h1-downgraded(...) 便于追踪。
  • Title 解析不再把匹配 required section 名称的 H1 行误消费为标题。
  • Report prompt(英文 + 中文)现在明确要求使用 ##(h2)标题。

Test plan

  • 触发一次 Always-On run,观察 report 正常使用 ## 时行为不变
  • 手动构造一份使用 #(H1)章节标题的 report content,验证 parseReportMarkdown 能正确提取所有 section 内容,且 fallbacks 包含 h1-downgraded 条目
  • 验证第一行为 # Plan Reference(无独立标题行)时,title 回退为默认值 Always-On Discovery Run,且 Plan Reference section 内容被正确提取

Made with Cursor

LLMs sometimes emit `# Plan Reference` (H1) instead of the required
`## Plan Reference` (H2), causing parseReportMarkdown to miss every
section and produce an all-empty report.

- parseReportMarkdown now downgrades `# SectionName` to `## SectionName`
  when the name matches a required section, and records an
  h1-downgraded fallback entry for traceability.
- Title parsing no longer consumes a line whose H1 text matches a
  required section name, so it stays available for section extraction.
- Report prompts (en + zh) now explicitly require `##` (h2) headers.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves robustness of the Always-On work report markdown parsing and reduces the chance of the runtime discarding report content when the LLM uses H1 headers for required sections. It also updates the report-writing prompts (EN + ZH) to explicitly require H2 (##) section headers to avoid producing incompatible markdown.

Changes:

  • Update parseReportMarkdown to treat # <RequiredSection> as a valid section header (downgrading H1 to H2 behavior) and record h1-downgraded(...) in fallbacks.
  • Fix title parsing so an H1 line matching a required section name is not mistakenly consumed as the report title.
  • Clarify report prompts (English + Chinese) to require ## headers for each required report section.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/always-on/runtime/discoveryPrompts.zh.ts Explicitly requires ## (H2) headers for each report section in the Chinese report prompt.
src/always-on/runtime/discoveryPrompts.ts Explicitly requires ## (H2) headers for each report section in the English report prompt.
src/always-on/contracts/ReportContract.ts Makes report parsing tolerant to H1 required-section headers and avoids mis-parsing required-section H1 as the title.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Kaguya-19
Kaguya-19 merged commit 8a29e2a into main Jun 4, 2026
1 check passed
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.

3 participants