fix(always-on): tolerate H1 section headers in report markdown - #157
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
parseReportMarkdownto treat# <RequiredSection>as a valid section header (downgrading H1 to H2 behavior) and recordh1-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
always_on_report工具时,有时使用# Plan Reference(H1)而非## Plan Reference(H2)作为章节标题,导致parseReportMarkdown无法识别任何 section,所有章节被填充为(empty),实际详尽的 report 内容被完全丢弃。parseReportMarkdown现在会将# SectionName(当 SectionName 匹配 required section 名称时)自动降级为## SectionName,并在 fallbacks 中记录h1-downgraded(...)便于追踪。##(h2)标题。Test plan
##时行为不变#(H1)章节标题的 report content,验证parseReportMarkdown能正确提取所有 section 内容,且 fallbacks 包含h1-downgraded条目# Plan Reference(无独立标题行)时,title 回退为默认值Always-On Discovery Run,且Plan Referencesection 内容被正确提取Made with Cursor