fix(agent): keep response policy in managed prompt

This commit is contained in:
2026-07-16 17:16:51 +08:00
parent 1b5fcc4d52
commit 921b56cfb9
2 changed files with 3 additions and 64 deletions

View File

@@ -21,7 +21,6 @@ from app.models.knowledge import (
)
from app.models.chat import ChatMessage
from app.services.knowledge_agent_service import Candidate, KnowledgeAgentService
from app.services.rag_service import PromptService, RetrievedChunk
def _database() -> Session:
@@ -146,9 +145,6 @@ def test_course_question_searches_chunk_and_reads_parent_section():
knowledge_context = next(
message["content"] for message in result.messages if message["content"].startswith("[本轮可靠知识上下文]")
)
assert "不得再以‘没有资料’" in knowledge_context
assert "不要求知识库中必须存在一个" in knowledge_context
assert "不要把本轮已经取到的内容留到下一轮再问" in knowledge_context
assert "来源知识库:亲子课程" in knowledge_context
@@ -228,26 +224,6 @@ def test_homework_overview_keeps_all_numbered_practices_before_selection():
assert all(item.chunk.title.startswith("练习") for item in selected)
def test_homework_overview_prompt_requires_every_recalled_title():
chunks = [
RetrievedChunk(
knowledge_id=1 if index <= 6 else 2,
knowledge_name="《原生·上》" if index <= 6 else "《原生·下》",
title=f"练习{index}:作业{index}",
content=f"作业{index}的正式说明",
)
for index in range(1, 15)
]
constraint = PromptService._list_completeness_constraint("原生里的作业都有哪些", chunks)
assert "本轮共召回 14 个正式编号练习" in constraint
assert "必须覆盖下面全部 14 项" in constraint
assert "不得新增清单外的作业" in constraint
assert "练习1作业1" in constraint
assert "练习14作业14" in constraint
def test_complete_section_includes_child_headings_but_stops_at_next_peer():
with _database() as db:
knowledge = _add_published_knowledge(db, knowledge_id=1, name="合一课程")