LLM orchestration, grounding and structured output
AI Financial Analyst Agent
An agent built around one constraint: the figures should come from a tool call or a retrieved document. It takes a natural-language question, chooses which tools to call and returns a structured investment analysis.
The problem
Ask a language model for an investment analysis and it will produce one. The figures inside it may be invented, stale or attached to the wrong company, and in a financial context a wrong number is the whole problem.
The design goal was therefore narrower than “an AI analyst”: every number in the output should come from a tool call or a retrieved document, and every answer should arrive in a shape the rest of the system can use.
What I built
The agent is built on a multi-step orchestration pipeline: it chooses the tools a question needs, runs them against live financial and web data, and passes a structured JSON object from one stage to the next. Model routing and prompt chaining are the plumbing; the report is generated from the JSON fields the pipeline assembles.
- Tool calling against live financial and web APIs, so figures are fetched rather than recalled.
- Grounding: tool calls against live APIs and retrieval from source documents, aimed at reducing hallucination of financial figures.
- Model routing: different steps are sent to different models according to the job they are doing.
- Prompt chaining across the analysis steps, with structured JSON outputs between them.
- Automated report generation from the structured result, rather than free text.
Why the output is a schema
A paragraph of analysis is hard to verify and hard to reuse. A JSON object with named fields can be validated, compared across runs, rendered into a report, and checked field by field against the tool output that produced it.
The pipeline ends in a schema because each stage then has an input and an output that can be inspected on its own, so the agent can be tested stage by stage.
What it demonstrates
- Agent design: deciding when to call a tool, which tool, and what to do with the result.
- Grounding as a deliberate constraint on the model, not a prompt instruction.
- Structured outputs as the contract between pipeline stages.
- Orchestration across models and steps rather than a single large prompt.
Limits and next steps
The agent is only as good as the APIs behind it. Rate limits, missing tickers and stale endpoints all degrade the analysis, and the current design has no formal evaluation of factual accuracy against a reference set.
It is a personal engineering project and not investment advice. The next version would add an evaluation harness that scores the grounded fields against source data, and a caching layer so repeated queries do not re-fetch the same figures.