Finance AI Assistant
Agentic RAG · LangGraph · MCP · pgvector · Ollama
A local agentic RAG assistant that answers questions about US and Taiwan listed companies from their filings and news, with cited sources — running entirely on Ollama.
- 11 nodes · 4 conditional routes
- FastAPI API · SSE + async jobs
- 355 tests · 90% branch coverage (core) · CI
- Citation accuracy 89% (156 citations, hand-verified)
- −57% tool payload to the agent
- Context truncation 125 → 0
01Raw pgvector SQL over LangChain PGVector
JSONB metadata filters can't express "rank only within the latest filing" — the target Q2 chunks ranked #242 by pure similarity. Hand-written SQL handles multi-filter retrieval and reserves a slot for the latest report.
View code →02Single-purpose MCP tools
Retrieval and fetching are split into 3 MCP tools shared by the built-in agent and external clients, served over streamable HTTP with constant-time Bearer auth; the server refuses to start without a token.
View code →03Deterministic guardrails around the agent
Code, not the LLM, ends the loop when news is already fresh, caps tool calls at 4 rounds, and asks the user for a ticker when structured extraction degrades instead of searching the whole corpus.
View code →04Two silent failures, found and fixed
Ollama's default context silently cut 50–75% of every prompt (125 truncations → 0 after resizing), and token-capped JSON still "parsed successfully" — now detected via done_reason.
View code → ← All projects