fix(agent): stabilize decision support grounding

This commit is contained in:
2026-09-16 12:15:42 +02:00
parent 50ba153904
commit 509b2f7544
4 changed files with 99 additions and 10 deletions
+22
View File
@@ -12,6 +12,7 @@ from agent.generate import (
UNCERTAIN_MESSAGE,
answer_question,
build_user_content,
ensure_decision_support_conflict,
looks_like_refusal,
strip_think,
trim_results,
@@ -61,6 +62,20 @@ class TestDecisionSupportValidation:
)
allowed = ["wk-akt-04", "lb-sva-03"]
def test_appends_fully_omitted_retrieved_conflict(self):
answer = ensure_decision_support_conflict(
self.question, "Die Prämie ist lohnsteuerfrei [wk-akt-04].", self.allowed
)
assert "⚠ Quellenkonflikt" in answer
assert "[lb-sva-03] ordnet" in answer
assert validate_decision_support_answer(self.question, answer, self.allowed) == []
def test_does_not_mask_existing_conflict_attempt(self):
original = "⚠ Widerspruch: Beide Quellen [wk-akt-04] [lb-sva-03]."
assert ensure_decision_support_conflict(
self.question, original, self.allowed
) == original
def test_requires_conflict_when_both_sources_are_in_context(self):
violations = validate_decision_support_answer(
self.question, "Nur lohnsteuerfrei [wk-akt-04].", self.allowed
@@ -74,6 +89,13 @@ class TestDecisionSupportValidation:
)
assert validate_decision_support_answer(self.question, answer, self.allowed) == []
def test_accepts_equivalent_listet_wording(self):
answer = (
"⚠ [wk-akt-04] nennt die Prämie SV- und BV-pflichtig. "
"[lb-sva-03] listet sie im Katalog als beitragsfreien Bezug."
)
assert validate_decision_support_answer(self.question, answer, self.allowed) == []
def test_rejects_reversed_source_roles_and_prompt_leakage(self):
answer = (
"⚠ [wk-akt-04] und [lb-sva-03] ordnen die Prämie als beitragsfrei "