Add duplicate approval flow with time-based dedup

- expenses_agent: extract transaction time (HH:MM) from OCR receipt text
- expenses_agent: _find_semantic_duplicate uses time to rule out false positives (>30 min apart = different receipts)
- expenses_agent: pause when duplicates found, set mode=awaiting_dup_approval, ask user before creating sheet
- expenses_agent: _report formats approval message listing each dup pair with vendor/amount/date/times/filenames
- ab_ai_mail: _find_pending_attachments recognises dup-approval bot message so ZIP re-attaches on user reply

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Carlos Garcia
2026-05-16 02:07:37 -04:00
parent f90a2ee863
commit 462f63d11d
2 changed files with 105 additions and 35 deletions

View File

@@ -191,12 +191,18 @@ class DiscussChannel(models.Model):
(i.e. the bot hasn't already acted on those files).
"""
messages = self.message_ids.sorted('date', reverse=True)[:_LOOKBACK_MESSAGES]
_bot_question_phrases = (
'what would you like me to do',
'suspected duplicate',
'skip duplicates',
'keep all',
)
prev_was_bot_question = False
for msg in messages:
is_bot = msg.author_id == bot_partner
if is_bot:
# Check whether this bot message was a clarification question
if 'what would you like me to do' in (msg.body or '').lower():
body_lower = (msg.body or '').lower()
if any(p in body_lower for p in _bot_question_phrases):
prev_was_bot_question = True
continue
# Human message