Files
sure/app/models/provider
Guillem Arias cfde4c70a1 fix(ai): guard PDF size + surface bank-statement truncation
- PdfProcessor and BankStatementExtractor raise upfront when
  pdf_content.bytesize exceeds MAX_PDF_BYTES (32 MB, matching
  Anthropic's hard limit). Previously a 100 MB PDF would be
  base64-encoded (~133 MB) and packed into the JSON body before
  the API rejected it — peak heap ~270 MB per Sidekiq worker.
- BankStatementExtractor inspects response.stop_reason; when the
  model hit max_tokens it logs a warning and flags result[:truncated]
  so downstream callers know the transaction list may be incomplete.
- ISO date pattern added to statement_period_start/end schema in
  PdfProcessor so the model can't return "March 2026" — Anthropic
  enforces the regex via the tool's input_schema.

Tests cover the size guard (raises before any client.messages call),
truncated-result flagging, and the warning log path.
2026-05-29 14:51:09 +02:00
..
2025-11-24 19:52:34 +01:00
2026-04-11 21:37:07 +02:00
2025-11-25 20:21:29 +01:00
2026-04-09 18:33:59 +02:00
2025-11-24 19:52:34 +01:00
2025-08-05 23:35:01 +02:00
2026-04-09 18:33:59 +02:00
2026-05-10 22:13:57 +02:00
2026-05-10 22:13:57 +02:00
2025-09-24 00:19:51 +02:00
2025-10-28 19:32:27 +01:00
2026-04-09 18:33:59 +02:00