Production Deployment of Toqan Data Analyst Agent: From Prototype to Production Scale

toqan · Tech · year n/a · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.6 (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: Natural-language data analysis over customer databases

Toqan needed to turn a demo-friendly data analyst agent into a production system that could translate English questions into SQL, execute them, and return reliable answers/visualizations for hundreds of partner users.

Constraints:

Architecture

The Toqan Data Analyst accepts a natural-language question, runs deterministic preprocessing to decide whether the question is answerable, retrieves relevant schema/documentation, generates SQL, validates referenced columns, executes queries, and returns tabular/visualized answers. Production hardening adds expert-maintained documentation pipelines, hard and soft limits against loops, smarter schema retrieval, SQL-executor self-correction for context-independent errors, custom model routing, limited database credentials, and case-by-case deployment security.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  user-question-interface["User question interface"] --> preprocessing-gate["Preprocessing gate"]
  preprocessing-gate["Preprocessing gate"] --> data-analyst-agent["Data analyst agent"]
  data-analyst-agent["Data analyst agent"] --> schema-retrieval-tool["Schema retrieval tool"]
  data-analyst-agent["Data analyst agent"] --> sql-generator["SQL generator"]
  data-analyst-agent["Data analyst agent"] --> hard-and-soft-limit-controller["Hard and soft limit controller"]
  schema-retrieval-tool["Schema retrieval tool"] --> expert-documentation-pipeline["Expert documentation pipeline"]
  sql-generator["SQL generator"] --> schema-validation-check["Schema validation check"]
  schema-validation-check["Schema validation check"] --> sql-executor["SQL executor"]
  sql-executor["SQL executor"] --> customer-database["Customer database"]
  sql-executor["SQL executor"] --> user-question-interface["User question interface"]
  model-routing-layer["Model routing layer"] --> data-analyst-agent["Data analyst agent"]
  model-routing-layer["Model routing layer"] --> sql-generator["SQL generator"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
User question interface Receives English business questions and presents answers or visualizations. Preprocessing gate
Preprocessing gate Determines whether a question is answerable from available context before invoking the main agent. User question interface, Data analyst agent
Data analyst agent Plans SQL-based analysis using schema context and tools. Preprocessing gate, Schema retrieval tool, SQL generator, Hard and soft limit controller
Schema retrieval tool Retrieves relevant documentation and schema context for the agent. Data analyst agent, Expert documentation pipeline
SQL generator Produces SQL candidate queries from the question and schema context. Data analyst agent, Schema validation check
Schema validation check Validates referenced columns against documented schema before query execution. SQL generator, SQL executor
SQL executor Executes validated queries and can self-correct simple dialect errors. Schema validation check, Customer database, User question interface
Customer database Partner database accessed with limited credentials. SQL executor
Expert documentation pipeline UI/pipeline for data experts to update agent-oriented documentation directly. Schema retrieval tool
Hard and soft limit controller Combines stop rules/timeouts/tool-count limits with behavioral nudges. Data analyst agent
Model routing layer Chooses smaller or larger OpenAI models by tool complexity and cost. Data analyst agent, SQL generator

Data flow

A user asks a business question in English. A preprocessing step checks whether the question can be answered from available context and requests clarification for vague inputs. The agent retrieves concentrated schema documentation, generates SQL, validates columns before execution, sends safe queries to a SQL executor, lets the executor repair simple dialect errors where possible, and returns results with optional visualizations. Expert-facing UIs keep documentation optimized for agent consumption.

3 supporting quotes
“The Toqan Data Analyst is a specialized agent that allows users to ask questions in natural language (English) and receive answers by automatically translating questions into SQL queries, executing them against user databases, and presenting results with optional visualizations.”summary, stated
“Their solution was implementing a "pre-processing step" that evaluates the question in isolation, before the agent attempts to solve it.”summary, stated
“Another predictable failure mode was the agent generating SQL that referenced non-existent columns.”summary, stated

Why this architecture

Toqan’s central lesson is that AI-first does not mean AI-only. Predictable behavior is enforced with deterministic checks, domain knowledge is maintained by experts, limits keep agents from looping while preserving useful self-correction, and smarter tools reduce cognitive load on the main agent.

3 supporting quotes
“One of the most significant insights is that not all problems require the full flexibility of agentic reasoning.”summary, stated
“The solution was creating pipelines and UIs that allow data experts to directly update their documentation without ML team intervention.”summary, stated
“The presentation concludes with an important philosophical point: building AI-first products doesn't mean using AI for everything.”summary, stated

Models used: OpenAI models · GPT-4-mini · o1 · GPT-4 Turbo

Scale

Alternatives considered (roads not taken)

Let the agent answer vague questions directly

Rejected because: The LLM produced confident but inconsistent answers when context was insufficient.

“when users asked vague questions, the LLM would confidently produce answers—even when it didn't have enough context to do so correctly.”summary, stated

Wait for database errors after bad SQL

Rejected because: Pre-validating columns avoids wasted cycles and user-system load.

“Rather than waiting for the query to fail against the actual database (which wastes cycles and puts unnecessary load on user systems), they implemented a deterministic check after query generation”summary, stated

One-off domain knowledge transfer to ML engineers

Rejected because: ML engineers could not generalize across highly specific domain problems without expert-owned documentation loops.

“This approach proved inadequate because the ML engineers weren't domain experts.”summary, stated

Use existing agent frameworks as the core

Rejected because: Toqan had invested in a custom framework that scaled for its requests/users and preserved flexibility.

“Their framework is tested and scales in terms of requests and users”summary, stated

Patterns

tool-use-orchestration (agent architecture)

The analyst agent uses schema retrieval, SQL generation, validation, and execution tools rather than a single prompt.

“The tools available to an agent significantly impact its performance, and tool optimization is a powerful lever for improving overall system behavior.”summary, stated

safety-policy-enforcement (production control)

Deterministic preprocessing and schema validation prevent predictable bad actions before database execution.

“LLM-generated content can and should be evaluated using traditional functional programming approaches before being applied to the outside world.”summary, stated

human-in-the-loop-gate (domain operations)

Data experts directly maintain agent documentation through pipelines/UIs.

“creating pipelines and UIs that allow data experts to directly update their documentation without ML team intervention.”summary, stated

fallback-degradation (resilience)

Hard limits stop runaway loops while soft nudges preserve useful self-correction.

“The key insight is balancing hard limits (strict rules about when the agent must stop) with soft limits (nudges that guide the agent in the right direction without removing creative problem-solving capability).”summary, stated

model-routing (model operations)

Different models are selected by task complexity and cost.

“The team uses multiple models across the pipeline, primarily OpenAI models but with different models for different components:”summary, stated

context-engineering (tool/context design)

Schema retrieval filters documentation to concentrate relevant context and reduce distraction.

“Better schema filtering means the agent receives concentrated, relevant information. It can't get distracted by irrelevant information, and doesn't have to parse through large contexts for what it needs. This reduces complexity and effort for the main agent.”summary, stated

Tradeoffs

Where to use AI

Chose AI plus deterministic workflows over LLM reasoning for every behavior.

Rationale: Predictable problems are better solved with hard-coded checks and functional validation.

“One of the most significant insights is that not all problems require the full flexibility of agentic reasoning. When behavior is required and predictable, it can and should be hard-coded through deterministic workflows.”summary, stated

Limit design

Chose Hard limits plus soft nudges over Only strict stop rules or only unconstrained creativity.

Rationale: Hard limits prevent runaway behavior while soft limits preserve creative problem solving.

“Hard limits prevent infinite loops and runaway behavior. Soft limits preserve the agent's ability to self-correct and solve problems creatively”summary, stated

SQL error repair

Chose Let SQL executor handle common context-independent errors over Returning every error to the main agent.

Rationale: Routine dialect fixes do not need full agent context and would clutter the main loop.

“Early SQL errors (like date function syntax when moving between SQL dialects) don't require full agent context to fix.”summary, stated

Framework strategy

Chose Custom agentic framework over Adopting existing frameworks wholesale.

Rationale: Existing frameworks were immature when Toqan started and the custom system already scaled for requests/users.

“The team developed their own agentic framework rather than using existing options. While they experimented with frameworks early on (and continue to explore options like Swarm for educational purposes), several factors led them to build custom:”summary, stated

Gotchas (what bit them)

Demo behavior did not survive production.

Root cause: Agents looped, hallucinated schema, ignored stop commands, and produced inconsistent answers under real user behavior.

Resolution: Add deterministic gates, validation, expert curation, and hard/soft limits.

“while agents can appear "magical" in demos, getting them to work reliably in production is a fundamentally different challenge.”summary, stated

Schema hallucination created unsafe SQL.

Root cause: The LLM inferred columns that seemed plausible but did not exist.

Resolution: Validate generated SQL against documented schema before execution.

“• Generating SQL with non-existent columns based on hallucinated schema information”summary, stated

Expert knowledge could not be delegated once to ML engineers.

Root cause: Use-case-specific schema/documentation details varied too much.

Resolution: Give experts ongoing tools to update documentation directly.

“This approach proved inadequate because the ML engineers weren't domain experts. They couldn't make general solutions for highly specific problems that varied across use cases. The knowledge gap was too significant.”summary, stated

Unexpected user behavior can trigger abuse or loops.

Root cause: Testing with stakeholders does not cover real users unfamiliar with development assumptions.

Resolution: Combine hard limits with liberal input acceptance and learn from boundary-pushing queries.

“Once deployed to users who hadn't been involved in development but were familiar with the broader Toqan platform, entirely unexpected queries emerged—including some abuse cases.”summary, stated

Evaluation

Toqan validates predictable failures functionally before execution, relies on expert-maintained documentation/test loops, and optimizes for precision because business users make decisions from outputs.

Metrics: SQL schema validity · tool-call counts · execution timeouts · precision · user adoption · query correctness

“This pre-validation approach allows them to immediately begin problem-solving when issues are detected, rather than burning through multiple agent cycles trying to self-correct after database errors.”summary, stated
“They optimize for precision because users make business decisions based on the outputs, so the cost of errors is high”summary, stated

Outcomes

The summary reports hundreds of users across iFood, Gloovo, and OLX, six months of deployment lessons, and one repeated-answer failure at 58-59 iterations.

“The result was successful adoption across hundreds of users at development partners including iFood, Gloovo, and OLX.”summary, stated
“The team had to bridge the gap from a frequently failing product to one with genuine user adoption, which they demonstrate through usage metrics shared in the presentation.”summary, stated