Technical Walkthrough

Galileo: AI Marketing Agent with Observations & Evals

A professional, plain-English walkthrough of your real multi-agent codebase: framework choices, node-level graph flow, state behavior, tool usage, observability, and evaluation pipeline.

This multi-agent system is built to handle two real business workflows in one place: GTM product assistance and outreach content execution. It works by first routing each user request to the right specialist branch, then running branch-specific nodes that gather context, apply business gates (like pricing email verification or send approval), and return a final answer. Every step is traced with Galileo so you can inspect exactly what happened and evaluate quality over time.

LangGraph Supervisor Routing Agent + GTM + Outreach Qdrant + Gemini Embeddings Anthropic LLM Galileo Tracing + Evals
3Agent roles
9LangGraph nodes
4Core tools
17Eval prompts

Step 1: Architecture Overview

The assistant behaves like a small team with one coordinator and two specialists:

All branches use one shared state object, so every node updates the same request context consistently.

Step 2: Project Map (What Each File Does)

FileWhat it does
app.pyMain Streamlit entrypoint that boots the UI and wires sidebar + chat loop.
ui/ui.pyUI behavior: styles, upload widgets, chat history rendering, prompt handling, and trace display.
services/agent_service.pyService adapter for `ask()`, `load_graph_image()` (PNG), and `load_graph_ascii()` (fallback).
services/vector_db_service.pyThin service wrapper for adding docs/PDFs and checking vector DB counts.
agents/__init__.pyMain runtime API (`ask`), `get_graph_image()` (PNG), `get_graph_ascii()` (fallback when PNG fails).
agents/graph.pyDefines LangGraph nodes and all edges/conditional routes.
agents/state.pyShared `AgentState` schema and `steps` merge behavior across nodes.
agents/router_agent/nodes.pyIntent classification (`gtm` vs `outreach`) using LLM.
agents/gtm_agent/nodes.pyGTM branch: retrieve context, pricing gate, email gate, final GTM generation.
agents/outreach_agent/nodes.pyOutreach branch: research, draft generation, send gate, optional SendGrid send.
agents/tools.pyAll 4 tools: search_knowledge_base (Qdrant), web_search (DuckDuckGo), apollo_search (Apollo), send_email (SendGrid) + tool-calling loop.
vector_db/database.pyQdrant client setup, collection validation, add/search/count methods.
vector_db/chunker.pyText chunking and PDF extraction for indexing documents.
vector_db/embeddings.pyGemini embedding model factory used by vector store operations.
llm.pyAnthropic LLM loader with config/env validation.
config.pyCentral configuration and environment variable loading.
observability/galileo.pyGalileo SDK integration: init, callbacks, spans, sessions, logger helpers.
evals/run_galileo_evals.pyEvaluation harness with sessions mode, experiment mode, and coverage checks.
evals/README.mdEval-specific usage guide, criteria, and Galileo integration notes.
README.mdTop-level architecture, setup/run steps, and project navigation docs.

Step 3: Framework and Runtime Stack

LayerTechnologyHow it is used in this codebase
OrchestrationLangGraphNode graph in agents/graph.py with conditional edges for routing.
Generation LLMChatAnthropicUsed in supervisor routing, gates, and generation nodes via llm.py.
EmbeddingsGoogle Gemini EmbeddingsConverts knowledge docs into vectors for Qdrant retrieval.
Vector StoreQdrant CloudStores chunks and returns similarity-scored context for tool calls.
Web ResearchDuckDuckGoweb_search — live web for market/competitor context.
Leads + EmailApollo + SendGridapollo_search (leads by job/industry), send_email (outreach send path).
ObservabilityGalileoSpans, traces, sessions, and experiment logging.
UIStreamlitChat UX, graph preview (PNG with ASCII/Mermaid fallback), upload flow, and step trace display.

Step 4: Node Graph (Current Runtime)

Node (function) Edge (always) Branch (conditional)
START classify gtm_retrieve pricing_gate collect_email gtm_generate outreach_research outreach_generate send_gate outreach_send END gtm outreach not_pricing pricing valid no_email send review

