c2743251e9
Self-evolving AI scientist framework built on LangGraph/LangChain with CLI/TUI core, FastAPI gateway, and Next.js frontend. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
"""Tests for stream output sanitizers."""
|
|
|
|
from EvoScientist.stream.sanitizer import (
|
|
normalize_user_visible_paths,
|
|
sanitize_internal_tracking_blocks,
|
|
sanitize_user_facing_text,
|
|
)
|
|
|
|
|
|
def test_sanitize_internal_tracking_blocks_without_markdown_headers():
|
|
raw = """SESSION INTENT
|
|
Search arXiv for dialogue boundary papers.
|
|
|
|
SUMMARY
|
|
The agent will run five queries.
|
|
|
|
ARTIFACTS
|
|
No files changed.
|
|
"""
|
|
|
|
assert sanitize_internal_tracking_blocks(raw) == ""
|
|
|
|
|
|
def test_sanitize_internal_tracking_blocks_preserves_user_content():
|
|
raw = """这里是给用户看的结论。
|
|
|
|
SESSION INTENT
|
|
Internal plan.
|
|
|
|
SUMMARY
|
|
Internal summary.
|
|
"""
|
|
|
|
assert sanitize_internal_tracking_blocks(raw) == "这里是给用户看的结论。"
|
|
|
|
|
|
def test_sanitize_internal_tracking_blocks_allows_proper_nouns():
|
|
raw = "Paper title contains Summary of Dialogue Acts, but it is not an internal header."
|
|
|
|
assert sanitize_internal_tracking_blocks(raw) == raw
|
|
|
|
|
|
def test_normalize_user_visible_paths_rewrites_artifact_mount_paths():
|
|
raw = "已保存到 `/workspace/artifacts/report.md`,另见 /artifacts/table.csv。"
|
|
|
|
assert normalize_user_visible_paths(raw) == "已保存到 `artifacts/report.md`,另见 artifacts/table.csv。"
|
|
|
|
|
|
def test_normalize_user_visible_paths_rewrites_upload_mount_paths():
|
|
raw = "输入文件为 /workspace/uploads/source.pdf。"
|
|
|
|
assert normalize_user_visible_paths(raw) == "输入文件为 uploads/source.pdf。"
|
|
|
|
|
|
def test_sanitize_user_facing_text_combines_tracking_and_path_cleanup():
|
|
raw = """结果已保存到 /workspace/artifacts/final.md。
|
|
|
|
SUMMARY
|
|
Internal summary.
|
|
"""
|
|
|
|
assert sanitize_user_facing_text(raw) == "结果已保存到 artifacts/final.md。"
|