fix(analysis): raise default ANALYSIS_MAX_TOKENS 900 -> 4096

A text-dense page's full analysis JSON exceeded the 900-token output cap,
so the model stopped mid-object (finish_reason: length) and the truncated
response failed to parse ("EOF while parsing a list"). The page image +
prompt are only a few hundred tokens, so a larger output budget still fits
comfortably in an 8k context window. Still overridable via
ANALYSIS_MAX_TOKENS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-13 21:33:35 +02:00
parent 8b5bd99446
commit ab9b8fb172
4 changed files with 8 additions and 4 deletions

2
backend/Cargo.lock generated
View File

@@ -1517,7 +1517,7 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "mangalord"
version = "0.77.0"
version = "0.77.1"
dependencies = [
"anyhow",
"argon2",

View File

@@ -1,6 +1,6 @@
[package]
name = "mangalord"
version = "0.77.0"
version = "0.77.1"
edition = "2021"
default-run = "mangalord"

View File

@@ -113,6 +113,10 @@ pub struct AnalysisConfig {
/// Whole-job timeout in the worker (`ANALYSIS_JOB_TIMEOUT_SECS`).
pub job_timeout: Duration,
/// Output token cap sent as `max_tokens` (`ANALYSIS_MAX_TOKENS`).
/// Must be generous enough to hold the full JSON for a text-dense page
/// — too low truncates the response mid-object (`finish_reason:
/// length`) and the parse fails. The page image + prompt are only a few
/// hundred tokens, so a large output budget still fits an 8k window.
pub max_tokens: u32,
/// Longest image edge (px) before downscaling (`ANALYSIS_MAX_IMAGE_DIM`).
pub max_image_dim: u32,
@@ -134,7 +138,7 @@ impl Default for AnalysisConfig {
api_key: None,
request_timeout: Duration::from_secs(120),
job_timeout: Duration::from_secs(180),
max_tokens: 900,
max_tokens: 4096,
max_image_dim: 1024,
max_image_bytes: 8 * 1024 * 1024,
response_format: ResponseFormat::JsonSchema,