Make dbn-legal-agent-v3 checker context-aware; wire into LegalAnalysisAgent

Three fixes:
1. bootstrap.php dbnToolsRunLegalCheck(): prepend first 350 chars of synthesis text
   to the v3 user message so it validates actual content, not just general law.
2. BvjAnalyzerAgent: fix engine guard — was skipping check for claude_sonnet/haiku;
   now skips only when dbn_legal_v3 is the synthesis model (it already IS the check).
3. LegalAnalysisAgent: add post-synthesis dbnToolsRunLegalCheck() call after Pass 3;
   add 'legal_check' key to runFullAnalysis() return.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 16:45:41 +02:00
parent 8a11001bff
commit 190f639784
3 changed files with 22 additions and 4 deletions
+8 -1
View File
@@ -1175,12 +1175,19 @@ function dbnToolsRunLegalCheck(string $brief, string $docType): array
$sysMsg = 'Du er en ekspert på norsk barnevernsloven og EMD-praksis. Svar alltid på norsk med korrekt juridisk terminologi. Bruk terskler fra barnevernsloven 2021: § 4-25 krever «klar nødvendighet». Strand Lobben mot Norge (37283/13) setter krav om rehabiliteringsplan før adopsjon. Aldri oppfinn paragrafnumre, saksnumre eller dommernavn.';
// Prepend a short snippet of the actual synthesis text so v3 answers in context,
// not just as a general law quiz. Strip HTML tags and cap at 350 chars.
$snippet = mb_strimwidth(strip_tags($brief), 0, 350, '…');
$userMsg = $snippet !== ''
? "Tekst fra dokumentet:\n{$snippet}\n\n{$question}"
: $question;
$text = '';
try {
$response = dbnToolsCallGpuLlm(
[
['role' => 'system', 'content' => $sysMsg],
['role' => 'user', 'content' => $question],
['role' => 'user', 'content' => $userMsg],
],
$opts
);