Commit 76f552c
fix(finance): raise AI report token budget to avoid gpt-5.5 truncation
The AI research report intermittently failed with "Could not generate
the report" (ledger: "Model returned an empty or unusable report").
gpt-5.5 spends hidden reasoning tokens out of the same
max_completion_tokens budget before emitting output; the report JSON is
~1500-1900 tokens, and successful runs sat at 1903/1912 against the 2000
cap. When reasoning ran long the JSON truncated, JSON.parse failed, and
the route surfaced a 502.
Raise MAX_COMPLETION_TOKENS 2000 -> 4000 (a ceiling, not added cost) and
have the pipeline read finish_reason so a 'length' truncation throws a
distinct, diagnosable error instead of a vague "empty report".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent e6458a4 commit 76f552c
2 files changed
Lines changed: 22 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
90 | 101 | | |
91 | 102 | | |
92 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
| |||
0 commit comments