Skip to content

bug: curation fails with 'unexpected end of JSON input' — VertexSynthesizer MaxTokens hardcoded at 4096 #76

Description

@mpeter

Summary

dewey curate fails for any vault with moderate content density. The VertexSynthesizer.Synthesize method hardcodes MaxTokens: 4096, but real-world curation extractions consistently produce responses larger than 4,096 output tokens. Claude truncates mid-JSON array → ParseExtractionResponse fails with parse LLM response as JSON array: unexpected end of JSON input.

Reproduction

Configure a knowledge store with rich markdown content (pursuits, dossier, account context — ~9-42 documents). Run dewey curate. Observe the error:

❌ <store>: parse extraction response: parse LLM response as JSON array: unexpected end of JSON input

Confirmed with stores containing as few as 9 documents when those documents contain rich markdown (dossiers, agreements, email context).

Root Cause

llm/vertex.go:

reqBody := vertexSynthRequest{
    AnthropicVersion: "vertex-2023-10-16",
    MaxTokens:        4096,  // ← hardcoded, too small for curation
    ...
}

A store with 9 richly-structured documents (134KB input) produced 16,000 output tokens — hitting the cap mid-JSON array. The stop_reason returned by Vertex is max_tokens.

Fix

Raise MaxTokens to 16000 (or make it configurable). Curation extraction is the primary consumer of Synthesize() and produces large JSON arrays; other callers (compile) produce shorter outputs.

MaxTokens: 16000,

Context

Discovered while running curation against several knowledge stores on Vertex AI with claude-sonnet-4-6@default. The max_tokens: 4096 limit was appropriate when the Vertex synthesizer was primarily used for compile operations but is insufficient for curation extraction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions