AI Agent + AlloyDB for Open-Ended Business Analytics
Challenge: The previous versions use pre-built analytical tools — each tool answers a fixed type of question. If a user asks something outside those 6-7 tool categories, the agent cannot answer. Real business questions are unpredictable and open-ended.
Solution: This version stores data in a database and lets the AI agent write custom SQL queries for every question. No fixed report menu — the agent converts plain English to SQL, executes it against AlloyDB, and returns the answer. Any question that can be answered with the data is fair game.
Ask any business question in plain English. The agent translates it into a SQL query, executes it against the database, and returns the answer — no SQL knowledge required from the user.
Every answer shows the full execution chain: question received, SQL query generated, database query executed, answer returned. Users can inspect exactly how their question was answered.
A status panel in the UI shows the database connection state, table name, total row count, and column count — confirming the agent has access to the full dataset.
Unlike the tool-based versions, there is no fixed set of report types. Users can ask any question the data can answer — from simple lookups to complex multi-condition analyses.
The agent handles multi-filter queries, date range comparisons, grouped aggregations, sorting, and nested conditions — matching what a human analyst would write in SQL.
The UI displays all available column names as tags, so users know exactly what data fields they can ask about — reducing guesswork and improving question quality.
Google ADK orchestrates the agent while Cloud SQL PostgreSQL (AlloyDB-compatible) serves as the data backend. The agent writes SQL dynamically based on user questions — no hardcoded queries.
Gemini handles both SQL generation and answer synthesis. It understands the table schema, writes correct SQL, and translates raw query results into plain-language business recommendations.
The agent is restricted to SELECT queries only. INSERT, UPDATE, DELETE, and DDL commands are blocked at the application layer — the database is read-only from the agent's perspective.
The agent is provided with the full table schema (column names, types) at startup. This enables accurate SQL generation without trial-and-error — the agent knows what columns exist before writing any query.