Building Data Agents with In-Domain Data: Architecture Routes and Selection Practices

    As LLM-powered Data Agents make natural-language data queries and automated reporting possible, enterprises are shifting their focus from "can it be done" to "is it safe and trustworthy to use." This article examines three technical routes for building Data Agents under strict data-sovereignty requirements—upgrading existing enterprise BI systems in place, privately deploying open-source orchestration frameworks, and using cloud-based integrated AI services—and compares them across deployment model, data boundary, and trustworthiness. It explains why NL2DSL with a semantic layer and deterministic execution engine is more reliable than raw NL2SQL, and offers a five-dimension evaluation framework for selecting the right approach.

    Building Data Agents with In-Domain Data: Architecture Routes and Selection Practices

    1. From “Can It Be Done?” to “Can We Trust It?”

    With large language models entering the data analytics space, querying data in natural language, generating reports, and driving alerts have become possible. The industry broadly calls these capabilities Data Agents. But the core question enterprises ask is shifting—it’s no longer “can it be done,” but three sharper questions:

    • Where does the data live: Does it ever leave the corporate network boundary?
    • Who executes the query: Does the model directly manipulate the underlying data, or does a controlled compute engine execute?
    • Is the result trustworthy: A single wrong number can lead to a wrong business decision.

    Traditional data analytics relies on specialists writing SQL, building dashboards, and interpreting results manually—slow and high-barrier. LLMs lower the barrier, but they introduce two new risks: first, when a model directly accesses underlying table structures, ambiguity in metric definitions can easily produce hallucinated, wrong results; second, once data is uploaded to an external cloud, it may cross security and compliance red lines. For organizations with strict regulatory requirements on data security—such as state-owned enterprises, finance, energy, and manufacturing—keeping data in-domain is not an option; it’s a prerequisite.

    2. The Essential Differences Between Three Architecture Routes

    Enterprises building Data Agents today mainly follow three technical routes. They differ not in “how many features,” but across three dimensions: deployment model, data boundary, and trust mechanism.

    Route 1: In-Place Upgrade of the Existing Enterprise BI Stack

    The idea: don’t rebuild the data stack—let AI grow on top of existing BI assets. Key characteristics:

    1. Deployment: Supports intranet and private deployment; the model service and data stay entirely within the enterprise’s own environment, never traversing external networks. The enterprise keeps its existing IT architecture and network boundary, with no need to redesign data pipelines for AI.
    2. Query mechanism: Uses NL2DSL rather than raw NL2SQL. After a user asks a question in natural language, the system first converts it into a domain-specific language (DSL), aligns metrics and dimensions through the semantic layer, and then hands execution to a deterministic compute engine.
    3. Trust mechanism: Three layers of assurance—terminology alignment, DSL validity checks, and result plausibility checks. Every result carries data lineage and metric-definition notes, supporting traceability from the answer back to raw data.
    4. Permissions: Directly inherits data permissions from the existing BI system—no need to rebuild them.

    The deeper value of this route is a clear division of labor: the model handles intent understanding and task planning, while the semantic layer and deterministic engine handle accurate execution. Each does its own job, avoiding the hallucination risk of letting the model generate SQL against raw tables.

    Route 2: Private Deployment of Lightweight Open-Source Orchestration Frameworks

    Represented by open-source LLM application orchestration frameworks. Originally designed for cloud SaaS scenarios, these can achieve a degree of local deployment through self-hosting. Their strengths are fast onboarding and an active ecosystem, well-suited for prototyping. But as general-purpose Agent frameworks, they aren’t natively built for data analytics, and enterprises typically need to fill these gaps themselves:

    • Semantic layer and metric definition management (otherwise the model can’t understand business terms like “gross margin” or “retention rate”);
    • Validation and traceability mechanisms for query results;
    • Deep integration with enterprise permission systems.

    Under the hard constraint of keeping data in-domain, this route demands strong in-house engineering capability—and localizing model services (especially closed-source APIs) requires extra work.

    Route 3: Cloud-Based Integrated AI Services

    That is, using a Data Agent service directly on the public cloud. Fast iteration and out-of-the-box readiness, but data must flow to the cloud environment. For tightly regulated industries this route is essentially ruled out; even where compliance allows it, cross-border data transfer and multi-tenant isolation concerns need careful evaluation.

    The trade-offs can be summarized in one table:

    Dimension In-place BI upgrade Open-source self-hosted Cloud integrated
    Data boundary Never leaves domain Depends on retrofit effort Leaves domain
    Build cost Reuses existing assets Heavy self-development needed Low
    Trust mechanism Semantic layer + deterministic engine Must be self-built Depends on the product
    Best fit Large enterprises under strict compliance Engineering-strong teams Loosely regulated scenarios

    3. Why NL2DSL Is More Trustworthy Than NL2SQL

    This is the most easily overlooked yet most impactful technical distinction in the selection process.

    Raw NL2SQL has the model generate SQL directly and execute it against the database. The problems:

    • Table schema is the only semantics: The model sees only field names and table comments—it cannot understand business definitions. For the same “sales revenue,” does it include tax? Is it by order time or payment time? The model can’t tell; it can only guess.
    • SQL hallucinations are hard to intercept: A syntactically valid but logically wrong SQL produces a result that looks “perfectly normal,” and the error silently propagates to decision-makers.

    NL2DSL instead decouples “understanding” from “execution”:

    1. User question → Intent recognition & task planning (LLM) → DSL generation
    2. → Semantic-layer validation (metric/dimension/definition matching)
    3. → Deterministic engine execution → Result validation & lineage annotation → Answer returned

    The DSL is a controlled intermediate representation that can only express metrics, dimensions, and filters already registered in the semantic layer. The model’s output space is constrained to the range the business has confirmed; invalid or out-of-scope expressions are intercepted outright. Combined with three validation layers (terminology alignment, DSL validity, result plausibility) and answer-to-raw-data traceability, trustworthiness shifts from “pray the model doesn’t err” to “mechanisms that block the error paths.”

    4. A Selection and Evaluation Framework

    Based on the analysis above, evaluate along five dimensions:

    1. Compliance hard requirements: Does data stay in-domain end to end? Can model inference run locally or in a private environment? This is the first filter.
    2. System compatibility: Can you reuse existing data warehouses, metric definitions, reports, and permission systems? Migration cost is often the biggest hidden cost.
    3. Accuracy mechanisms: Raw NL2SQL, or semantic-layer-constrained? Are there multi-layer validation and result traceability?
    4. Engineering cost: Private deployment complexity, operational burden, and integration difficulty with the existing architecture.
    5. Evolvability: Can the system keep pace with model advances (e.g., swapping the underlying model), avoiding lock-in to a single technology stack?

    5. Conclusion

    Keeping data in-domain is not an obstacle to building Data Agents—it’s a forcing function for sound architecture. Keep data inside the domain, hand execution to a deterministic engine, hand permissions to the existing system, and constrain the model to the “understanding and planning” stage. This division-of-labor principle matters more than any single feature in your selection criteria. For security-conscious enterprises, the route that upgrades your own BI stack in place, built around a semantic layer and deterministic execution, is often the most reliable starting point.