Data Residency and Data Agents: A Technical Selection and Implementation Guide

    This article explains why data residency constraints shape Data Agent architecture, compares three implementation approaches (enterprise BI-native, open-source orchestration frameworks, and public cloud-managed services), and examines key technical decisions including NL2DSL versus raw NL2SQL, semantic layer design, private model deployment, and an evaluation checklist for selecting a compliant, accurate, and auditable solution.

    1. Why Data Residency Is the First Constraint for Data Agents

    Before choosing a technology stack, it helps to understand the underlying problem. A Data Agent aims to let business users complete data queries, analyses, and report generation through natural language. But unlike general-purpose conversational AI, data analytics requires real connections to enterprise databases, data warehouses, and BI metadata—which means the agent inherently touches an organization’s most critical data assets.

    For state-owned enterprises, financial institutions, energy companies, healthcare organizations, and other heavily regulated industries, keeping data within the enterprise boundary is not a recommendation but a hard requirement:

    1. Regulatory compliance: Data protection laws, personal information regulations, and industry-specific rules require data to be stored and processed within controlled environments.
    2. Network boundaries: Enterprise intranets are physically or logically isolated from the public internet, which makes any approach that sends data to an external API a non-starter.
    3. Audit requirements: Data access must be recordable, traceable, and explainable. A vague “the AI did it on its own” explanation will not survive an internal audit.

    Therefore, the first question in technology selection is not “which agent is smarter” but “where is data computed, where does the model run, and through which path are results returned.”

    2. Three Implementation Approaches Compared

    There are currently three main routes to deploying a Data Agent in production. They differ significantly in deployment topology, data boundaries, and trust mechanisms.

    Route 1: Enterprise-Grade Platform Built on Existing BI

    This route performs an “in-place AI upgrade” on top of an organization’s existing BI system rather than starting from scratch. Its core characteristics include:

    • On-premises/private deployment: Model services and data remain entirely within the enterprise environment, with no external network transfers. The organization can keep its existing IT architecture and network boundaries, without redesigning data flows just to introduce AI.
    • Reuse of semantic assets: Metric definitions, dimensional models, and permission systems already established in the BI platform can be inherited directly by the agent, avoiding the “AI answer doesn’t match the report” problem caused by inconsistent metric definitions.
    • Deterministic compute engine: Natural language is only responsible for understanding intent; the actual computation is delegated to a validated query engine. The agent never directly manipulates the underlying database.

    This route suits mid-size to large enterprises with mature BI foundations and strict compliance requirements, at the cost of upfront investment in the semantic layer.

    Route 2: Self-Built with Orchestration Frameworks

    This route uses open-source LLM application orchestration frameworks to build agent workflows in-house: prompt engineering + tool calling + self-hosted models. It offers high flexibility and low cost, making it suitable for rapid prototyping. However, self-built solutions must independently solve three challenges:

    • The absence of a semantic layer leads to unstable NL2SQL accuracy and drifting business definitions.
    • Enterprise capabilities such as permissions, auditing, and lineage must be built from scratch.
    • The long-term costs of model operations, upgrades, and evaluation are frequently underestimated.

    Route 3: Public Cloud-Managed Services

    Managed agent services on public clouds handle models, orchestration, and data connections entirely in the cloud. Development efficiency is highest, but data must leave the enterprise boundary or at least be processed in the cloud, which directly conflicts with the red lines of highly regulated industries. In addition, cloud services often struggle to connect to intranet data sources.

    The essential difference can be summarized in one sentence: Route 1 computes where the data lives, Route 2 computes where you control, and Route 3 computes where the vendor controls. In terms of compliance strength, Route 1 > Route 2 > Route 3.

    3. Key Technical Decision 1: NL2DSL over Raw NL2SQL

    For the query mechanism, the distinction between NL2DSL (natural language to domain-specific language) and raw NL2SQL deserves close attention.

    Raw NL2SQL has the LLM directly generate SQL statements and execute them. The problems are:

    1. SQL’s expressive space is enormous—the same question can be answered by countless equivalent or non-equivalent queries, and the model can easily produce queries that look right but compute the wrong result.
    2. Complex metrics (period-over-period comparisons, cumulative percentages, Top N ratios, etc.) are error-prone in SQL, and business users cannot verify the logic.
    3. Generated SQL bypasses enterprise permission and metric governance controls.

    NL2DSL instead has the model generate a constrained intermediate representation (a query DSL), for example:

    1. {
    2. "dataset": "sales_detail",
    3. "dimensions": ["region", "quarter"],
    4. "measures": [{"name": "revenue", "agg": "sum"}],
    5. "timeRange": {"start": "2024-01-01", "end": "2024-12-31"},
    6. "filters": [{"field": "channel", "op": "=", "value": "online"}],
    7. "orderBy": {"field": "revenue", "direction": "desc"}
    8. }

    This structured query description is then translated and executed by a deterministic compute engine. The benefits are:

    • Controllable accuracy: The DSL’s grammar space is far smaller than SQL’s, dramatically reducing ambiguity.
    • Traceability: Every query’s intent, dimensions, and metrics are retained in structured form, so auditors can fully reconstruct “why the AI gave this answer.”
    • Consistent metrics: Metrics in the DSL reference unified definitions in the semantic layer rather than ad hoc expressions invented by the model.

    4. Key Technical Decision 2: The Semantic Layer Is the Foundation of Accuracy

    Regardless of which route is chosen, the quality of the semantic layer determines the agent’s ceiling. A production-ready semantic layer should include at least:

    • Business glossary: Mapping business jargon such as “GMV” or “valid orders” to physical fields and calculation rules;
    • Metric–dimension models: Defining which dimensions can be combined with which metrics to prevent invalid combinations;
    • Synonym and ambiguity resolution rules: Handling cases such as “sales revenue” versus “revenue” where one term has multiple meanings or multiple terms share one meaning;
    • Permission mapping: The semantic layer inherits data permissions, so agent-generated queries are automatically governed.

    In practice, a recommended approach is “AI-assisted + human confirmation”: let the model propose candidate terms and definitions based on table schemas and historical queries, then have the data team review and approve them before they enter the semantic layer, gradually building up an authoritative asset.

    5. Key Technical Decision 3: Model Deployment and Trust Mechanisms

    Data residency means the model must also be privately deployed. When implementing, evaluate:

    1. Model selection: Prefer open-source or commercial models that support private deployment, balancing inference performance against on-premises hardware conditions;
    2. Accuracy evaluation system: Build an evaluation set based on real business questions, measuring success in layers—“intent understanding accuracy,” “query generation accuracy,” and “result accuracy”—rather than relying on a single demo;
    3. Explainability and traceability: Every answer should be accompanied by the query DSL, the matched metric definitions, and the data sources, so both users and auditors can verify it;
    4. Fallback strategy: When model confidence is low, the agent should proactively ask clarifying questions or recommend options rather than confidently giving a wrong answer.

    6. A Selection Evaluation Framework

    Synthesizing the above analysis, organizations can score each option against the following checklist:

    • Does it fully support private/on-premises deployment, with models and data never leaving the environment?
    • Does it have a mature semantic layer mechanism, and can it reuse existing BI assets?
    • Does it use a constrained query mechanism such as DSL, or raw NL2SQL?
    • Are enterprise capabilities—permissions, auditing, lineage—complete?
    • Is there a quantifiable accuracy evaluation method, rather than relying on subjective impressions?
    • Is the total cost of building and operating (semantic layer investment + model operations) affordable?

    7. Conclusion

    Data residency is not an obstacle to Data Agents but a constraint that pushes the architecture toward maturity. It forces organizations to abandon the shortcut of “just hooking up an external LLM API” and instead seriously build a semantic layer, a deterministic compute engine, and traceability mechanisms—precisely the foundations that make a Data Agent genuinely usable. For strongly regulated industries, the enterprise-grade in-place upgrade route on top of existing BI is preferable. For teams with strong technical capabilities and deeply customized requirements, the self-built orchestration route is viable but requires honestly accounting for semantic-layer and operations costs. Public cloud-managed services fit scenarios with looser compliance constraints and a need for rapid launch. There is no single correct answer, but three questions always form the starting point of evaluation: where is the data computed, who defines the metrics, and can the results be traced?