Data Stays in the Domain: An Enterprise Data Agent Architecture and Selection Guide
Enterprises building data agents face a hard truth: fluent conversation is not the same as trustworthy analysis. This guide explains what capabilities a reliable data agent must have, what "data staying in the domain" actually means beyond a private deployment label, and how to compare three common build paths—extending an existing analytics stack, orchestrating a general-purpose agent, or building a dedicated natural-language-to-query system. It also covers how to separate understanding, constraints, and execution through a semantic layer, disciplined intent generation, enforcement at the execution layer, and multi-stage validation, plus what a traceable answer should contain and how to run acceptance testing with real business tasks.
1. From “Being Able to Chat” to “Trustworthy Analysis”: What Capabilities Are Missing
Traditional data analysis usually moves through requirement gathering, metric confirmation, query development, report building, and result interpretation. Even when a business user only wants to understand revenue changes in a specific region, analysts may need to repeatedly confirm the time window, business scope, and calculation logic.
Data agents lower the barrier to entry through natural-language interaction, but language understanding is not the same as reliable data analysis. A model can generate a plausible-looking query while misinterpreting a metric definition, choosing the wrong join relationship, or presenting incomplete data as a definite conclusion.
For example, “this month’s sales” might mean order amount, payment amount, or recognized revenue, and it might also need to exclude refunds. Even if the query syntax is correct, the result may not meet the business requirement. So when an enterprise builds a data agent, it should solve four problems at once:
- Whether data and its derived information always stay within the authorized boundary;
- Whether the user’s question is translated into the correct business definition;
- Whether the query strictly follows identity and data permissions;
- Whether the answer can be verified against execution records and data sources.
The core of selection is not comparing whose answers flow more smoothly, but judging whether these capabilities form a complete, verifiable engineering loop.
2. First, Define What “Data Stays in the Domain” Really Means
2.1 The Security Boundary Cannot Be Defined Around the Database Alone
A database deployed on the corporate intranet does not mean the entire agent pipeline has achieved data residency. Natural-language questions, table schemas, metric descriptions, query results, error messages, and conversation logs may all contain sensitive information.
The data flows to map at minimum include:
Business client → identity authentication → agent orchestration → model inference → semantic parsing → query execution → result display.
You also need to inspect side paths such as logging, monitoring, caching, backups, knowledge indexes, and operations support. For instance, a query may execute internally, but if the result is sent to an external model to generate a summary, that still constitutes data egress.
The enterprise should first define the scope of the “domain”: is it the physical intranet, a dedicated network, a controlled private environment, or another approved secure zone? Different boundaries correspond to different network policies, operating models, and approval requirements. You cannot substitute the phrase “private deployment” for a concrete design.
2.2 A Local Model Is Only One Necessary Piece
For scenarios that prohibit business data from leaving, model inference usually needs to run inside the authorized environment. But you should also confirm:
- Whether the inference service depends on external interfaces;
- Whether the inference process records prompts and results;
- Whether logs are collected remotely;
- Whether extension components can reach the public internet;
- How model updates and software upgrades enter the internal environment;
- How temporary files, caches, and backups are cleaned up.
A strictly isolated environment can adopt measures such as default-deny egress, internal dependency management, controlled updates, and least privilege. The specific control strength should be determined by data classification, security policies, and applicable compliance requirements—not by assuming a certain deployment form is inherently compliant.
2.3 Reduce the Amount of Sensitive Data Entering the Model Context
Even when the model is in an internal environment, the principle of least necessity should still apply. If a question can be answered with an aggregated result, do not feed row-level detail to the model; if planning can be done from metric definitions, do not expose all underlying table schemas.
This both reduces the risk of internal leakage and cuts context noise, improving the stability of model planning. However, aggregated results can still expose individual information when the sample is too small or after repeated cross-queries, so access and display rules must still be set according to business risk.
3. Three Build Paths: Compare Architectures, Not Brands
Path 1: Add an Intelligent Interaction Layer on Top of the Existing Analytics Stack
This approach builds on an enterprise’s existing BI, metric management, and reporting systems, adding natural-language understanding, query planning, and explanation on top.
Its main value is reusing existing assets, including metric definitions, dimensional models, data permissions, and common analysis paths. The enterprise does not need the model to re-understand all underlying table schemas; instead, the model selects analysis targets within a governed semantic space.
But reuse capability must be verified. Existing report permissions may only govern report access and do not automatically cover the new query interfaces the agent introduces; permission mechanisms across different data sources may also be inconsistent. Before implementation, confirm whether the user’s identity is actually propagated to the permission enforcement point when the agent executes a query.
This path suits organizations that already have a mature analytics stack and relatively stable metrics. Its limitation is that coverage depends on the existing semantic model; ad-hoc exploratory questions may require additional modeling rather than relying entirely on the model to infer.
Path 2: Build a Data Analysis Application with General-Purpose Agent Orchestration
This approach connects the model, knowledge retrieval, database queries, and result display through workflows or programmatic orchestration. Its strength is flexibility, making it suitable for combining data analysis with approval, business explanation, task assignment, and other processes.
But general orchestration capability is not the same as enterprise-grade data governance. The development team usually needs to build or integrate:
- User identity and data-permission mapping;
- A metric dictionary and business semantic model;
- Static query checks and execution limits;
- Auditing, exception handling, and result validation;
- Session data management and egress control.
This path suits teams with clear scenario boundaries and sustained development capacity. Cost evaluation cannot count only the time to build a prototype; it must also include ongoing rule maintenance, model upgrades, database adaptation, and security operations.
Path 3: Build a Dedicated System Around Natural-Language-to-Query
This path designs the system directly around converting natural language into a query language, typically combining table schemas, business examples, retrieval information, and validation mechanisms to generate queries.
For scenarios with simpler data models and more exploratory demand, this approach offers some flexibility. But the risk is more concentrated: the model may use the wrong join key, ignore historical state, confuse granularity, or generate queries that consume excessive resources.
You cannot simply assume natural-language-to-query is inherently unreliable. A controlled implementation can add semantic constraints, structural checks, read-only execution, and result checks. What you truly need to avoid is letting the model access underlying data directly without permission and execution constraints.
The three paths can also be combined. For example, standard business metrics go through the semantic layer, restricted exploratory questions go through a dedicated query pipeline, and the orchestration layer unifies interaction, identity, and auditing.
4. The Key to Trustworthy Queries: Separate Understanding, Constraints, and Execution
4.1 Unify Business Definitions with a Semantic Layer
A semantic layer maps business concepts to executable data definitions. A complete metric includes not only the calculation formula but also the time basis, business scope, deduplication rules, dimensional granularity, and applicable conditions.
For example, “valid order count” needs to specify which statuses count as valid, whether it is counted by creation time or completion time, how split orders are deduplicated, and whether historical status needs to be traced back.
Metric definitions should also carry version information. When statistical rules change, historical reports should be able to state which version was used, avoiding one name mapping to different calculations.
A semantic layer is not a guarantee against all errors, but it turns rules scattered across personal experience and prompts into governable, testable assets.
4.2 Have the Model Generate Constrained Analysis Intent
In the natural-language-to-domain-specific-language path, the model first generates a structured analysis plan, which a controlled program then compiles into a query. The following is a pseudocode example used only to illustrate the structure, not a real product interface:
Analysis plan:Metric: valid order amountDimension: sales regionTime: this monthComparison: same period last monthReturn form: aggregated result
The system then checks whether the metric exists, whether the dimension is allowed, whether the time is explicit, and whether the user is authorized. When required information is missing, it should raise a clarification rather than silently guess.
This design narrows the model’s output space but does not automatically guarantee correctness. Wrong semantic mappings, compilation logic, and base data can still produce wrong results, so testing and auditing remain necessary.
4.3 Enforce Permissions at the Execution Layer
“Don’t access sensitive data” in a prompt is only behavioral guidance and cannot serve as reliable permission control.
Identity verification and authorization should be enforced at trusted execution layers such as the query gateway, semantic service, or database. The model should not hold a high-privilege account, nor should it decide which fields a user can access.
For cross-region and cross-department scenarios, row-level scope, field visibility, and metric permissions must be checked together. Export, caching, and session reuse must follow the same constraints, so that one user’s query result cannot be read by another user.
4.4 Build a Multi-Layer Validation Pipeline
At minimum, cover the following checks:
- Semantic check: whether the question matches the metric definition and whether clarification is needed;
- Structural check: whether fields, functions, join relationships, and query types are allowed;
- Permission check: whether the query scope matches the current identity;
- Resource check: whether execution time, returned rows, and computation scale are limited;
- Result check: whether there are abnormal nulls, duplicate aggregations, or unreasonable fluctuations;
- Explanation check: whether the generated text is faithful to the query result.
Anomaly detection can only flag doubts; it cannot replace business confirmation. The system should clearly distinguish “computed result,” “anomaly alert,” and “business inference.”
5. What a Traceable Answer Should Contain
A trustworthy analytical answer should let the user know where the number came from and how it was calculated.
Recommended to display or retain:
- The metric used and its definition version;
- The time range and filter conditions;
- The data update time;
- The execution record identifier;
- The data source or an accessible traceability entry point;
- Known limitations, such as data latency, missing values, or insufficient samples.
Result explanations should also separate fact from inference. “Revenue decline occurred mainly in a certain region” can be supported by grouped data; “the decline was caused by customer churn” requires further evidence. The model should not express correlation directly as causation.
When a query fails, permission is insufficient, or data is missing, the system should clearly state the reason and should not use a language model to fabricate numbers to keep the answer complete.
6. Selection and Acceptance: Validate Capabilities with Real Business Tasks
6.1 Build a Representative Question Set
The test set should include simple aggregations, year-over-year and period-over-period comparisons, cross-table joins, ambiguous metrics, privilege-escalation requests, and questions with no answer.
For example:
- “How are sales this month?”
- “By recognized revenue, which regions declined year over year?”
- “Why do the order counts differ between two reports?”
- “Show the customer details of another department.”
- “Can you provide the final settlement result when the data has not been updated yet?”
These questions validate not only query capability but also clarification, refusal, definition explanation, and the expression of uncertainty.
6.2 Evaluate Correctness and Usability Separately
Do not judge the system by answer fluency alone. It is recommended to record separately:
- Whether the metric and time basis match;
- Consistency of results with baseline queries;
- Whether permission isolation is effective;
- Whether ambiguous questions are correctly clarified;
- Whether any unauthorized data egress occurred;
- The number of interactions a user needs to complete a task;
- Query latency, resource consumption, and failure recovery.
Different scenarios need different acceptance standards. Core business and financial tasks should prioritize verifiable definitions and results; exploratory analysis can allow more clarification but still cannot bypass permissions and security boundaries.
6.3 Account for Full Lifecycle Cost
Beyond deployment and inference resources, also consider semantic modeling, data governance, test-set maintenance, permission adaptation, audit storage, and upgrade regression costs.
Enterprises with an existing analytics stack should focus on how much they can reuse; enterprises with development capacity should assess the maintenance burden of self-orchestration; enterprises with weak data governance should first unify core metrics and access rules, rather than handing foundational problems to the model to paper over.
7. Implementation Advice: Build a Reliable Loop from a Limited Scope
Start with high-frequency analysis tasks that have clear definitions and clear permission boundaries, such as regional business summaries, inventory structure analysis, or order trend queries. In the first phase, use read-only capability, restrict data sources and query scope, and do not yet open operations that modify business data.
The implementation order can be:
- Define the security domain and map the complete data flow;
- Organize core metrics, dimensions, and permissions;
- Build a controlled query and execution pipeline;
- Connect model understanding, clarification, and result explanation;
- Run acceptance testing with a baseline question set;
- Launch to a small scope and collect failure cases;
- Gradually expand coverage after regression testing.
In the end, data residency is not a deployment label but a security constraint that runs through inference, queries, logs, and operations; trustworthy analysis is not a single model capability but the combined result of semantic governance, permission enforcement, deterministic computation, and result traceability. Enterprises should make selection decisions around these verifiable capabilities, not around demo effects.
