The Problem
LLMs are useless for live financial questions out of the box: prices, statements, and analyst sentiment change daily, so any answer from training data is fabricated by definition — and raw text answers can't carry the charts and tables that make market data readable.
The Solution
A full-stack agentic platform. A LangGraph reasoning loop is wired to sixteen specialised tools over yfinance — price, historical ranges, financial statements, holders, insider transactions, dividends, splits, news, analyst recommendations, plus a company-name → ticker resolver. A strict system prompt forces tool-first behaviour: never fabricate, resolve tickers before answering, fall back to reasoning only when no tool applies. Responses stream as Server-Sent Events through Thesys C1's generative-UI model, so the React frontend renders native charts and tables from the token stream instead of static markdown. Every request is traced span-by-span in Langfuse.
How the workflow runs
01 · Ask
The React chat posts the question with a thread id; FastAPI opens a traced request span.
02 · Route
The agent checks whether a tool can supply real data — resolving company names to tickers first when needed.
03 · Fetch
Selected tools hit Yahoo Finance for live prices, statements, ownership, or analyst data — logged and timed per call.
04 · Reason
The model grounds its answer strictly in tool output, never guessing figures it didn't retrieve.
05 · Stream
Tokens flow back over SSE into Thesys C1's generative-UI format — tables and charts materialise as they generate.
06 · Observe
Langfuse records the full trace — request span, nested generation, complete output — for debugging and evaluation.
AI layer
- LangGraph reasoning loop
- create_agent drives tool selection and multi-step reasoning with checkpointed conversation state.
- Anti-hallucination prompt
- System prompt mandates tool use before answering and forbids fabricating any financial figure.
- Generative UI model
- Thesys C1 streams structured UI components — not just text — which the React SDK renders natively.
Automation layer
- Sixteen logged data tools
- Uniform @tool wrappers around yfinance with timing logs and defensive error returns — one pattern, sixteen capabilities.
- Streaming SSE pipeline
- FastAPI pipes tokens with no-cache/keep-alive headers so long analyses render progressively.
- One-command deploys
- render.yaml ships the backend; vercel.json ships the frontend against a single env var.
Technical challenges
Financial LLM answers are confidently wrong whenever they come from training data instead of live markets.
Tool-first system contract: the agent must call data tools before answering and may only reason freely when no tool covers the question.
Users ask about companies, but every data API needs exact ticker symbols.
A dedicated ticker-resolution tool queries Yahoo's search API, letting the chain start from natural-language company names.
Market answers need structure — a table of holders or a price chart — not paragraphs of prose.
Streaming through Thesys C1's generative-UI endpoint turns the same token stream into native charts, tables, and cards client-side.
Outcome
- Natural-language questions about any listed company get current, source-grounded answers — no stale figures.
- Answers arrive as interactive visualisations rendered directly from the model stream, zero manual charting.
- Every agent decision and tool call is observable end-to-end in Langfuse traces.
Lessons learned
- “Grounding beats guardrails: forcing tool retrieval up front eliminates hallucinated numbers better than asking the model to be careful.”
- “Generative UI changes what an LLM product is — the stream isn't text to display, it's the interface itself.”
- “Thin, uniform tool wrappers with logging pay off immediately when tracing which data source slowed down or failed.”