Data Agent Selection Guide for Data-Residency-Constrained Environments

    This article explains how to select a Data Agent when data cannot leave the enterprise boundary. It compares three common technical routes—direct NL2SQL, metadata-based RAG, and enterprise Data Agent platforms with semantic layers and deterministic execution—then provides a five-dimension evaluation framework, a phased rollout path, and common pitfalls to avoid.

    1. Starting Point: The Shift in Data Analysis and a New Risk Surface

    For the past two decades, the dominant model of enterprise data analysis has been “professional-driven.” Business teams submit requests, data teams write SQL, build models, and create reports, and analysts manually interpret the results and deliver conclusions. This workflow suffers from long cycle times, high skill barriers, severe request backlogs, and heavy dependence on individual experience when explaining metric definitions.

    The maturation of large language models has made “conversation as analysis” practical: business users can ask questions in natural language, and the system can return conclusions and charts directly. However, as capabilities move closer to business users, risks move forward as well. Three risks are especially important:

    1. Metric-definition misunderstanding. The model sees table names and field names, not the enterprise’s actual metric definitions. The same “active user” metric may correspond to three different calculation logics in operations, finance, and risk control.
    2. Generative uncertainty. When a model directly generates SQL against underlying table structures, there are hallucination risks such as incorrect field selection, wrong joins, and metric-definition drift. These errors often “look reasonable” and are difficult for business users to detect.
    3. Data-boundary spillover. Uploading table structures, sample data, or even full query results to an external cloud inference service may directly violate security review and compliance requirements.

    For data-sensitive industries, keeping data within the enterprise boundary is a prerequisite, not an option. It determines the direction of architecture selection: any solution that requires moving data outside the enterprise network boundary should be excluded during evaluation, rather than being found unusable during validation.

    2. Three Main Technical Routes and Their Boundaries

    Route 1: Bare NL2SQL Directly Connected to the Database

    A general-purpose large model uses database metadata, such as table structures and a small number of samples, to generate SQL directly and execute it.

    • Deployment model: It can be deployed privately or rely on an external inference service. The boundary depends on where the model is deployed.
    • Advantages: It has the shortest validation cycle and can run a demo with almost no modification.
    • Limitations: Its accuracy ceiling is obvious. When table-structure semantics are sparse and multi-table joins are complex, the error rate rises quickly. It does not naturally inherit permissions and auditing, so additional work is required.
    • Applicable scenarios: Low data sensitivity, exploratory analysis, and scenarios where results are only for reference.

    Route 2: Metadata and Document Retrieval-Augmented Generation (RAG over Metadata)

    A retrieval layer is added between the model and the data. Metric dictionaries, business terms, historical SQL, and analysis documents are vectorized. When a question is asked, relevant fragments are retrieved as context and then used to generate a query.

    • Advantages: It significantly mitigates metric-definition bias, and knowledge assets can be accumulated and iterated over time.
    • Limitations: Retrieval quality determines the upper bound. When retrieval is inaccurate, the model may still “confidently make mistakes.” The execution layer still relies on generative SQL and lacks deterministic guarantees. The permission system must be designed separately.
    • Applicable scenarios: Teams that already have a relatively complete metric documentation system and can tolerate a certain level of accuracy fluctuation.

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

    Agent capabilities are layered on top of the enterprise’s existing BI and data systems. The core characteristics are semantic layer + deterministic computation engine + full-chain privatization.

    • Deployment model: It supports intranet and private deployment. Model services and data remain in the enterprise’s own environment, and data flows do not pass through external networks. It can directly reuse the existing IT architecture and network boundary, without redesigning the data pipeline just to introduce AI.
    • Query mechanism: It uses NL2DSL rather than bare NL2SQL. Natural language is first converted into a domain-specific language (DSL), aligned with metrics and dimensions through the semantic layer, and then executed by a deterministic computation engine. The model is responsible for intent understanding and query planning, while the semantic layer and engine are responsible for accurate execution. The responsibility boundary is clear.
    • Trust mechanism: A typical implementation includes three layers of validation: term alignment (whether business terms in the question can be mapped to registered metrics), DSL validity (whether the structure and parameters are compliant), and result reasonableness (whether the magnitude, null rate, and year-over-year or month-over-month changes are abnormal). Each conclusion includes data-source annotations and metric-definition explanations, supporting traceability from the answer back to the original data.
    • Permissions and cost: It directly inherits the data permissions of the existing BI system, so there is no need to build a separate permission model. It can reuse existing data assets, metric definitions, and analysis assets, avoiding data migration or system rebuilding just to introduce AI.

    The execution chain can be abstracted as follows:

    1. User question
    2. → intent recognition and term alignment (business terms → registered metrics/dimensions)
    3. → DSL generation (structured and verifiable)
    4. → validity check + permission filtering
    5. → deterministic computation engine execution
    6. → result reasonableness check
    7. → return conclusion + data source + metric-definition explanation

    The corresponding validation logic can be expressed with the following pseudocode:

    1. def trusted_query(question, user_ctx):
    2. terms = align_terms(question) # term alignment
    3. if terms.unmapped:
    4. return clarify(terms.unmapped) # clarify instead of guessing when alignment fails
    5. dsl = plan_to_dsl(question, terms) # generate domain-specific language
    6. if not validate(dsl, schema): # validity check
    7. return reject(dsl.errors)
    8. dsl = apply_row_level_policy(dsl, user_ctx) # inherit existing data permissions
    9. df = engine.execute(dsl) # deterministic execution
    10. if not sanity_check(df, dsl): # result reasonableness check
    11. return flag_anomaly(df)
    12. return answer(df, lineage=dsl.lineage(), caliber=terms.caliber)

    3. Five-Dimension Evaluation Framework

    Dimension Key question High-risk signal
    Deployment model Are both the model and the data inside the enterprise boundary? Sample data or table structures must be sent externally
    Query mechanism Is the system executing generative SQL or deterministic computation? No intermediate semantic layer; SQL is generated directly
    Trust capability Are validation, traceability, and metric-definition explanations provided? Only numbers are returned, without sources
    Permission system Does it inherit existing BI permissions? A separate permission model must be built
    Implementation cost Does it reuse existing data and metric assets? Data migration or metric rebuilding is required first

    4. Selection Recommendations and Implementation Path

    Recommended decision order: First, use “data must remain within the enterprise boundary” as a veto criterion to eliminate all solutions that require data to be sent externally. Then, among the remaining solutions, segment by accuracy requirements. Exploratory analysis can use Route 1 or Route 2. Scenarios that enter formal business decision-making chains should use Route 3.

    Phased implementation:

    1. Asset inventory: Review existing metric dictionaries, data permission models, and network boundaries, and identify the list of assets that must not be transferred externally.
    2. Small-scale validation: Select 3–5 high-frequency analysis scenarios with clear metric definitions to validate accuracy and traceability. Use real question sets rather than demo questions.
    3. Semantic layer construction: Complete term and metric registration. This is the main source of accuracy and the area that requires the most long-term investment.
    4. Permission and audit integration: Confirm that row-level and column-level permission inheritance is effective, and enable full-chain logging, monitoring alerts, and audit trails.
    5. Scaled rollout: Establish a badcase feedback mechanism and turn incorrect questions into iteration inputs for the semantic layer and validation rules.

    5. Common Pitfalls

    • Treating demo accuracy as production accuracy. Demo questions usually have a single metric definition, while real questions are full of omissions and ambiguity.
    • Underestimating semantic-layer investment. The semantic layer is not a one-time configuration; it is an enterprise knowledge asset that requires continuous operation.
    • Ignoring explainability. Conclusions that cannot be traced are almost unusable in compliance reviews, and business users will find it difficult to trust them.
    • Choosing the model first and considering boundaries later. In data-sensitive industries, boundary constraints should come before model-capability evaluation.

    Conclusion: Keeping data within the enterprise boundary does not limit innovation. Instead, it narrows architecture choices to a more sustainable path: let the model handle understanding, let the semantic layer and deterministic engine handle execution, and let permissions and auditing continue to use the existing system. With this principle, a Data Agent can be both useful and trustworthy, auditable, and compliant.