Fix Korrespond stream disconnect: emit progress before legal check

The dbnToolsRunLegalCheck call blocks for 30-120s with no output,
causing the H2 idle stream timeout (~60s) to drop the connection.

Fix: emit 'Verifying legal authorities...' progress event just before
the legal check to reset the idle timer. Also reduce legal check
timeouts from 120s/60s to 45s/30s so the call completes within the
new 60s window even if LiteLLM is slow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 19:26:45 +02:00
parent b014638f39
commit e3645ba908
2 changed files with 12 additions and 3 deletions
+10 -1
View File
@@ -91,6 +91,12 @@ final class DbnKorrespondAgent
'pl' => 'Sprawdzanie jakości projektu…',
'uk' => 'Перевірка якості чернетки…',
],
'legal_check' => [
'en' => 'Verifying legal authorities…',
'no' => 'Verifiserer rettskilder…',
'pl' => 'Weryfikacja źródeł prawnych…',
'uk' => 'Перевірка правових джерел…',
],
'translating_to' => [
'en' => 'Translating to {lang}…',
'no' => 'Oversetter til {lang}…',
@@ -257,7 +263,9 @@ PROMPT;
if ($emit) { $emit('progress', ['detail' => self::L('quality_check', $userLang)]); }
$checked = $this->selfCheck($draftNo, $retrieval['sources'], $classify, $goal, $tone);
// ── Legal check: dbn-legal-agent-v2 threshold verification ────────────────
// ── Legal check: dbn-legal-agent-v3 threshold verification ────────────────
// Emit progress to keep H2 stream alive during the blocking LiteLLM call (60s idle timeout)
if ($emit) { $emit('progress', ['detail' => self::L('legal_check', $userLang)]); }
$legalCheck = [];
try {
$legalCheck = dbnToolsRunLegalCheck($checked['draft'], $body);
@@ -775,6 +783,7 @@ EOT,
if ($emit) { $emit('progress', ['detail' => self::L('check_and_authorities', $userLang)]); }
$checked = $this->selfCheck($refinedNo, $retrieval['sources'], $classify, $goal, $tone);
if ($emit) { $emit('progress', ['detail' => self::L('legal_check', $userLang)]); }
$legalCheckRefine = [];
try {
$legalCheckRefine = dbnToolsRunLegalCheck($checked['draft'], $body);