From 72f607132c2c08944ca21cc167066c8faeec2ec1 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Fri, 24 Jul 2026 19:48:05 +0000 Subject: [PATCH] =?UTF-8?q?Tighten=20AI=20insight=20bullet=20constraints?= =?UTF-8?q?=20further=20=E2=80=94=20still=20truncating=20at=20800=20tokens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Live-tested again: 800 tokens still wasn't enough for Sonnet's bullet density (6 dense bullets, cut off mid-sentence again). Capped bullet count to 4-5, added a hard 35-word single-sentence limit per bullet, told it not to add a closing summary, and raised the cap to 1200 for genuine headroom. Co-Authored-By: Claude Sonnet 5 --- backend/jobs/ai_insights.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/jobs/ai_insights.py b/backend/jobs/ai_insights.py index d417a68..7f1663c 100644 --- a/backend/jobs/ai_insights.py +++ b/backend/jobs/ai_insights.py @@ -22,7 +22,7 @@ logger = logging.getLogger(__name__) DEFAULT_MODEL = "claude-haiku-4-5-20251001" DEFAULT_DAILY_TOKEN_BUDGET = 12000 -MAX_OUTPUT_TOKENS = 800 +MAX_OUTPUT_TOKENS = 1200 FORECAST_HORIZON_DAYS = 30 RATE_MOVEMENT_THRESHOLD = 3.0 # GBP — minimum delta to surface as a market move @@ -320,10 +320,12 @@ def build_prompt( "a daily briefing. Use UK date format (DD/MM/YYYY) and GBP (£) for all monetary values. " "Be specific with numbers and dates. Keep it actionable — no fluff or generic advice.\n\n" "Output format: first line must be `HEADLINE: `, " - "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 " - "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" + "then a blank line, then EXACTLY 4-5 bullet points covering the most important of: occupancy/pace, " + "pricing opportunities, 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. " + "Each bullet must be a SINGLE sentence, hard limit 35 words — pick the 1-2 most important numbers per " + "bullet rather than listing every date. Do not add a closing summary or wrap-up paragraph after the " + "bullets — the last bullet ends the response.\n\n" "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" "Never compare a direct/rack rate to a competitor's Booking.com rate as if they were the same channel — "