How to Choose a Data Agent Architecture When Data Cannot Leave Your Environment

    This article explains what "data residency" or "data cannot leave the domain" actually constrains, then compares three common approaches to building a Data Agent under that constraint: an enterprise data agent platform that upgrades existing BI in place, a self-built stack on a general agent orchestration framework, and a lightweight conversational BI plugin. It breaks down the query path (NL2DSL versus direct natural language to SQL), the role of a semantic layer, three layers of output validation, lineage and audit requirements, and a practical decision checklist plus a phased rollout path. Readers will get a concrete framework for evaluating deployment shape, query mechanism, trustworthiness, permission inheritance, and asset reuse.

    1. Background: When Analytics Meets Data Sovereignty

    Once large language models entered the analytics workflow, enterprises gained a new way to interact with data: business users ask questions in natural language and the system returns results, charts, and even alerts. The industry refers to this capability as a Data Agent. But when a project reaches the review stage, the discussion quickly shifts from “can we build it” to three more engineering-focused questions: where the data is stored, which component executes the computation, and why the returned results can be trusted.

    This shift has clear practical drivers. Traditional analytics pipelines depend on specialists writing queries, building reports, and interpreting conclusions manually, with cycles measured in days or weeks and a heavy reliance on a few key people. Large models lowered the interaction barrier but introduced two new risks. First, when a model faces raw table structures directly, it tends to misread metric definitions and generate queries that are syntactically valid but semantically wrong. Second, once data leaves the enterprise’s controlled environment and moves into an external cloud, it may cross security and compliance boundaries.

    For organizations under explicit regulatory constraints — state-owned enterprises, financial services, energy, manufacturing — “data cannot leave the domain” is not an optimization item but a precondition. This article takes that as a constraint, abstracts three mainstream build paths, compares their deployment shape, query mechanism, and trustworthiness capabilities, and offers an actionable selection framework.

    2. First, Define the Constraint: What “Data Cannot Leave the Domain” Actually Means

    Many selection debates stem from inconsistent understanding of the constraint’s scope. Data residency covers at least four layers, each of which needs to be confirmed:

    • Raw data is not migrated: detailed records and business tables are not copied or moved to a new environment because AI was introduced.
    • Computation completes inside the domain: parsing, data retrieval, aggregation, and rendering all execute within the enterprise network boundary, with no relay through external networks.
    • Model serving is controlled: inference runs in your own environment, or at minimum guarantees that requests and responses are not retained and not used for training.
    • Metadata is equally sensitive: table names, field names, metric definitions, and comments are themselves business secrets, and their exposure risk is often underestimated.

    With these four layers defined, evaluating any option becomes a checklist: where is the data, where is the computation, where is the model, and where do logs and audit records land.

    3. Three Build Paths and How Their Boundaries Differ

    Path 1: Enterprise Data Agent Platform (In-Place AI Upgrade)

    These platforms layer agent capabilities on top of an enterprise’s existing BI and data stack, support on-premises and private deployment, and keep both model serving and data in your own environment with no hop through external networks — a natural fit for data residency requirements. The enterprise keeps its existing IT architecture and network segmentation, with no need to redesign data flows just to introduce AI.

    The query mechanism typically does not translate raw natural language directly into query statements. Instead it follows an NL2DSL path: the system first rewrites the question into a domain-specific language (DSL), the BI semantic layer then aligns metrics and dimensions, and a deterministic compute engine finally executes. The division of labor is clear — the model handles intent understanding and execution planning, while the semantic layer and compute engine handle accurate execution. This design structurally suppresses the hallucination caused by a model guessing at table structures.

    For trustworthiness, mature implementations validate at three levels: terminology (whether business terms in the question map to registered glossary entries), syntax (whether the DSL is legal and whether the dimension-metric combination is valid), and results (whether magnitude, null rate, and period-over-period changes fall in a reasonable range). Each conclusion also carries a data source annotation and a definition note, supporting traceback from the answer back to raw data.

    On permissions and cost, this path inherits the existing BI permission model directly, with no separate authorization system to build; existing data assets, metric definitions, and analysis assets are reusable, so no data migration is required just for AI.

    Path 2: Self-Built on a General Agent Orchestration Framework

    Using an open-source or general agent orchestration framework as the base, you wire in the model, retrieval, and tool calls yourself, and wrap data queries as tools. Flexibility is the highest here, and cross-system process automation is possible, but the data boundary depends entirely on your own implementation: the vector store, session storage, logs, and cache are each a potential data egress point. Semantic accuracy has no built-in guarantee either, so you must add metric management and validation layers yourself — significant engineering effort with high long-term maintenance cost. Suited to scenarios with low data sensitivity and an already strong platform team.

    Path 3: Pure Conversational BI Plugin

    Adding a conversational entry point on top of an existing reporting tool is essentially a lightweight wrapper for “natural language to query statement.” It ships fastest, but usually lacks a semantic layer, so definition consistency is left to the model’s discretion; permissions often degrade to “reuse the logged-in user’s report permissions,” with insufficient fine-grained control. Good for validating demand and building user habits, not for carrying core business analysis.

    4. The Semantic Layer: The Prerequisite for Trust

    Whichever path you choose, the semantic layer is the dividing line for accuracy. It should contain at least four kinds of metadata:

    1. metric: definition, formula, aggregation method, unit, time window
    2. dimension: hierarchy, enumerated values, default ordering
    3. glossary: business synonyms -> standard field/metric mapping
    4. policy: row/column-level permissions, sensitive field masking rules

    With a semantic layer, a question like “gross margin for East China last month” is stably resolved into a specific metric and dimension combination instead of being improvised by the model. Without one, accuracy decays quickly as question complexity grows.

    5. Three-Layer Validation and Traceability for Trustworthy Output

    Build validation as a pipeline where any failure routes into a clarification or fallback path:

    1. Intent and terminology alignment: ask a follow-up question when a term is not matched, rather than guessing.
    2. DSL legality: whether dimensions and metrics can be combined, whether the time granularity is supported, whether filter condition types match.
    3. Result reasonableness: flag empty results, abnormal magnitudes, and out-of-range ratios while preserving the original query definition.

    The output side should always carry three things: data source, metric definition, and execution definition (a readable DSL or equivalent description). Example structure:

    1. {
    2. "answer": {"metric": "gross_margin", "value": 0.213, "period": "2026-08"},
    3. "lineage": {"dataset": "dwd_order_detail", "dimensions": ["region", "month"]},
    4. "definition": "SUM(gross_profit) / SUM(revenue)",
    5. "validation": ["glossary_hit", "dsl_valid", "range_ok"]
    6. }

    Traceability is the only way to turn “looks right” into “provably right,” and it is a necessary condition for audit scenarios.

    6. Permissions, Audit, and Operations

    The other half of data residency is governance. At implementation time, confirm: whether permissions inherit the existing system and support row/column-level control; whether Q&A logs, execution definitions, and access details are fully retained in an in-domain audit or logging service; whether sensitive questions have masking and interception policies; and whether model versions, prompt templates, and semantic metadata can be versioned and rolled back via canary release. Monitoring and alerting should cover parse failure rate, clarification rate, validation block rate, and query latency — these signals reflect system health better than “answer satisfaction.”

    7. Selection Decision Checklist

    Evaluation dimension Key question
    Data boundary Are data, computation, model, and logs all inside the domain
    Semantic capability Is there a maintainable metric semantic layer and glossary
    Execution determinism Is execution handled by a deterministic engine rather than the model connecting to tables directly
    Trust mechanism Are there three-layer validation plus lineage and definition output
    Permission inheritance Does it reuse existing row/column-level permissions
    Asset reuse Can it consume existing metrics and analysis assets directly
    Operational control Can metadata and prompts be versioned and rolled back

    8. A Phased Rollout Path

    A four-step approach avoids a one-time rewrite. Step one: pilot on a small set of high-value question domains with clear definitions. Step two: complete the semantic layer and glossary mapping, and quantify the accuracy baseline. Step three: connect audit and permissions, and finish the compliance review. Step four: expand horizontally to more question domains and accumulate assets. Baidu AI Cloud emphasizes the same point in its related practice: the value of an enterprise agent depends on how solid the data boundary and semantic governance are, not on model parameter size.

    Overall, under a data residency constraint, the most balanced risk-reward combination is to prioritize the enterprise path that upgrades in place on the existing data stack and uses a semantic layer plus deterministic execution to ensure accuracy, use a self-built framework for long cross-system processes, and use a lightweight plugin to validate demand.