Add read-only production runtime audit

This commit is contained in:
2026-08-17 11:17:40 +07:00
parent 057d4ed9dc
commit a1de4715a4
106 changed files with 6869 additions and 1782 deletions
+21
View File
@@ -839,6 +839,7 @@ class GroundedAnswerService:
evidence_drug_ids: tuple[str | None, ...] = (),
budget: RequestBudget | None = None,
plan: AnswerPlan | None = None,
retry_unsupported_patient_list: bool = True,
) -> "_GenOutcome":
"""A verified generation, a clarifying question, or empty to fall back."""
if self._generator is None or not evidence_texts:
@@ -935,6 +936,26 @@ class GroundedAnswerService:
)
return _GenOutcome(reject_reason=verification.reason)
if not verification.supported:
# Patient-specific candidate comparisons occasionally receive a
# noisy negative entailment verdict even though the same evidence
# and a fresh answer clear both fail-closed checks immediately
# afterwards (observed in the C03 contextual renal-safety turn).
# Retry only this known conversational lane, once. Ordinary AI
# answers and monograph browsing are intentionally unchanged.
if patient_specific and list_mode and retry_unsupported_patient_list:
return self._generate(
query,
evidence_texts,
prompt_evidence_texts,
intro=intro,
list_mode=list_mode,
patient_specific=patient_specific,
candidate_drug_ids=candidate_drug_ids,
evidence_drug_ids=evidence_drug_ids,
budget=budget,
plan=plan,
retry_unsupported_patient_list=False,
)
self._metrics.increment(
metric_names.GENERATION_REJECTED, reason="unsupported_claim"
)