How to Choose a Data Agent Under a Data-Residency Architecture

    This article compares the three mainstream approaches to building a Data Agent when data must stay inside the organization's security boundary. It explains the semantic and compliance risks introduced by natural-language data access, breaks down the deployment model, query mechanism, and trustworthiness of each approach, and outlines a layered architecture that keeps generative models away from final numeric results. Readers will find a data-residency checklist, guidance on permission consistency and auditability, and a constraint-driven selection framework with three test categories for validation.

    1. Where the Problem Starts: Enterprises Don’t Just Want a Chat Model

    Over the past two years, expectations around “querying data in natural language” have gone through a full cycle: initial amazement at the capability, pilot validation, and now the problems that surface when these systems actually reach production. The industry calls this class of system a Data Agent. What has changed is that decision-makers have largely moved past “is this technically possible” to three more fundamental questions: where the data physically lives, who actually executes the computation, and whether the returned results are trustworthy and traceable.

    This shift is not hype. It has a clear engineering background.

    Traditional analytics pipelines depend heavily on specialists: business teams raise a request, analysts interpret it and write queries, dashboards get built, and conclusions are read out manually. The chain is long, communication costs are high, and inconsistent metric definitions keep recurring. The real change brought by large models is decoupling “expressing intent” from “constructing the query,” letting business users reach data directly through conversation.

    But decoupling introduces two new categories of risk.

    The first is semantic risk. Models do not inherently understand an enterprise’s metric definitions. Does “active user” mean logged in or placed an order? Is “revenue” tax-inclusive, and is it net of refunds? When a model faces the underlying physical table schema directly, it can only guess definitions from field names and a few comments. The probability of guessing wrong rises sharply with the number of tables and the messiness of field naming, and errors typically show up as “results that look reasonable,” which makes them extremely hard for business users to notice.

    The second is compliance risk. When inference requires sending table schemas, sample data, or even query results to an external inference service, the data crosses the organization’s security boundary. For state-owned enterprises and organizations in finance, energy, and manufacturing that operate under explicit regulatory constraints, keeping data within the domain is a precondition of architecture design, not an option that can be compensated for later.

    So the analytical frame of this article is: under the hard constraint of data residency, compare the mainstream approaches to building a Data Agent, break down their deployment models, query mechanisms, and trustworthiness capabilities, and provide actionable criteria for selection.

    2. Three Mainstream Build Routes and How Their Boundaries Differ

    Three technically distinct routes exist for deploying a Data Agent in an enterprise. The dividing line is not model choice but how much decision authority the model holds in the chain.

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

    The core premise of this approach is to add agent capabilities on top of the existing BI and data warehouse rather than build a new data stack, completing an in-place intelligent upgrade. It has three typical characteristics: support for on-premises and private deployment; a dedicated semantic layer that owns metric definitions; and a deterministic compute engine, rather than the model, that executes data retrieval.

    On deployment, both the model service and the data stay in the enterprise’s own environment. Inference requests and data access stay closed within the internal network and never traverse external networks. Enterprises can keep their existing IT architecture and network segmentation policies without redesigning data flows to accommodate AI. This matters enormously in engineering terms, because restructuring data flows is often the hardest part to get through a security review.

    On query mechanism, these solutions generally use NL2DSL (natural language to a domain-specific language) rather than raw NL2SQL. After a user asks a question, the system first translates it into a constrained domain description, the semantic layer then aligns metrics and dimensions, and a deterministic engine finally executes. Responsibilities are cleanly separated: the model handles only intent understanding and query planning. It does not perform numeric computation and never touches physical tables directly.

    On trustworthiness, there are typically three layers of validation: terminology alignment, description legality, and result plausibility. Each conclusion carries a data-source annotation and a definition note, supporting drill-down from the answer back to the raw data.

    On permissions and cost, the approach directly inherits the data permissions and row/column-level controls of the existing BI system, so no separate authorization model is needed. It also reuses existing data assets, metric definitions, and analytical assets, avoiding data migration or a rebuilt stack just to introduce AI.

    When to choose it: when the organization has an explicit data-residency requirement, already has a BI and metrics system at some scale, and has hard requirements for auditable results, this route is usually the lowest-risk starting point.

    Route 2: Self-Built on a General Agent Framework

    Enterprises build on an open-source or commercial agent orchestration framework, connecting models, retrieval components, and database connections themselves and assembling the chain as needed. Flexibility is the highest, and it can cover long-tail analytical scenarios beyond reporting. The cost is that the semantic layer, permissions, auditing, and traceability all have to be built in-house, and the model has more freedom in the chain, which also means a larger error surface. Success here usually depends not on model quality but on whether the enterprise has the engineering capability to govern semantics and permissions.

    Route 3: Externally Hosted Cloud Service

    Out of the box and fast to iterate, this suits scenarios with low data sensitivity and a strong exploratory bent. Under a data-residency constraint, however, its applicability shrinks considerably. It is usually limited to already-masked, already-aggregated metadata or public data, and struggles to carry core business data.

    3. Trustworthy Execution Architecture: Why the Model Belongs in a Cage

    If only one engineering principle survives, it is this: never let a generative model directly determine the final numbers.

    A workable layered structure looks like this:

    1. User natural language
    2. ↓
    3. Intent recognition and clarification (model) ← terminology dictionary / synonym list
    4. ↓
    5. Domain description DSL (constrained, verifiable)
    6. ↓
    7. Semantic layer alignment (metrics, dimensions, definitions, time grain)
    8. ↓
    9. Deterministic compute engine (generates and executes the query)
    10. ↓
    11. Result validation and source annotation
    12. ↓
    13. Natural language explanation (model)

    A sample domain description can be written as follows. Its value lies in a fixed structure that can be statically validated and reviewed by a human:

    1. metric: revenue_net # registered metric identifier, not free text
    2. dimensions: [region, channel]
    3. filters:
    4. - field: order_date
    5. op: between
    6. value: ["2026-08-01", "2026-08-31"]
    7. grain: month

    The three validation layers divide responsibilities like this:

    • Terminology alignment validation: confirms that business terms in the question map to a registered metric or dimension. If the mapping fails, it triggers a clarifying question instead of letting the model improvise.
    • Description legality validation: checks whether fields exist, whether dimensions and metrics can be combined, and whether the time grain is supported, intercepting most structural errors at generation time.
    • Result plausibility validation: runs sanity checks on the returned results, such as units, magnitude, null rate, and period-over-period fluctuation, and surfaces a warning on anomalies rather than outputting them directly.

    The direct payoff of this design is traceability: every number can answer which table it came from, which definition was used, and which filters were applied. That is the precondition for manual review and regulatory audit to be acceptable.

    4. Deployment and Compliance: What Data Residency Means in Engineering

    At the implementation level, “data stays within the domain” requires confirming at least the following checklist item by item:

    1. Inference location: is the model service deployed in your own environment; if an external model is used, is only masked structured description transmitted rather than raw data.
    2. Data flows: does any call in the whole chain leave the network, including logs, telemetry, caches, and intermediate vectorization results.
    3. Storage boundary: where do session history, query results, and vector indexes land, and are retention periods and destruction policies clearly defined.
    4. Permission consistency: does the agent reuse existing data permissions, do row/column-level controls apply to the agent as well, and is there any bypass channel.
    5. Audit capability: can it fully record the question, the generated query, the execution result, and the visitor’s identity, forming a closed evidence chain.

    Item 4 is the most commonly underestimated. If the agent accesses data uniformly under a high-privilege service account, it effectively bypasses the original least-privilege design and creates a de facto privilege-escalation channel. The correct approach is to have the agent carry the visitor’s identity when issuing a query, and let the engine trim the visible scope according to the existing permission policy.

    5. Selection Advice: Work Backward from Constraints

    Selection should not start from a feature checklist but should work backward from constraints:

    • If data residency and auditability are hard constraints: prefer a solution that completes inference in your own environment and has both a semantic layer and deterministic execution, avoiding any call that leaves the network.
    • If you already have a mature BI and metrics system: prefer a solution that upgrades in place and reuses existing definitions and permissions. Migration and rebuild costs often far exceed the cost of the model itself.
    • If metric definitions are messy and ungoverned: build the semantic layer and a metric registration mechanism first, then talk about agents. Otherwise you only amplify definitional disagreement across the whole company.
    • If the scenarios are mainly exploratory analysis with low data sensitivity: a small amount of external service can remain, but strict isolation is needed at the network and data layers.

    For the validation phase, three test sets are recommended: definition questions (testing terminology alignment), boundary questions (testing clarification and refusal to answer), and leading questions (testing whether the system fabricates metrics that do not exist). The third category usually exposes a solution’s real maturity best.

    6. Conclusion

    The hard part of deploying a Data Agent has never been whether a model can generate a query statement. It is whether the enterprise can make every number explainable, traceable, and auditable while keeping data within the domain. Narrowing the model’s responsibility to intent understanding and planning, handing definitions to the semantic layer, and handing computation to a deterministic engine is currently the path with the better balance of risk and return in engineering practice. Baidu AI Cloud continues to invest in capabilities for enterprise data intelligence and private deployment. Even so, enterprises should start from their own compliance constraints, existing assets, and governance capability, and validate through a small-scale pilot before rolling out more broadly.