From ba0da8c12217c2515a7a211f1cb4ab43fdf6488e Mon Sep 17 00:00:00 2001 From: "jinli.yl" Date: Mon, 24 Aug 2026 17:35:14 +0800 Subject: [PATCH] fix(daily-paper): sanitize analysis workflow state --- reme/steps/cookbook/daily_paper/analyze.py | 9 +++++---- tests/unit/test_daily_paper.py | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/reme/steps/cookbook/daily_paper/analyze.py b/reme/steps/cookbook/daily_paper/analyze.py index 54b9bd4a..68e3579f 100644 --- a/reme/steps/cookbook/daily_paper/analyze.py +++ b/reme/steps/cookbook/daily_paper/analyze.py @@ -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, diff --git a/tests/unit/test_daily_paper.py b/tests/unit/test_daily_paper.py index 0583eec8..851a93da 100644 --- a/tests/unit/test_daily_paper.py +++ b/tests/unit/test_daily_paper.py @@ -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