fix: force JSON output for Ollama intent classification; fix attachment detection

- ollama_backend: add format='json' for 'master' and receipt_parser
  callers so llama3.1:8b returns valid JSON instead of plain English
- ab_ai_mail: add debug logging to trace attachment_ids from Discuss;
  handle file-only messages and clarification look-back flow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Carlos Garcia
2026-05-16 01:17:58 -04:00
parent 4b7223a139
commit 62d5d3f550
2 changed files with 19 additions and 0 deletions

View File

@@ -24,6 +24,11 @@ class OllamaBackend:
kwargs = {'model': self._model, 'messages': messages}
if tools:
kwargs['tools'] = tools
# Force structured JSON output for callers that parse JSON responses.
# Without this llama3.1:8b returns plain English instead of JSON.
_JSON_CALLERS = {'master', 'expenses_agent_receipt_parser'}
if caller in _JSON_CALLERS and not tools:
kwargs['format'] = 'json'
client = ollama.AsyncClient(host=self._url)
try:
response = await asyncio.wait_for(client.chat(**kwargs), timeout=self._timeout)