How to Integrate LlamaIndex for investment banking with Supabase for multi-agent systems

By Cyprian AaronsUpdated 2026-04-21
llamaindex-for-investment-bankingsupabasemulti-agent-systems

Combining LlamaIndex for investment banking with Supabase gives you a clean pattern for building agent systems that can retrieve deal docs, store shared state, and coordinate multiple specialized agents without wiring everything together by hand. The practical win is simple: one layer handles financial document retrieval and reasoning, the other gives you persistent Postgres-backed memory, message passing, and task state for the agent swarm.

Prerequisites

  • Python 3.10+
  • A Supabase project with:
    • project URL
    • anon key or service role key
    • a Postgres database you can write to
  • A LlamaIndex setup for your investment banking knowledge base
    • SEC filings, CIMs, pitch decks, earnings transcripts, or internal deal notes
  • Installed packages:
    • llama-index
    • llama-index-vector-stores-supabase if you want vector retrieval in Supabase
    • supabase
    • python-dotenv
  • An embeddings provider configured for LlamaIndex
  • Optional but useful:
    • pgvector enabled in Supabase
    • a table for agent messages/state

Integration Steps

1) Install dependencies and load environment variables

Start by setting up both SDKs in the same Python project. Keep secrets in environment variables; don’t hardcode keys in notebooks or agent workers.

pip install llama-index supabase python-dotenv llama-index-vector-stores-supabase
import os
from dotenv import load_dotenv

load_dotenv()

SUPABASE_URL = os.getenv("SUPABASE_URL")
SUPABASE_KEY = os.getenv("SUPABASE_SERVICE_ROLE_KEY")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

2) Connect LlamaIndex to your investment banking corpus

For investment banking workflows, you usually want a retriever over filings, models, transcripts, and internal memos. LlamaIndex gives you the ingestion + retrieval layer; here we wire it to a local folder first so you can validate the pipeline before moving storage into Supabase.

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.embeddings.openai import OpenAIEmbedding

Settings.embed_model = OpenAIEmbedding(api_key=OPENAI_API_KEY)

docs = SimpleDirectoryReader("./banking_docs").load_data()
index = VectorStoreIndex.from_documents(docs)
query_engine = index.as_query_engine(similarity_top_k=5)

response = query_engine.query("Summarize the revenue drivers and key risks in this target company.")
print(response)

If you already have documents chunked and stored elsewhere, swap SimpleDirectoryReader for your own loader. The important part is that your agent can now ask structured questions over banking content instead of searching raw files.

3) Create a Supabase client for shared agent state

Supabase is where the multi-agent system gets coordination primitives. Use it for conversation history, task queues, extracted entities, or intermediate outputs between agents.

from supabase import create_client, Client

supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)

# Example table: agent_messages(id, session_id, agent_name, role, content)
payload = {
    "session_id": "deal-2024-001",
    "agent_name": "research_agent",
    "role": "assistant",
    "content": "Target company shows strong EBITDA growth but margin pressure in H2."
}

result = supabase.table("agent_messages").insert(payload).execute()
print(result.data)

Use a table like this to let one agent publish findings and another consume them later. That keeps your orchestration stateless at the application layer and durable at the database layer.

4) Store retrieved banking insights back into Supabase

This is where the two tools start working as one system. LlamaIndex handles retrieval and summarization; Supabase stores the result so downstream agents can reuse it without re-querying the corpus.

question = "What are the main diligence risks mentioned across the latest filings?"
answer = query_engine.query(question)

insight_row = {
    "session_id": "deal-2024-001",
    "agent_name": "research_agent",
    "role": "assistant",
    "content": str(answer),
}

supabase.table("agent_messages").insert(insight_row).execute()

In production, add metadata columns like source_doc, chunk_id, confidence, and deal_id. That makes it easier to audit why an agent produced a recommendation.

5) Let another agent read from Supabase and continue the workflow

A multi-agent system needs handoffs. One agent can retrieve market or deal intelligence from Supabase and feed it into a second agent that drafts an IC memo or generates follow-up questions.

messages = (
    supabase.table("agent_messages")
    .select("*")
    .eq("session_id", "deal-2024-001")
    .order("created_at", desc=False)
    .execute()
)

context_lines = [
    f"{row['agent_name']}: {row['content']}"
    for row in messages.data
]

prompt = "\n".join(context_lines) + "\n\nDraft follow-up diligence questions for management."
follow_up_response = query_engine.query(prompt)

print(follow_up_response)

This pattern works well when each agent has a narrow job:

  • research agent retrieves facts
  • risk agent checks assumptions
  • memo agent writes output
  • supervisor agent decides next action

Testing the Integration

Run a simple end-to-end check: query investment banking docs through LlamaIndex, persist the result in Supabase, then read it back.

test_question = "List three valuation concerns from the target's latest quarterly report."
test_answer = query_engine.query(test_question)

supabase.table("agent_messages").insert({
    "session_id": "smoke-test",
    "agent_name": "test_agent",
    "role": "assistant",
    "content": str(test_answer),
}).execute()

rows = (
    supabase.table("agent_messages")
    .select("*")
    .eq("session_id", "smoke-test")
    .execute()
)

print(rows.data[-1]["content"])

Expected output:

The target shows...
1. Revenue concentration risk...
2. Margin compression...
3. Working capital pressure...

If that round-trip works, your retrieval layer and persistence layer are connected correctly.

Real-World Use Cases

  • Deal diligence copilot

    • One agent reads CIMs and filings with LlamaIndex.
    • Another stores extracted risks in Supabase.
    • A third builds an IC-ready diligence checklist from prior sessions.
  • Multi-agent research desk

    • Research agents pull from transcripts and filings.
    • A synthesis agent merges outputs stored in Supabase.
    • A supervisor agent tracks which questions are still open.
  • Banking memo generation

    • Agents gather comps data, summarize management commentary, and flag anomalies.
    • Supabase keeps versioned notes per deal team.
    • LlamaIndex provides grounded answers from source documents instead of free-form generation.

The main design rule here is straightforward: use LlamaIndex for retrieval over financial content, use Supabase for durable coordination between agents. That separation keeps your system auditable enough for banking workflows and flexible enough to scale beyond a single chatbot.


Keep learning

By Cyprian Aarons, AI Consultant at Topiax.

Want the complete 8-step roadmap?

Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.

Get the Starter Kit

Related Guides