AI Agent for Self-Service Business Intelligence with Text-to-SQL
bgl · Finance · 2026 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.2 (schema v2)
Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.
Problem
Domain: Financial business intelligence
BGL needed business users to query complex compliance and financial data without depending on data teams or unreliable generic text-to-SQL.
Constraints:
- financial accuracy
- 400+ analytics tables
- regulated data
- secure execution sessions
Architecture
BGL built a governed text-to-SQL analytics agent on top of its existing Athena/dbt data platform. dbt and Athena prebuild business-ready analytic tables as a single source of truth. A Claude Agent SDK agent hosted on Amazon Bedrock AgentCore receives natural-language questions, loads project context from CLAUDE.md and product-domain skills from SKILL.md, discovers relevant table metadata, writes SELECT-only SQL, runs it in Athena, downloads CSV results from S3 into the AgentCore file system, and writes Python code for aggregations, filtering, and charts without stuffing large result sets into the model context.
Diagram confidence: explicit (topology described by the source).
flowchart LR business-user-interface[Business user interface] --> agentcore-claude-runtime[AgentCore Claude runtime] claude-project-context[CLAUDE project context] --> agentcore-claude-runtime skill-domain-modules[SKILL domain modules] --> agentcore-claude-runtime skill-domain-modules --> analytic-table-metadata[Analytic table metadata] agentcore-claude-runtime --> sql-security-validator[SQL security validator] sql-security-validator --> athena-query-engine[Athena query engine] analytic-table-metadata --> athena-query-engine athena-query-engine --> s3-result-store[S3 result store] s3-result-store --> python-code-executor[Python code executor] python-code-executor --> agentcore-claude-runtime
Components
| Component | Role | Interacts with |
|---|---|---|
Business user interface |
Slack or similar user-facing entry point for natural-language analytics questions. | AgentCore Claude runtime |
AgentCore Claude runtime |
Stateful hosted Claude Agent SDK session that orchestrates SQL generation, code execution, files, and responses. | Business user interface, CLAUDE project context, SKILL domain modules, SQL security validator, Athena query engine, Python code executor |
CLAUDE project context |
Global project instructions, folder layout, environment settings, and SQL execution guidance. | AgentCore Claude runtime |
SKILL domain modules |
Product-line domain expertise and table metadata loaded progressively on demand. | AgentCore Claude runtime, Analytic table metadata |
Analytic table metadata |
Schema, sample data, and statistics for business-ready Athena/dbt tables. | SKILL domain modules, Athena query engine |
SQL security validator |
Allows only SELECT queries and blocks destructive SQL operations. | AgentCore Claude runtime, Athena query engine |
Athena query engine |
Runs SQL over prebuilt analytic tables and stores results in S3. | SQL security validator, S3 result store |
S3 result store |
Stores query result CSV files for the agent to download. | Athena query engine, Python code executor |
Python code executor |
Processes CSV files, aggregates data, and generates charts or refined datasets inside the isolated session. | AgentCore Claude runtime, S3 result store |
Data flow
A business user asks an analytics question. The AgentCore-hosted Claude agent uses CLAUDE.md for project instructions and SKILL.md product files for domain expertise, discovers relevant analytic tables, generates a SQL SELECT query, passes it through a security validator, executes it in Athena over dbt-built tables, stores results in S3, downloads the CSV into the isolated AgentCore session, then writes Python to process and visualize results before responding.
5 supporting quotes
Why this architecture
BGL explicitly avoided making the agent reason over raw schemas and business logic. The data platform handles joins, aggregations, and business rules deterministically, leaving the agent to translate questions into reliable SELECTs and code. Code execution was chosen because analytics outputs can be thousands of rows or megabytes, which would overwhelm an LLM context window if passed through ordinary tool calls.
3 supporting quotes
Models used: Claude · Claude Agent SDK · Amazon Bedrock foundation model hosting
Scale
- BGL serves more than 12,700 businesses across 15 countries.“serving over 12,700 businesses across 15 countries. BGL’s solution processes complex compliance and financial data through over 400 analytics tables”article, stated
- The data platform has more than 400 analytics tables across business domains.“BGL’s solution processes complex compliance and financial data through over 400 analytics tables, each representing a specific business domain”article, stated
- AgentCore sessions can persist state for up to eight hours.“Stateful execution session: AgentCore maintains session state for up to 8 hours.”article, stated
- The capability changes analytics access for more than 200 BGL employees.“For BGL’s more than 200 employees, this represents a significant shift in how they extract business intelligence.”article, stated
Alternatives considered (roads not taken)
Let the agent handle raw schemas, transformations, business logic, and result interpretation
Rejected because: BGL calls this an anti-pattern that leads to inconsistent joins, missed edge cases, and incorrect aggregations.
Pass large query results directly into the model context through tools/MCP
Rejected because: BGL uses SQL plus Python-on-files because large result sets can exceed context limits.
Stateless agent hosting without per-session isolation
Rejected because: Financial-services analytics needs isolated state, credentials, and compliance-aligned execution sessions.
Patterns
tool-use-orchestration (analytics)
The agent executes SQL/code against curated analytics tables rather than trying to infer all business logic from raw schemas.
safety-policy-enforcement (security)
AgentCore stateful sessions provide security isolation for production data analysis.
Tradeoffs
Where to put business logic.
Chose curated dbt/Athena data foundation over agent improvisation over raw data.
Rationale: BGL sacrificed some genericity to gain consistent, governed answers for business users.
Data-platform responsibility boundary.
Chose dbt/Athena business-ready tables as the source of truth over agent improvisation over raw business data.
Rationale: Validated transformations and metrics keep business logic deterministic while the agent focuses on query interpretation and result processing.
Large-result processing strategy.
Chose SQL to Athena plus Python over CSV files over putting retrieved rows directly into the LLM context window.
Rationale: File-based code execution handles thousands of rows or megabytes without exhausting tokens.
Gotchas (what bit them)
Letting the agent handle raw schema interpretation is an anti-pattern.
Root cause: Agents can join tables incorrectly, miss edge cases, and produce wrong aggregations in regulated BI.
Resolution: Build aggregated, denormalized, business-ready tables as a single source of truth before adding the agent.
Evaluation
The case reports adoption and productivity outcomes rather than a public benchmark.
Metrics: 200+ employees · business self-service · reduced data-team dependency
Outcomes
- Business users can self-serve analytics through natural language over curated financial data.
AWS co-authored customer story; results are customer-reported.