Fix AI insight output truncation — bump token cap, enforce bullet brevity

Live-tested on the dev stack: with the more verbose Sonnet model, the old
550-token cap cut the last bullet off mid-sentence. Bumped to 800 and told
the model to keep each bullet to 1-2 sentences so it isn't relying on the
cap alone to stay in bounds.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-24 19:39:26 +00:00
parent 2a7ee1d6b8
commit 50ef00c336

View file

@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
DEFAULT_MODEL = "claude-haiku-4-5-20251001" DEFAULT_MODEL = "claude-haiku-4-5-20251001"
DEFAULT_DAILY_TOKEN_BUDGET = 12000 DEFAULT_DAILY_TOKEN_BUDGET = 12000
MAX_OUTPUT_TOKENS = 550 MAX_OUTPUT_TOKENS = 800
FORECAST_HORIZON_DAYS = 30 FORECAST_HORIZON_DAYS = 30
RATE_MOVEMENT_THRESHOLD = 3.0 # GBP — minimum delta to surface as a market move RATE_MOVEMENT_THRESHOLD = 3.0 # GBP — minimum delta to surface as a market move
@ -322,7 +322,8 @@ def build_prompt(
"Output format: first line must be `HEADLINE: <one sentence, the single most important takeaway>`, " "Output format: first line must be `HEADLINE: <one sentence, the single most important takeaway>`, "
"then a blank line, then 4-6 bullet points covering: occupancy/pace, pricing opportunities, " "then a blank line, then 4-6 bullet points covering: occupancy/pace, pricing opportunities, "
"notable competitor rate movements (only if the Market Movement section has any), UK bank holidays " "notable competitor rate movements (only if the Market Movement section has any), UK bank holidays "
"in the window if they affect pace, and anything unusual requiring attention.\n\n" "in the window if they affect pace, and anything unusual requiring attention. Keep each bullet to "
"1-2 sentences — do not let any single bullet run long enough to risk truncation.\n\n"
"A 'Previous Insight' section may be included below — compare against it explicitly: call out what's " "A 'Previous Insight' section may be included below — compare against it explicitly: call out what's "
"changed, what's resolved, and what's still an open issue. Don't just repeat it verbatim.\n\n" "changed, what's resolved, and what's still an open issue. Don't just repeat it verbatim.\n\n"
"Never compare a direct/rack rate to a competitor's Booking.com rate as if they were the same channel — " "Never compare a direct/rack rate to a competitor's Booking.com rate as if they were the same channel — "