Fix advocate brief truncation: raise synthesis max_tokens to 6K
Haiku synthesis had a hard cap of 2500 tokens which truncated the advocate JSON response (~4-6K tokens), causing decodeJsonObject() to fail and rendering the raw JSON string as the brief. Fix: remove the 2500-token Haiku override; introduce a per-mode limit (6000 for advocate, 4000 for deep-research) in $opts before the engine branch so all paths benefit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1133,7 +1133,10 @@ PROMPT;
|
|||||||
['role' => 'user', 'content' => $prompt],
|
['role' => 'user', 'content' => $prompt],
|
||||||
];
|
];
|
||||||
$synthTemp = ($advocateRole !== '') ? min($temperature, 0.20) : $temperature;
|
$synthTemp = ($advocateRole !== '') ? min($temperature, 0.20) : $temperature;
|
||||||
$opts = ['json' => true, 'temperature' => $synthTemp, 'max_tokens' => 4000, 'timeout' => 180];
|
// Advocate briefs require ~4-6K tokens (brief + strengths + weaknesses + uncertainty).
|
||||||
|
// Non-advocate deep-research responses are shorter (~2-3K). Use separate limits.
|
||||||
|
$synthMaxTokens = ($advocateRole !== '') ? 6000 : 4000;
|
||||||
|
$opts = ['json' => true, 'temperature' => $synthTemp, 'max_tokens' => $synthMaxTokens, 'timeout' => 180];
|
||||||
$thinkingTrace = null;
|
$thinkingTrace = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1153,9 +1156,9 @@ PROMPT;
|
|||||||
$raw = $this->azure->withDeployment('gpt-4o')->chatText($messages, $opts);
|
$raw = $this->azure->withDeployment('gpt-4o')->chatText($messages, $opts);
|
||||||
$deployLabel = 'gpt-4o';
|
$deployLabel = 'gpt-4o';
|
||||||
} elseif ($engine === 'azure_mini' && $this->azure instanceof DbnBedrockGateway) {
|
} elseif ($engine === 'azure_mini' && $this->azure instanceof DbnBedrockGateway) {
|
||||||
// When Bedrock enabled, azure_mini → Haiku (fast, ~20-40s synthesis)
|
// When Bedrock enabled, azure_mini → Haiku (fast, ~20-50s synthesis)
|
||||||
$haiku = $this->azure->withDeployment(DbnBedrockModelRouter::LITELLM_HAIKU);
|
$haiku = $this->azure->withDeployment(DbnBedrockModelRouter::LITELLM_HAIKU);
|
||||||
$raw = $haiku->chatText($messages, array_merge($opts, ['max_tokens' => 2500, 'timeout' => 90]));
|
$raw = $haiku->chatText($messages, array_merge($opts, ['timeout' => 90]));
|
||||||
$deployLabel = 'Claude Haiku 4.5 (AWS Bedrock)';
|
$deployLabel = 'Claude Haiku 4.5 (AWS Bedrock)';
|
||||||
$thinkingTrace = null;
|
$thinkingTrace = null;
|
||||||
} elseif ($engine === 'claude_sonnet' || ($this->azure instanceof DbnBedrockGateway)) {
|
} elseif ($engine === 'claude_sonnet' || ($this->azure instanceof DbnBedrockGateway)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user