fix(daily-paper): sanitize analysis workflow state

This commit is contained in:
jinli.yl 2026-08-24 17:35:14 +08:00
parent 4b0945bc0e
commit ba0da8c122
2 changed files with 10 additions and 7 deletions

View file

@ -128,8 +128,9 @@ class DailyPaperAnalyzeStep(DailyPaperStep):
)
used_titles.add(title)
note_rel = note_path.relative_to(self.workspace_path).as_posix()
body = strip_frontmatter(output.body)
if not output.desc.strip() or not body:
desc = replace_surrogates(output.desc.strip())
body = replace_surrogates(strip_frontmatter(output.body))
if not desc or not body:
raise ValueError(f"Agent returned an empty paper note for {paper.arxiv_id}")
await write_markdown(
note_path,
@ -137,7 +138,7 @@ class DailyPaperAnalyzeStep(DailyPaperStep):
{
"name": title,
"title": title,
"description": output.desc.strip(),
"description": desc,
"kind": "daily-paper-analysis",
"arxiv_id": paper.arxiv_id,
"source_title": paper.title,
@ -165,7 +166,7 @@ class DailyPaperAnalyzeStep(DailyPaperStep):
arxiv_id=paper.arxiv_id,
reasoning=selected.reasoning,
title=title,
desc=output.desc.strip(),
desc=desc,
body=body,
note_path=note_rel,
pdf_path=pdf_rel,

View file

@ -778,8 +778,8 @@ async def test_pipeline_filters_strict_yesterday_and_writes_outputs(
},
{
"title": "记忆代理研究",
"desc": "Detailed note one",
"body": "Evidence one [p. 1].",
"desc": "Detailed note\ud800 one",
"body": "Evidence\udfff one [p. 1].",
},
{
"title": "上下文压缩研究",
@ -874,7 +874,9 @@ async def test_pipeline_filters_strict_yesterday_and_writes_outputs(
assert "ReMe" not in analysis_prompt
assert "# PDF 分页文本" in analysis_prompt
digest_prompt = cc_wrapper.calls[-1]["inputs"]
assert "Evidence one [p. 1]." in digest_prompt
assert "Evidence\ufffd one [p. 1]." in digest_prompt
assert "Detailed note\ufffd one" in digest_prompt
assert not any("\ud800" <= character <= "\udfff" for character in digest_prompt)
assert "调用 Read" not in digest_prompt
assert "daily/2026-07-21" not in digest_prompt
assert "长期记忆" not in digest_prompt