Custom AI Agents for Data Analytics: What It Takes to Build One That Works

General-purpose AI can produce a competent one-off analysis. Getting that quality of analysis every week, on live data your security team actually governs, is a different problem. A custom AI agent can make that work more reliable and repeatable when it's built with the right context, controls, and audit trail.
Key takeaways
- Large language models (LLMs) can return different outputs for the same prompt even when set to their most deterministic settings.
- Getting consistently reliable outputs often requires someone to paste schema, sample rows, and business context into the AI context window, outside the warehouse governance perimeter.
- A custom AI agent for data analytics can address the reliability problem. Once configured around your warehouse, metric definitions, and existing permissions, it can produce more consistent output, query in place under warehouse governance, and use a narrow toolset scoped to analytics tasks.
2 reasons general-purpose AI tools fall short on data analytics work
Reliable analytics work exposes two structural weaknesses in general-purpose AI assistants.
1. Ad hoc prompting isn't built for repeated analytics work
General-purpose AI assistants are optimized for one-shot answers. Repeated, deterministic analytics work is a different job, and the same prompt can return different SQL, different numbers, and different narrative on different days.
Model nondeterminism undermines repeatability, and warehouse complexity undermines accuracy. LLMs can return different outputs for identical prompts, even at temperature zero. GPT-4o scores 86.6% on academic text-to-SQL benchmarks and roughly 10% on Spider 2.0, a benchmark built from real enterprise warehouse workflows.
The vendor demo runs on the clean academic database, while your warehouse, with its 1,000-column tables and dialect quirks, is the other kind. And absent a governed semantic layer, a general assistant re-infers what "revenue" means on every prompt, which is why the same executive question can silently return a different answer next week.
2. Making general-purpose AI useful means exposing warehouse data outside your governance perimeter
The second structural problem shows up in what it takes to get a competent answer in the first place. Someone has to hand the assistant schema, sample rows, and business context, and once that data leaves the warehouse, so does the governance around it.
Employees frequently paste sensitive data into general-purpose AI tools, and once that happens, security teams can lose visibility into where the data went and how it may be used. Samsung banned generative AI tools company-wide in 2023 after an engineer uploaded internal source code to ChatGPT. A general assistant sits outside your row-level security, your audit trail, and your compliance perimeter, and a prompt alone doesn't bring those controls back.
The benefits of building a custom AI agent for data analytics
Configuring a custom agent is closer to defining the formulas behind a spreadsheet than training a model, and the potential payoff shows up in three places:
- A custom agent produces consistent, repeatable output. Context often drives accuracy more than model size. A custom agent can bake in technical metadata, governed metric definitions, and semantic context, so query generation runs against a fixed vocabulary reviewers can inspect and reproduce.
- Access to your own data stays governed. Agents that query in place run where governance already lives. On Databricks, permissions can be enforced through the connected user or agent context. Snowflake Cortex Analyst applies row access policies using the querying user's role.
- Purpose-built reasoning supports analytics tasks. General-purpose AI has to choose from a large, open-ended set of tools, and tool-selection accuracy tends to degrade as that pool grows. A custom analytics agent is scoped to a specific job and only needs to call a small, well-defined set of tools, which reduces the failure modes that bloated toolsets invite.
The benefits of building custom AI agents are real, but they don't come for free. Building custom AI agents the right way depends on four decisions: what data the agent can reach, how it reasons through a task, what it's allowed to do with the answer, and how you verify what it produces. The rest of this article walks through each one.
Scoping your AI agent's access to the right data
The first build decision is what data and systems the agent can reach. Unscoped access creates security and accuracy risk before the agent runs a single query.
Connect the agent to a defined, governed data source
Give the agent a purpose-built role scoped to the exact tables and schemas it needs, and route its queries through a governed data model rather than raw tables.
Raw tables carry sensitive fields the agent has no reason to touch, and undocumented column names invite the hallucinated join logic that produces wrong-but-plausible answers. Service accounts often accumulate privileges over time and get reviewed rarely, so reusing an analyst or developer role can hand the agent past over-grants it never needed.
Limit the data it can see
Broad read access expands the blast radius of any compromise. An attacker who takes over a broadly permissioned agent gets much of what the human behind it could reach.
Excessive permissions can increase the risk of sensitive information disclosure. Scope access to the current task, expire it when the task ends, and prefer short-lived credentials over standing API keys.
Choosing how your agent reasons and orchestrates its work
An analytics agent needs a layer that plans multi-step work, calls tools, and adapts when a query returns something unexpected. In from-scratch builds, this orchestration harness often becomes substantial engineering effort beyond the model and the prompts.
Multi-step reasoning and tool calling
Real analytical questions rarely resolve in one query, so the agent needs a loop that interleaves reasoning and action rather than a single-shot prompt.
In practice, the agent forms a plan, runs a query, reads the result, and revises the plan before acting again. When a query returns an empty set, the agent inspects the join it used, corrects the join, reruns the query, and returns the answer. Under the hood, this is a run loop that continues until an exit condition, such as a completed answer, an error, or a maximum number of turns, what the agent knows matters as much as how it loops. When an agent underperforms, the cause is often missing context, instructions, or tools rather than the model itself.
Handling errors and unexpected results
Production agents pair self-correction loops with hard limits, because unbounded retries are how a well-behaved agent can turn into an expensive one.
Queries fail, return empty sets, or return numbers that don't pass a sanity check. In the correction loop, a corrector step critiques and regenerates a failed query. Runaway loops can quickly drive costs above expectations, so retries need hard stops. Checkpoints matter too, because they let a run resume from the point of failure and skip an expensive multi-step rerun.
Defining the actions your agent is allowed to take
An agent's usefulness depends on what it can do beyond answering: query additional tables, write results back, or send a notification. Define that permission set explicitly. Left implicit, it defaults to whatever the underlying credential allows. Sigma exposes this through a defined set of agent actions.
Read-only vs. write-enabled actions
Read-only agents can still produce flawed analysis, but write-enabled agents can change operational systems, and the two risk profiles deserve separate treatment.
An agent that drafts variance commentary carries a different risk profile from one that writes a forecast scenario back. Writing deserves a staged path: start read-only, add proposal or draft actions, then narrow reversible writes, and reserve irreversible actions for explicit approval flows. Real-world incidents in which AI agents have taken destructive actions on production systems underscore why irreversible actions need effective human stops before they execute.
Human approval vs. autonomous execution
Autonomy comes in degrees, and where a given action sits on the ladder should follow how reversible it is and how big the blast radius could be.
A useful ladder runs from observe (read-only), to advise (recommendations only), to act with approval (a human confirms each write), to act autonomously within guardrails while humans review exceptions. Let the agent draft variance summaries autonomously, but require approval before it writes to a production table. Gate the approval upstream of the write, before it executes.
Setting guardrails and observability so the agent stays trustworthy
Access scoping and action permissions control what the agent can do. Trust also requires validating what it produces and recording what it did, or errors may surface only after they've done damage.
Validating outputs before they're trusted
One of the most dangerous failure modes is a query that executes cleanly and returns wrong numbers, invisible without domain expertise. Validation has to catch it before a business decision does.
Validation runs in stages: parse the generated SQL against the target dialect, reject queries that use unauthorized join paths, execute in a test environment before production, and compare results against expected outputs for known cases. Pair those structural checks with a second model scoring the answer, plus periodic human review to catch the semantic errors automation misses.
Logging and auditing every decision
If you can't reconstruct how the agent reached an answer, you can't defend it when someone challenges it.
Production agent actions should create agent audit logs that capture who initiated them and why. Record model calls, lookups, and tool executions in a run. That trace is what lets you reconstruct how the agent reached an answer when a stakeholder pushes back, and it's what helps demonstrate the agent followed policy when compliance asks.
How Sigma supports building custom AI agents
The infrastructure above (identity scoping, an orchestration harness, validation pipelines, and audit logging) is expensive to build from scratch, and many agent projects never reach production because of it.
Sigma is the runtime layer for building and scaling analytics, apps, and agents. It connects your cloud data warehouse to the AI systems that generate analyses from warehouse data. The artifacts they produce (workbooks, dashboards, AI Apps, and agents) become production-ready software that inherits your existing warehouse governance.
Instructions define what your agent does
An agent's instructions are a plain-English prompt describing its role and behavior. A builder who can write a spreadsheet formula can write them, with no framework code required. The person using the agent types a question into a chat element on the workbook canvas. A builder can specify behaviors like "ask follow-up questions if the user's input is vague" and can use dynamic text so the agent tailors output to context available in the workbook.
A support team might build a ticket-analysis agent scoped to ticket, account, and product-area tables. It flags a rising escalation rate on one product area and writes the weekly triage note back for the on-call manager.
Data access is inherited from warehouse security
You don't set up a separate permission model for the agent. It inherits the controls already in place, layered from the warehouse up through the workbook.
Five layers of governance apply automatically, stacking from the warehouse up through the individual agent:
- Warehouse governance. The underlying permissions, row-level security, and column-level security configured in your cloud data warehouse.
- Data model governance. Curated datasets and metric definitions that control how the underlying tables are exposed to builders and agents.
- Roles and permissions. Account-level controls that determine what each user can access and do inside Sigma.
- Workbook-level grants. Access to the workbook itself, where no workbook access means no agent access.
- In-agent scoping. The builder defines exactly which tables the agent can see and which it can write to.
The agent runs on your warehouse (Databricks, Snowflake, BigQuery, Amazon Redshift, and others) and routes AI through your configured model stack, including lab models like OpenAI or Gemini and warehouse-native options through Snowflake Cortex or Databricks.
Actions the agent can take, including writeback and approvals
A builder grants the agent a specific set of actions, so the permission set is explicit from the start rather than defaulting to whatever the underlying credential could reach.
Actions include writing results back to Input Tables, sending notifications, generating scenarios, and calling external systems through APIs. The audit trail on Input Tables records the original record, the new record, who changed it, and when. Writes go to Input Tables rather than overwriting original warehouse data. Autonomous agents can run on a schedule, so a user can open the workbook to a summary already written.
Sigma Assistant and Sigma Agents
Two Sigma capabilities matter here. Sigma Assistant is a single governed AI interface for analyzing warehouse data in plain language and building applications from natural language prompts. It validates queries before execution and keeps answers traceable to the underlying tables.
Sigma Agents is how you build the kind of custom analytics agent this article has described. A builder configures a workflow inside a workbook with its own instructions, its own scoped data access, and its own set of actions, and surfaces it to end users through a chat element on the workbook canvas.
Getting started with custom agents on Sigma
Building a custom analytics agent from scratch means setting up identity scoping, an orchestration harness, a validation pipeline, and an audit trail before you write your first useful prompt.
On Sigma, that infrastructure is provided through access scoping inherited from warehouse permissions, workflow configuration inside a workbook, governed execution on your warehouse, configured actions granted per agent, and Input Table auditing on every write.
Business teams get the speed of building on live warehouse data through a familiar spreadsheet interface, and IT keeps the guardrails because the agent inherits the warehouse security and audit trail already in place.
Get a demo or try Sigma free to see a custom agent running on your own warehouse data.


