# Task Update — Accountants Chatbot (Alex)

**Date:** 5 Aug 2026  
**Area:** Chat routing · statement Q&A quality · anti-hallucination  
**Status:** Done  

---

## Summary

Hardened Alex so short / personal / concept questions no longer dump a full statement overview or invent answers from RAG. Document asks now go to focused structured insights; greetings, today’s date, and general concepts stay conversational.

---

## Problems fixed (from live chat)

| User ask | Before | After |
|----------|--------|--------|
| `help me analyse the pdf` | Capability help listing PDFs | Statement overview |
| `…what do you think my name is` | Full overview dump | Account holder from statement |
| `what is my bank name?` | Ollama concept gibberish | Bank / IFSC / branch from PDF |
| `what is the date todat` | Calendar nonsense | Today’s date template |
| `what is a pdf` | RAG invented a statement summary | PDF definition (no docs) |
| `…profit or loss` | Full overview dump | Focused net-cashflow verdict |

---

## What shipped

1. **Routing** — Analyse / field / identity / profit-loss before help; today’s date (`todat` typo) → `template_today`; “what is a PDF” → concept, not RAG.
2. **Identity & bank fields** — Statement identity (“think my name is…”) and bank-name asks extract from the uploaded PDF.
3. **Cashflow verdict** — `build_cashflow_verdict()` for profit/loss style questions (net inflow/outflow + totals), not a full summary card.
4. **Assistant policy** — Conversation vs document memory, natural greetings, name vs account-holder disambiguation, adaptive follow-up suggestions.
5. **Tests + smoke** — Router/accuracy coverage updated; **67** pytest cases passed; live API smoke on HDFC + Paytm KB confirmed the table above.

---

## Verification (live)

- Agent with `Acct Statement_4640_…pdf` + Paytm UPI PDF ready  
- `help me analyse the pdf` → Statement overview (Nitin Kumar, May 2026 totals)  
- Bank name → **HDFC BANK Ltd**  
- Profit/loss → net outflow **₹ -56,924.16** (focused card)  
- Today / “what is a pdf” → conversational, no document dump  

---

## Files touched

- `app/saas/chat_router.py` — route order, today/date, concept guards  
- `app/saas/finance_intent.py` — identity, bank field, profit/loss, PDF concept  
- `app/saas/insight.py` — cashflow verdict + structured KB wiring  
- `app/saas/agent.py` — `template_today` handler  
- `app/rag/chain.py` — help intent narrowed (don’t steal analyse)  
- `app/saas/assistant_policy.py` / `conversation.py` / `answer_style.py` — assistant behaviour  
- `tests/test_chat_router.py` — new route cases  

---

## Next (optional)

- Multi-statement disambiguation when user says “the pdf” with 2+ docs open  
- Trim LLM polish so overview prose stays shorter by default  
- Persist chat session suggestions chips after hard refresh without rebuild  
