diff --git a/app/services/portfolio_analysis.py b/app/services/portfolio_analysis.py index dfd3cb1..9de6383 100644 --- a/app/services/portfolio_analysis.py +++ b/app/services/portfolio_analysis.py @@ -344,7 +344,17 @@ async def analyse( {"role": "system", "content": system}, {"role": "user", "content": user}, ], - max_tokens=2000, + # 4000 not 2000. Italian / Spanish / French / German + # output runs ~25-35% longer in tokens than English; on + # top of that DeepSeek-V4-flash bills its internal + # reasoning against the same budget. At 2000 we + # repeatedly hit finish_reason=length mid-sentence, + # which the reviewer agent then correctly flags as + # truncated and rejects — the user ends up looking at + # whatever stale row was last cached. 4000 leaves + # ample headroom; we only pay for tokens actually + # emitted, not the cap itself. + max_tokens=4000, ) status = "ok" error_msg = None