The graph is tree-shaped from a single classifier root, with conditional branch points for pricing and send intent. The Streamlit UI shows PNG when available; falls back to ASCII or Mermaid if Mermaid.INK is unreachable.

Step 5: State Contract and How It Evolves

State fieldWho writes itPurposeTypical value
questionask()Original user request"What does Galileo cost?"
agent_typeclassifyBranch selectorgtm or outreach
contextgtm_retrieve / outreach_researchTool-generated evidence contextKB snippets, web notes, leads
is_pricingpricing_gateControls pricing branch behaviortrue / false
user_emailcollect_emailRequired for gated pricing outputritvik@dauji.ai
send_requestedsend_gateControls send vs review routingtrue / false
answergtm_generate / outreach_generate / outreach_sendFinal user-facing responseGenerated answer or send summary
stepsEvery nodeTrace log shown in UI and eval parsing["Supervisor Routing Agent -> GTM", "..."]

Step 6: Node-by-Node Execution Framework

GTM branch logic

  1. gtm_retrieve gathers internal + web context.
  2. pricing_gate decides if email verification is required.
  3. collect_email extracts/validates email from question text.
  4. gtm_generate composes final grounded answer.

Outreach branch logic

  1. outreach_research selects Apollo+KB or KB+web tool mix.
  2. outreach_generate drafts post/email content.
  3. send_gate resolves "send now" vs "review only".
  4. outreach_send performs SendGrid delivery if approved.

Step 6b: All 4 Tools

ToolBackendUsed byPurpose
search_knowledge_baseQdrantGTM, OutreachProduct docs from your indexed knowledge base
web_searchDuckDuckGoGTM, OutreachLive web for market/competitor/industry info
apollo_searchApollo.ioOutreachFind leads by job title, location, industry
send_emailSendGridOutreachDeliver personalized emails when user asks to send

Step 7: Galileo SDK (Tracing + Evaluations)

Tracing in app runtime

  • observability/galileo.py is the integration hub for initialization, callbacks, spans, and logger access.
  • ensure_galileo_initialized() connects project + log stream once.
  • get_langchain_config() injects GalileoCallback into LLM/tool invokes.
  • @log_span(...) decorates nodes/tools so every step is captured as a named span.
  • agents/__init__.py::ask() starts top-level trace (start_trace) and concludes/flushes it.
  • ui/ui.py starts one Galileo session per fresh chat thread.

Evaluation logging flow

  • evals/run_galileo_evals.py uses the same ask() runtime path (no eval/prod drift).
  • Sessions mode: each dataset row opens its own Galileo session via logger.start_session(...).
  • Experiment mode: uses galileo.experiments.run_experiment(...) for experiment tracking.
  • Expected tool coverage is inferred from trace steps and validated at run end.
  • Key env vars: GALILEO_API_KEY, GALILEO_PROJECT, GALILEO_LOG_STREAM.

Step 8: Examples (End-to-End Requests)

Example A - Pricing

User: "What does Galileo cost?"

Path: classify -> gtm_retrieve -> pricing_gate -> collect_email

Outcome: asks for verified email before full pricing details.

Example B - Content draft

User: "Write a LinkedIn post for AI platform teams."

Path: classify -> outreach_research -> outreach_generate -> send_gate(review)

Outcome: returns draft only, no email sent.

Example C - Send request

User: "Send this to ritvik@dauji.ai now."

Path: classify -> outreach_research -> outreach_generate -> send_gate(send) -> outreach_send

Outcome: sends via SendGrid and returns send status summary.

Step 10: Official Resource Links

ServiceWhy it is used hereLink
GalileoTracing, session logs, and experiment/eval trackingapp.galileo.ai
AnthropicPrimary chat model runtime for routing/generation logicconsole.anthropic.com
Google AI StudioAPI key source for Gemini embedding modelmakersuite.google.com/app/apikey
Qdrant CloudVector storage and semantic retrievalcloud.qdrant.io
LangGraphState graph orchestration and conditional routingLangGraph docs
StreamlitApplication UI and interactive chat viewdocs.streamlit.io
ApolloLead search and enrichment in outreach flowapollo.io
SendGridEmail delivery for approved send actionssendgrid.com