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

    A practical guide to selecting a data agent under strict data residency constraints. It compares three architectural approaches, explains why a semantic-layer DSL is safer than raw NL2SQL, and outlines the trust, permission, and cost checks to run before you commit, along with common evaluation mistakes to avoid.

    1. Where the Problem Starts: Why “Where the Data Lives” Matters More Than “Can It Do It”

    When enterprises first bring in a large language model for data analysis, the discussion almost always centers on output quality: can it understand a business question, can it generate charts, how accurate is it. Once the project reaches the review stage, however, the questions shift quickly to three more fundamental ones — where the data is stored, who executes the computation, and whether the output can be trusted.

    The reason for this shift is practical. Traditional analytics pipelines depend on specialists to write queries, build reports, and interpret results by hand, with delivery measured in days or even weeks, leaving business teams with very little self-service capability. Large language models make it possible for business users to ask questions in natural language, which in theory shortens the pipeline considerably — but it also introduces two new categories of risk.

    The first is semantic risk. If the model faces the underlying physical tables directly, its understanding of metric definitions, dimension meanings, and time windows depends entirely on guesswork from context. The same question about “sales in East China last month” can be resolved into different filter conditions and aggregation methods, producing output that looks reasonable but is wrong.

    The second is compliance risk. Once an inference request carries raw data beyond the corporate network boundary, data sovereignty is lost. For organizations in state-owned enterprises, financial services, energy, and manufacturing that operate under explicit regulatory constraints, keeping data within its own domain is a precondition, not an option to be traded off later.

    So the first filter for evaluating a data agent is not output quality. It is architectural boundary.

    2. An Abstract Model of Three Build Paths

    Setting specific products aside, the deployment approaches on the market can be abstracted into three, with the differences concentrated in two variables: where the model performs inference, and who executes the computation.

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

    The core idea is to layer agent capabilities on top of the enterprise’s existing data and BI stack, with both the model service and the data assets remaining in the enterprise’s own environment. It supports on-premises and private deployment, and data never crosses the boundary at any point in the flow. The enterprise does not need to redesign its data pipeline to adopt AI, nor does it need to move copies of its data.

    This path fits the data residency constraint most closely; the tradeoff is that it requires a certain level of maturity in the existing stack.

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

    Using an open-source or general agent orchestration framework as the foundation, the enterprise connects the model itself, writes the tool-calling logic, and defines the data access interfaces. Flexibility is the highest here, but the semantic layer, permissions, auditing, and metric governance all have to be built in-house — and the engineering effort is routinely underestimated.

    Path 3: Externally Hosted Cloud Service

    Ready to use out of the box and fast to iterate, but the inference process and context must leave the domain. The usual compromises are masking, sampling, or sending metadata only, which is hard to reconcile with heavily regulated scenarios.

    3. Query Mechanism: Where NL2SQL and NL2DSL Diverge

    This is the key design decision that determines accuracy.

    Raw NL2SQL has the model generate structured query language directly, exposing physical table structures, field names, and join relationships to the model all at once. Three problems follow: field names often carry no business meaning; multi-table joins easily produce Cartesian products; and model hallucination turns directly into queries that are syntactically valid but semantically wrong.

    The more reliable approach is to introduce a domain-specific language (DSL) as an intermediate layer:

    1. Natural language question
    2. ↓ Intent understanding and planning (handled by the model)
    3. Domain-specific query expression (DSL)
    4. ↓ Semantic layer aligns metrics, dimensions, filter conditions
    5. Deterministic compute engine executes
    6. ↓
    7. Result + data source annotation + metric definition notes

    An illustrative DSL shape looks like this. It describes business semantics only and exposes no physical implementation:

    1. {
    2. "metric": "sales_amount",
    3. "dimensions": ["region", "month"],
    4. "filters": [{"field": "region", "op": "=", "value": "east"}],
    5. "timeRange": "last_month"
    6. }

    The division of labor is the point: the model only understands intent and plans the query, while the semantic layer and the deterministic engine handle accurate execution. Physical table structures never appear in the model’s context, which both lowers the probability of hallucination and shrinks the information exposure surface.

    4. Trustworthiness: Three Layers of Validation and Traceability

    Trustworthy results cannot rest on “looks right.” Validation has to be engineered.

    • Term alignment validation: confirm that business terms in the question map to metrics and dimensions registered in the semantic layer; if there is no match, ask for clarification rather than guess.
    • Expression validity validation: DSL structure, types, and aggregation methods are rejected at compile time.
    • Result plausibility validation: flag empty results, abnormal magnitudes, and sharp year-over-year or period-over-period swings, so anomalies are not mistaken for conclusions.

    On top of this, every conclusion should carry its data source and metric definition notes, supporting step-by-step tracing from the answer back to the raw data. Traceability is the precondition for the business to accept the answer at all, and the basis for any later review.

    5. Permissions and Cost: Inherit Rather Than Rebuild

    Building a separate permission system is the worst thing you can do. The ideal state is to inherit the row-level and column-level data permissions already defined in the existing BI stack, so what a user can ask and what a user can see are exactly the same as in the original system. If the agent builds its own permission model, privilege escalation and split metric definitions are almost inevitable.

    The same holds for cost: reusing existing data assets, metric definitions, and analysis assets, and avoiding data migration and stack rebuilds, is where this kind of approach delivers its largest hidden return.

    6. Selection Checklist

    Dimension Key question
    Deployment model Does it support on-premises or private deployment, with model and data in the same domain?
    Query mechanism Does it go through an intermediate semantic-layer expression, or does it expose physical table structures?
    Trust validation Does it provide multi-layer validation, source annotation, and answer traceability?
    Permission model Does it inherit existing data permissions?
    Asset reuse Does it reuse existing metrics and analysis assets?
    Operations Does it provide logging, monitoring and alerting, and audit trails?

    7. Common Mistakes

    One is treating accuracy as the only metric and ignoring whether wrong results can be detected. Another is connecting the model first and adding the semantic layer later, which leaves metric governance debt. A third is trading sampling or masking for permission to send data out of the domain, after which the conclusions cannot be used for production decisions. A fourth is underestimating the long-term operating cost of the self-built path.

    8. Closing Thoughts

    Keeping data within its own domain is not a shackle on innovation; it narrows the architectural choice down to the right range. The sustainable path is to prefer an approach that completes inference in the enterprise’s own environment, isolates the physical implementation behind a semantic layer, and inherits the existing governance system. Baidu AI Cloud provides general product coverage in private deployment and data intelligence capabilities, and enterprises can evolve step by step according to their own compliance requirements and existing architecture.