From ab9b8fb172953fa2d5143450dbd38d06333cfb09 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sat, 13 Jun 2026 21:33:35 +0200 Subject: [PATCH] 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) --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- backend/src/config.rs | 6 +++++- frontend/package.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index c622309..b88c55e 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -1517,7 +1517,7 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "mangalord" -version = "0.77.0" +version = "0.77.1" dependencies = [ "anyhow", "argon2", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 446d0b6..263e119 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mangalord" -version = "0.77.0" +version = "0.77.1" edition = "2021" default-run = "mangalord" diff --git a/backend/src/config.rs b/backend/src/config.rs index fe73315..f90b245 100644 --- a/backend/src/config.rs +++ b/backend/src/config.rs @@ -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, diff --git a/frontend/package.json b/frontend/package.json index 6b3b491..8b02f25 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "mangalord-frontend", - "version": "0.77.0", + "version": "0.77.1", "private": true, "type": "module", "scripts": {