refactor: remove scripted file intercept — LLM owns all responses

Previously ab_ai_mail.py intercepted file uploads before reaching the
LLM and responded with a hardcoded clarification template. The LLM had
no involvement in the file upload response.

Changes:
- ab_ai_mail.py: remove _post_file_clarification, _find_pending_attachments,
  _describe_zip, and the two-step pending-attachment lookup. All messages
  (text, files, or both) are dispatched to the agent service immediately.
  Files with no text pass an empty message — the LLM decides what to do.
- upload.py: default message changed from hardcoded receipt instruction
  to '' so the LLM determines intent from file content.
- master_agent._synthesize: always runs through the LLM for both single
  and multi-agent cases — no raw templates reach the user.
- master_system.txt: add FILE UPLOADS routing rule so the LLM knows to
  route receipts to expenses_agent without asking for clarification.

New flow: upload → parse → LLM classifies → agent acts → LLM synthesizes
natural response → user sees it. Zero scripted intercepts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Carlos Garcia
2026-05-19 21:05:38 -04:00
parent 0bd1810405
commit 93f2a101fa
4 changed files with 36 additions and 158 deletions

View File

@@ -30,6 +30,10 @@ CRITICAL ROUTING RULE: Most messages are general conversation and require NO spe
Only route to a specialist agent when the user explicitly asks for Odoo data or actions.
When in doubt, use "agents": [].
FILE UPLOADS: When a user uploads files (message is empty or "User uploaded files"),
do NOT ask for clarification. Route directly to the appropriate agent based on file content.
Receipt images or PDFs → expenses_agent. Unknown files → agents: [] and answer directly.
Examples of correct routing:
User: "hello" or "hi" or "what can you do?" or "what does that mean?" or "ok" or "thanks"