An enterprise-grade, agentic financial analysis platform built on the Google Agent Development Kit (ADK) and Vertex AI. It automates period-over-period financial variance analysis (Revenue, Operating Income, Net Income), performs longitudinal thematic tracking across SEC 10-K filings, and renders interactive A2UI financial visualization surfaces with grounded citations.
- Orchestration: Google Agent Development Kit (ADK)
RootOrchestrator(agent/root_orchestrator.py) supervised byAppController(app/app_controller.py). - Hybrid RAG:
- Structured Datastore: Live GCP BigQuery (
sec_edgar_financials.financial_metrics) for verified financial facts. - Unstructured SEC Datastore: Vertex AI Search over official SEC 10-K filings (Item 7 MD&A and Item 1A Risk Factors) with 100% grounded citations.
- Structured Datastore: Live GCP BigQuery (
- Deterministic Math Engine: Native calculation engine (
agent/tools/calculation_engine.py) enforcing mathematical rigor and zero calculation hallucinations. - Generative UI (A2UI): Native synthesis of interactive JSON-based UI components (charts, summary cards, financial tables) rendered in frontend split-pane view.
- Enterprise Guardrails: Pre- and post-execution security with Model Armor for PII redaction, prompt injection defense, and Human-In-The-Loop (HITL) approval for GCS report exports.
- Observability: OpenTelemetry / Cloud Trace integration with structured JSON audit logging and BigQuery telemetry sink.
.
├── README.md
├── SPECIFICATION.md
├── AGENTS.md
├── Makefile
├── requirements.txt
├── .env.example
├── app/
│ ├── __init__.py
│ └── app_controller.py <- Web & Session Dispatch Controller
├── agent/
│ ├── __init__.py
│ ├── api.py <- FastAPI REST API & Web Server
│ ├── cli.py <- Interactive Command-Line Interface
│ ├── config.py <- Pydantic Settings & Environment Config
│ ├── constitution.py <- System Constitution & Tool Calling Directives
│ ├── root_orchestrator.py <- ADK Root Orchestrator (LlmAgent & Runner)
│ ├── guardrails/
│ │ └── model_armor.py <- Model Armor PII & Injection Filters
│ ├── memory/
│ │ └── session_store.py <- Persistent Multi-Turn Conversation Store
│ ├── observability/
│ │ ├── logging_config.py <- Structured JSON Logging
│ │ ├── telemetry_sink.py <- BigQuery Telemetry Sink
│ │ └── tracer.py <- OpenTelemetry Tracing
│ ├── rag/
│ │ ├── bigquery_store.py <- BigQuery Financial Metrics Client
│ │ ├── vertex_search.py <- Vertex AI Search Client
│ │ └── context_caching.py <- Gemini Context Cache Manager
│ ├── static/ <- Interactive Web App Frontend
│ ├── subagents/
│ │ └── search_subagent.py <- SEC 10-K Search Sub-Agent
│ └── tools/
│ └── calculation_engine.py <- Deterministic Variance Calculation Engine
├── eval/
│ ├── golden_dataset.json <- Audited Ground-Truth Evaluation Dataset
│ ├── generate_evalset.py <- ADK EvalSet Compiler
│ ├── run_adk_eval_parallel.py <- Parallel ADK Evaluation Runner
│ ├── test_eval_harness.py <- Core Unit & Integration Pytest Suite
│ ├── test_model_armor.py <- Security Guardrail Tests
│ ├── test_multi_thread_session.py <- Multi-Turn Session State Tests
│ ├── test_sec_corpus_rag.py <- RAG Grounding & Citation Tests
│ ├── test_telemetry_sink.py <- Observability Sink Tests
│ ├── evaluator.py <- Dual-Layer Eval Engine (Metrics & Scoring)
│ ├── metrics.py <- Deterministic Math, Recall & ROUGE Metrics
│ ├── mocks.py <- Thread-Safe SDK & Boundary Mocks
│ └── evalsets/
│ ├── test_config.json <- ADK 4-Pillar Evaluation Configuration
│ ├── sec_edgar_analyst_master.evalset.json
│ ├── multiturn_revenue_variance.evalset.json
│ └── capstone_demo.evalset.json
└── scripts/
├── audit_bigquery_against_sec.py <- SEC EDGAR XBRL Data Auditor
└── sync_bigquery_from_sec_edgar.py <- BigQuery Synchronization Tool
- Python 3.12+
- Google Cloud SDK (
gcloud) installed and authenticated:gcloud auth application-default login
- Access to GCP Project with Vertex AI and BigQuery APIs enabled.
Create a .env file from .env.example:
cp .env.example .envEnsure your .env contains:
GCP_PROJECT_ID=sec-analyst
GCP_REGION=us-central1
BIGQUERY_DATASET=sec_edgar_financials
BIGQUERY_TABLE=financial_metrics
VERTEX_SEARCH_DATASTORE_ID=sec-10k-filings-datastore
ORCHESTRATOR_MODEL=gemini-2.5-pro
SEARCH_MODEL=gemini-2.5-proActivate your virtual environment and install dependencies:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtLaunch the FastAPI server (serves both REST endpoints and the split-pane web UI):
PYTHONPATH=. uvicorn agent.api:app --host 0.0.0.0 --port 8080 --reload- Web UI: Navigate to
http://localhost:8080in your browser. - Swagger API Documentation: Navigate to
http://localhost:8080/docs.
Run a live multi-turn conversational session in your terminal:
PYTHONPATH=. python agent/cli.pyExample CLI Prompts:
- "Analyze Apple revenue 2023 vs 2022"
- "Why did revenue decrease in FY2023?"
- "Compare Microsoft and Nvidia operating income for 2024"
- "Explain Tesla's Item 1A Risk Factors disclosures for 2023"
The SEC EDGAR Natural Language Analyst evaluation pipeline implements Google ADK Multi-Pillar Evaluation across four distinct tiers:
- Deterministic Tool Trajectory (
tool_trajectory_avg_score): EvaluatesIN_ORDERexact tool invocations, argument matching, and zero hallucinated APIs. - Lexical Token Overlap (
response_match_score): Statistical ROUGE-1 F1 baseline measuring presence of essential financial tokens and company entities. - LLM-as-a-Judge Semantic Match (
final_response_match_v2): Evaluates semantic equivalence to golden reference answers viagemini-2.5-flash. - LLM-as-a-Judge Financial Rubrics (
rubric_based_final_response_quality_v1): Qualitatively scores Faithfulness, Numerical Precision, Completeness, and Conversational Isolation against strict SEC financial rubrics.
Execute the complete deterministic test harness across all 5 test modules (69 tests):
make test
# or: pytest eval/Run the 39-case master evaluation suite with configurable concurrency (-p 8):
make eval-mocked
# or: python eval/run_adk_eval_parallel.py --mode mocked -p 8make eval-live
# or: python eval/run_adk_eval_parallel.py --mode live -p 8python eval/run_adk_eval_parallel.py --mode live -p 4 --cases test_001_aapl_revenue,test_003_msft_revenue,test_017_edge_zero_prior_periodReports are automatically generated and saved by execution mode to eval/results/adk_parallel_eval_sec_edgar_analyst_master_v1_live.md and eval/results/adk_parallel_eval_sec_edgar_analyst_master_v1_mocked.md.
System latency and execution profiling are measured across multiple operational layers:
- Parallel Evaluation Profiling:
eval/run_adk_eval_parallel.pymeasures precise wall-clock latency per case, overall suite throughput, and breaks down timing across phase 1 (agent trajectory inference) and phase 2 (multi-pillar metric evaluation). The generated markdown scorecard includes a dedicatedLatency (s)column for every test case. - Distributed OpenTelemetry Spans:
agent/observability/tracer.pytraces root agent invocations, tool calling sub-spans, and SEC search roundtrips in Google Cloud Trace. - Production BigQuery Telemetry Sink:
agent/observability/telemetry_sink.pyasynchronously logs per-request token metrics (prompt tokens, response tokens, cached tokens), cache hit ratios, and millisecond latencies to BigQuery (sec_edgar_telemetry.telemetry_events).
Compare all structured BigQuery rows directly against official SEC EDGAR XBRL facts (data.sec.gov):
PYTHONPATH=. python scripts/audit_bigquery_against_sec.pyPopulate or update BigQuery with audited SEC EDGAR XBRL company facts:
PYTHONPATH=. python scripts/sync_bigquery_from_sec_edgar.pyGenerate canonical ADK-native .evalset.json files from golden_dataset.json:
PYTHONPATH=. python eval/generate_evalset.py