Build a multi-agent financial analysis team with LangDB and Agno that can reason, research, and report on complex financial data.
In the world of finance, staying ahead requires more than just data; it requires deep analysis, contextual awareness, and collaborative reasoning. What if you could build a team of AI agents to do this for you? In this post, we'll show you how to build a sophisticated, multi-agent financial analysis team using LangDB and Agno.
TL;DR:
This guide walks you through building a multi-agent workflow using Agno for orchestration and LangDB as the AI Gateway. We'll use a financial analysis team as a practical example to show how you can build sophisticated agent systems that are easy to manage and debug, thanks to LangDB's end-to-end tracing, dynamic tooling, and access to over 350 LLMs.
This team of agents collaborates to deliver in-depth insights on publicly traded companies by combining web research for market sentiment with hard financial data analysis. You can see a full trace of the final agent's execution.
The Code
You can find the complete source code for this project on GitHub:
- LangDB Samples: https://github.com/langdb/langdb-samples/tree/main/examples/agno/reasoning-finance-team
The Architecture: A Trio of Financial Experts
Our system is composed of two specialist agents orchestrated by a coordinating team:
Web Search Agent: Gathers the latest news and market sentiment from the internet.
Finance Agent: Equipped with
YFinanceTools
to fetch and analyze quantitative stock data, including pricing, fundamentals, and analyst recommendations.Reasoning Finance Team: A coordinator that directs the two agents, synthesizes their findings, and produces a final, comprehensive report.
LangDB provides the backbone for this system. As an AI Gateway, it enables seamless access to over 350 LLMs, simplifies tool integration, and provides full end-to-end tracing and observability into each agent's actions and the team's collaborative process.
Checkout: https://docs.agno.com/models/langdb and https://docs.agno.com/observability/langdb
Enhanced Tracing with pylangdb.agno.init()
While you can use LangDB as a provider in Agno directly, calling pylangdb.agno.init()
unlocks deeper, end-to-end tracing. This function provides additional metadata and observability by automatically instrumenting the entire Agno framework, giving you complete visibility into your agent's workflows.
# main.py
from pylangdb.agno import init
# Initialize LangDB for enhanced tracing *before* importing any Agno modules.
init()
from agno.agent import Agent
from agno.team import Team
# ... other imports
As an official provider integrated with Agno, LangDB requires you to set up your credentials. You'll need to export your LangDB API key and Project ID as environment variables. You can find these in your LangDB project settings.
export LANGDB_API_KEY="<your_langdb_api_key>"
export LANGDB_PROJECT_ID="<your_langdb_project_id>"
Code Walkthrough: Building the Team
Let's look at how the agents and the team are defined.
The Web Search Agent: Decoupled and Dynamic
Instead of hard-coding a search tool, we assign the web_agent
a LangDB Virtual Model. This decouples the agent's logic from the specific tools it uses.
web_agent = Agent(
name="Web Search Agent",
role="Search the web for the information",
model=LangDB(id="langdb/search_agent_xmf4v5jk"),
instructions="Always include sources"
)
This virtual model is configured in the LangDB UI to provide search capabilities, which we'll cover in the next section.
The Finance Agent: The Quantitative Analyst
This agent is equipped with YFinanceTools
to access a wide range of financial data. It's powered by a powerful model like Grok-4 and has specific instructions to format its output professionally.
finance_agent = Agent(
name="Finance AI Agent",
role="Analyse the given stock",
model=LangDB(id="xai/grok-4"),
tools=[YFinanceTools(
stock_price=True,
stock_fundamentals=True,
analyst_recommendations=True,
company_info=True,
company_news=True
)],
instructions=[
"Use tables to display stock prices, fundamentals (P/E, Market Cap), and recommendations.",
"Clearly state the company name and ticker symbol.",
"Focus on delivering actionable financial insights."
]
)
The Coordinating Team: The Orchestrator
The ReasoningFinanceTeam
orchestrates the two specialist agents. It operates in coordinate
mode, allowing it to delegate tasks, synthesize information, and ensure the final output is a comprehensive report.
reasoning_finance_team = Team(
name="Reasoning Finance Team",
mode="coordinate",
model=LangDB(id="xai/grok-4"),
members=[web_agent, finance_agent],
tools=[ReasoningTools(add_instructions=True)],
instructions=[
"Collaborate to provide comprehensive financial and investment insights",
"Consider both fundamental analysis and market sentiment",
"Present findings in a structured, easy-to-follow format",
],
success_criteria="The team has provided a complete financial analysis with data, visualizations, risk assessment, and actionable investment recommendations."
)
Dynamic Tooling with Virtual Models and Virtual MCPs
To empower the web_agent
with live web search capabilities without hard-coding tools, we configure a Virtual Model in LangDB. This model is backed by a Virtual MCP Server that provides the actual search functionality.
Create a Virtual MCP Server: In the LangDB UI, create a new Virtual MCP Server named
web-search-mcp
that uses the Tavily Search MCP.Create and Configure the Virtual Model: Create a new virtual model (e.g.,
search-agent
) and attach theweb-search-mcp
to it.Use the Virtual Model ID: Copy the ID of your new virtual model and use it in the
web_agent
definition.
This setup allows you to change the tools and models your agents use on the fly from the LangDB UI, without changing a single line of code.
Running the Team and Observing the Results
To run the team, simply call the print_response
method with a detailed prompt:
reasoning_finance_team.print_response(
"""Compare the tech sector giants (AAPL, GOOGL, MSFT) performance:\n
1. Get financial data for all three companies\n
2. Analyze recent news affecting the tech sector\n
3. Calculate comparative metrics and correlations\n
4. Recommend portfolio allocation weights"""
)
Every execution is captured in LangDB, providing a complete trace of the team's operations. This includes the initial prompt, each agent's contributions, the tools they used, and the final synthesized output. You can explore the full, shareable trace.
Here is a snippet of the final report generated by the agent team:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Comprehensive Comparative Analysis of Tech Giants: AAPL, GOOGL, and MSFT ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
As the Reasoning Finance Team, we've conducted a thorough analysis of Apple Inc. (AAPL), Alphabet Inc. (GOOGL), and Microsoft Corporation (MSFT) based on the user's request. This includes financial data retrieval, recent news analysis, comparative metrics and correlations, and portfolio allocation recommendations. Our evaluation incorporates fundamental analysis (e.g., valuations, growth), market sentiment (e.g., news and analyst views), quantitative metrics (e.g., betas, correlations), and risk assessments. Data is current as of July 2025.
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1. Financial Data Overview
Key financial data for each company, sourced from reliable APIs.
Stock Prices
Metric AAPL GOOGL MSFT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Current Price $210.16 $182.97 $505.62
52-Week High $260.10 $207.05 $508.30
52-Week Low $169.21 $140.53 $344.79
50-Day Moving Avg $203.87 $170.88 $472.41
200-Day Moving Avg $222.55 $173.43 $427.18
And here's a view of the full trace in the LangDB UI, showing how the agents collaborated to produce the report.
Full Observability with LangDB Tracing
The "full observability" promised in our subtitle is delivered through LangDB's detailed tracing capabilities. When you run your Agno team, every action is captured, providing a transparent, hierarchical view of the entire workflow. Here’s what you can see in the trace:
Hierarchical Span View: The trace isn't a flat list of events but a tree of "spans." The top-level span represents the entire team's execution, with child spans for each agent's turn, tool call, and model invocation. This shows the exact flow of control and delegation.
Input/Output for Each Step: For every span, you can inspect the exact inputs and outputs. This means you can see the precise query sent to the
Web Search Agent
, the articles it returned, the data requested by theFinance Agent
, and the final synthesized response from the team. This level of detail is crucial for debugging.Latency and Performance: Each span is timestamped and includes latency information, allowing you to instantly identify bottlenecks. You can see exactly how long each tool call, model response, or agent deliberation took.
Cost and Token Usage: For every LLM call, the trace displays the number of input and output tokens and the associated cost, giving you full transparency into your operational expenses.
Automatic Metadata: Thanks to
pylangdb.agno.init()
, traces are automatically enriched with metadata, including agent names, the team name (Reasoning Finance Team
), and the models used, making it easy to filter and search for specific traces in the LangDB UI.
This granular, end-to-end visibility is what makes building, debugging, and managing complex agentic workflows with LangDB and Agno so powerful.
You can check out the full conversation with tracing here: https://app.langdb.ai/sharing/threads/630b2ded-15ae-43d9-8a7a-d6dd9d649655
Conclusion
By combining Agno with the LangDB AI Gateway, we've built a financial analysis team that is:
Modular: Each agent has a specific, firewalled responsibility.
Dynamic: We can change models and grant new tools on the fly from the LangDB UI without redeploying our agent.
Observable: We get detailed traces of every interaction, making debugging and performance analysis straightforward.
This architecture allows for rapid development and iteration, enabling you to build truly powerful and intelligent agentic systems for any domain.
Ready to build your own? Start building for free on LangDB or Explore Agno to orchestrate your agent workflows.