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:
@@ -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);
|
||||
|
||||
@@ -949,7 +949,7 @@ function dbnToolsRunLegalCheck(string $brief, string $docType): array
|
||||
'model' => 'dbn-legal-agent-v3',
|
||||
'temperature' => 0.1,
|
||||
'max_tokens' => 350,
|
||||
'timeout' => 120,
|
||||
'timeout' => 45,
|
||||
// No 'json' key — plain narrative, no response_format flag
|
||||
];
|
||||
|
||||
@@ -977,7 +977,7 @@ function dbnToolsRunLegalCheck(string $brief, string $docType): array
|
||||
['role' => 'system', 'content' => $sysMsg],
|
||||
['role' => 'user', 'content' => $question],
|
||||
],
|
||||
array_merge($opts, ['model' => 'qwen2.5:7b', 'timeout' => 60])
|
||||
array_merge($opts, ['model' => 'qwen2.5:7b', 'timeout' => 30])
|
||||
);
|
||||
$text = trim((string)($fallback['choices'][0]['message']['content'] ?? ''));
|
||||
} catch (Throwable $e) {
|
||||
|
||||
Reference in New Issue
Block a user