Data Doesn't Leave the Domain: Architecture and Selection Guide for Enterprise Data Agents
Enterprises deploying data agents face a core constraint: keeping all data within authorized boundaries. This guide explains what "data stays in the domain" actually means beyond local deployment, compares three architectural routes—general agent orchestration with self-built tools, controlled query-based analytics (NL2SQL), and semantic-layer-driven systems (NL2DSL)—and recommends a production architecture that separates understanding, authorization, and execution. It also provides evaluation criteria, a phased rollout plan, and key questions to verify data boundaries, semantic consistency, query reliability, and auditability.
1. The Value of a Data Agent Goes Beyond Converting Natural Language to Queries
Traditional data analysis typically involves requirement gathering, metric confirmation, query development, result verification, and business interpretation. Even after an enterprise has built out reporting systems, business users may still depend on the data team for ad hoc questions. For example, “Why did revenue decline across regions this quarter?” involves not just data extraction, but also confirmation of the time range, revenue definition, organizational hierarchy, and comparison baseline.
A data agent attempts to organize these steps into an interactive analysis flow: understand the question, identify metrics, plan queries, call controlled tools, explain results, and continue the analysis based on user feedback.
But “being able to answer” does not mean “answering credibly.” In enterprise deployment, at least three problems must be solved:
- Is the data boundary clear? Are questions, data, model inputs, and runtime logs flowing to unauthorized environments?
- Are analytical definitions consistent? Do the system’s understandings of “revenue,” “customer count,” or “completion rate” align with the enterprise’s official definitions?
- Is execution controlled? Can queries exceed permissions, potentially drag down the database, and can results be reviewed?
Therefore, building a data agent is not simply about connecting a model. It means embedding model capabilities into the enterprise’s existing data governance, security controls, and analysis execution systems.
2. Define the “Domain” Before Talking About “Data Staying In-Domain”
“Data doesn’t leave the domain” is not an attribute determined solely by deployment location. Enterprises must first clarify what the “domain” actually means: the corporate intranet, an isolated network, a specific regional data center, or an approved dedicated runtime environment.
Different organizations define boundaries differently, but the judgment criterion should be consistent: all data flows are within authorized scope and can be verified.
1. What Needs Boundary Management Is More Than Business Tables
In addition to the raw records in databases, the following may also contain sensitive information:
- Customer names, transaction information, and internal business goals mentioned in user questions
- Table schemas, field descriptions, metric formulas, and business rules
- Detail rows, aggregated results, and exported files returned by queries
- Conversation history, session memory, retrieval indexes, and caches
- Model call records, error logs, audit records, and backups
For example, even if the database is deployed on an internal network, if the application submits query results containing customer names to an external model for summarization, it can still violate data boundary requirements.
2. Local Deployment Does Not Automatically Mean End-to-End Data Containment
Deploying models and applications locally is an important foundation for controlled data flows, but you also need to check whether the runtime has external calls.
Common check items include model request addresses, external knowledge retrieval, runtime telemetry, error reporting, online updates, remote operations, and backup replication. Strictly isolated scenarios should also configure outbound access control and verify through network logs that the system has no unapproved external connections.
A more reliable approach is to draw a data flow diagram and annotate each link with the transmitted content, recipient, purpose, retention period, and access permissions. Selection discussions should revolve around this diagram rather than relying solely on a “supports private deployment” description.
3. Three Construction Routes: Compare Mechanisms, Not Labels
Enterprise data agents can generally be categorized by their primary construction approach. These categories are not mutually exclusive, and real systems may combine them.
Route 1: General Agent Orchestration with Self-Built Data Tools
These solutions center on conversation flow and tool calling, with the technical team building database query, metric services, document retrieval, and permission verification capabilities themselves.
The advantage is flexibility: multi-step analysis flows can be designed around business needs, and analysis results can be integrated into other internal systems. For teams with strong development capabilities that need special interaction logic, this is a viable path.
However, orchestration capability is not data governance capability. Metric definitions, query constraints, row/column permissions, cache isolation, and audit traceability typically must be built by the team itself. If the loop only completes “model generates query, database returns results, model summarizes,” the system may still lack production-grade security and reliability guarantees.
Its cost cannot be calculated only by prototype development time; it should also include permission adaptation, exception recovery, regression testing, and long-term operations.
Route 2: Controlled-Query-Based Data Analysis Applications
These solutions build interactive entry points around data queries. A common mechanism is natural language to structured query, i.e., NL2SQL.
The model generates candidate queries based on the question and data structure, then the system executes checks, runs the query, and returns results. This approach adapts fairly directly to existing well-structured datasets, but its reliability depends on several prerequisites:
- The data model is clear, with reliable descriptions of table relationships and field meanings
- Query accounts follow least privilege, generally allowing only necessary read-only operations
- Syntax, permission, and resource constraint checks are performed before query execution
- Special validation is applied to complex joins, aggregation granularity, and time conditions
- Ambiguous questions are clarified before queries are generated
Here it is important to distinguish between a “legal query” and a “business-correct query.” A query can be syntactically valid yet produce wrong results—duplicating values due to a join between orders and order line items, or misinterpreting a natural month as a fiscal month.
Therefore, NL2SQL should not be dismissed outright, nor treated as inherently accurate. It is suitable for use within clear data scopes and under sufficient constraints.
Route 3: Semantic-Layer-Driven Enterprise Analysis Systems
This route prioritizes reusing the enterprise’s existing metrics, dimensions, analytical models, and permission rules. The model first maps user intent into a constrained analytical expression, then an analysis engine generates and executes the query.
One implementation approach is natural language to domain-specific language, i.e., NL2DSL. A DSL can express metrics, dimensions, filters, time ranges, and sort orders without directly exposing the full underlying table structure.
Its main value is narrowing the range within which the model can freely act. The model is responsible for understanding what the user wants to analyze, the semantic layer determines metrics and business rules, and the execution engine completes calculations according to the rules.
However, note that deterministic execution does not guarantee correct results. If metric definitions are wrong, relationships are distorted, or data updates lag, the system will still stably produce wrong results. The reliability of the semantic layer route comes from the combination of governance quality, constrained expressions, and verification mechanisms—not from a technical acronym itself.
4. Recommended Architecture: Separate Understanding, Authorization, and Execution
A production-ready data agent can be organized by the following responsibilities:
User question↓Identity authentication and session context↓Intent recognition, terminology matching, and necessary clarification↓Constrained analysis plan↓Permission checks, semantic validation, and resource control↓Query execution and result validation↓Result-based explanation, presentation, and audit records
1. Semantic Governance Layer: Turn Business Definitions into Executable Rules
A metric definition should include at least the name, business meaning, calculation method, default time basis, applicable dimensions, data source, owner, and version.
For example, “sales” might refer to order amount, net sales after refunds, or recognized revenue. Without a unified definition, the model can only guess based on language conventions.
Semantic governance should also cover synonyms, organizational hierarchies, unit conversions, and special exclusion conditions. For questions with multiple reasonable interpretations, the system should let the user choose the definition rather than defaulting to a seemingly definite answer.
2. Authorization Layer: Permissions Must Be Enforced in the Execution Chain
Permissions must not merely be requested in the prompt, such as telling the model “do not access sensitive data.” Prompts are not a reliable access control mechanism.
Permissions should be enforced in the service layer and data access layer, covering accessible datasets, row-level scope, column-level restrictions, masking requirements, and export policies. When the system inherits existing permissions, identity mapping and permission semantics must be verified for consistency; it cannot be assumed that they take effect automatically after integration.
Caching must also consider authorization. If different departments share the same query cache without distinguishing user permission scopes, indirect leakage can occur. Retrieval, queries, cache hits, and result downloads should all follow consistent authorization rules.
3. Execution Layer: Prevent Correct Queries from Becoming Operational Incidents
Even read-only queries can strain resources through large scans or complex joins. Production environments should set query timeouts, concurrency quotas, result row limits, and necessary scan range constraints.
For expensive analyses, asynchronous tasks can be used, or users can be guided to narrow the time range. For requests that exceed authorized scope or resource budgets, the system should explicitly reject them or ask for adjustments rather than silently modifying the question and returning results.
4. Explanation Layer: Conclusions Must Have Evidence Boundaries
Answers should state which metrics were used, which time period was analyzed, which filters were applied, and when the data was last updated.
At the same time, distinguish facts, inferences, and claims requiring verification. “The revenue decline mainly comes from a certain region” can be verified through contribution decomposition; “the decline is due to reduced customer satisfaction” requires additional evidence and cannot be asserted causally based only on sales data.
5. Understanding Reliable Analysis Through One Example
Suppose a user asks: “How much did sales in the East China region decline year over year this year?”
The system should first confirm whether “this year” means year-to-date through the current date or the full calendar year; whether sales excludes refunds; and which organizational version “East China region” corresponds to.
If the user actually wants a year-to-date year-over-year comparison, the prior year should use the comparable time interval rather than the entire previous year. If the historical organization has changed, the system must clarify whether to recast history according to the current organizational structure.
An illustrative constrained analysis plan can be written as:
Metric: Net salesDimension: RegionFilter: Region belongs to East China scopeCurrent period: Start of this year to the specified end dateComparison period: The corresponding date range in the previous yearOutput: Current value, comparison value, year-over-year change rateException rule: When the comparison value is zero, do not output a regular YoY percentage
This is not a product interface but an illustration of what information an analysis plan should contain.
After execution, the system should also check whether the data is complete, whether currencies are consistent, whether refunds span periods, and whether comparison bases are anomalous. Finally, when presenting conclusions, it should display key values alongside the definition notes so users can verify them.
6. Selection Evaluation: Turn Capability Claims into Verification Items
When evaluating solutions, require candidates to complete validation in a controlled environment rather than just watching a demo.
| Evaluation dimension | Key verification items |
|---|---|
| Data boundary | Whether model requests, logs, caches, and backups flow outside the domain |
| Deployment fit | Whether it fits existing network, identity, and operations requirements |
| Metric consistency | Whether it correctly handles synonyms, definition differences, and metric versions |
| Query reliability | Whether it identifies duplicate joins, time misalignment, and aggregation granularity errors |
| Permission control | Whether it prevents cross-department access and sensitive field exposure |
| Traceability | Whether it records analysis plans, sources, definitions, and execution status |
| Operational stability | Whether it has timeout, rate limiting, monitoring, and failure recovery capabilities |
| Ongoing cost | Whether it requires heavy maintenance of semantic configurations, tools, and test sets |
The test set should include real business questions and cover normal questions, ambiguous questions, unauthorized questions, no-data questions, and anomalous-data questions.
Evaluation metrics should not focus only on answer success rate. Also pay attention to definition accuracy, permission interception effectiveness, clarification quality, result traceability, and query resource consumption. For high-risk errors, set launch-blocking conditions instead of letting overall average performance mask problems.
7. Phased Rollout: Build a Trusted Loop First, Then Expand Scope
Phase 1: Choose a Pilot with Clear Boundaries
Prioritize scenarios with stable metrics, good data quality, and clear permission relationships. Initially focus on queries and explanations; do not open data modifications, automated approvals, or large-scale exports.
The pilot’s goal is to validate the complete chain, not to cover all business questions.
Phase 2: Establish Acceptance and Regression Mechanisms
For each test question, save the expected definition, reference results, and allowed error margins. Whenever models, prompts, semantic configurations, or database structures change, re-run the key tests.
When the system cannot reliably understand a question, asking for additional information is more valuable than generating a superficially fluent answer.
Phase 3: Gradually Expand Analysis Depth
After basic queries are stable, introduce contribution decomposition, multi-turn follow-ups, and cross-metric analysis. Cross-dataset analysis especially requires checking join granularity to avoid duplicate calculations or misleading comparisons.
Phase 4: Establish Long-Term Governance Responsibilities
Business teams own metric definitions, the data team owns models and quality, the security team owns boundaries and authorization, and R&D and operations teams own execution stability and change management.
Without clear owners, both the semantic layer and test sets will easily become stale as the business changes.
8. Conclusion: Security, Accuracy, and Governability Must Hold Together
Data staying in the domain is a precondition for enterprise data agents, not the ultimate goal. A truly sustainable system must simultaneously achieve verifiable boundaries, manageable definitions, controllable queries, and traceable results.
The general orchestration route emphasizes flexibility, the controlled-query route emphasizes direct data analysis capability, and the semantic-layer route emphasizes reuse of existing governance assets. Which route to choose should depend on data maturity, development capability, permission complexity, and business risk—not on a technical label.
The soundest approach is to first define the data boundary, then establish semantic and permission constraints, and then validate the entire execution chain with real questions. Only in this way can natural language interaction move from a demo capability to a trusted enterprise analysis entry point.
