Data Agent Architecture with In-Domain Data Processing: An Enterprise Selection Guide
This guide explains how enterprises can build data agents that answer natural-language questions without letting data leave a controlled domain. It covers defining verifiable data boundaries, three technical implementation routes (workflow orchestration, self-built controlled query services, and unified semantic layer platforms), converting natural language into reliable data operations, a recommended seven-module closed-loop architecture, result traceability and validation, acceptance testing for vendor selection, and a phased rollout strategy. The core principle: the model handles understanding and suggestions, trusted services handle authorization and execution, semantic rules ensure consistent metric definitions, and audit evidence supports verification.
1. Start with the Right Goal: A Data Agent Is Not a Chat Window Connected to a Database
A data agent is a system that understands natural-language requests, invokes data query and analysis capabilities, and organizes results into readable answers. Users might ask “Why did revenue decline across regions this quarter?” or “Which devices show a significantly higher anomaly rate?” The system must then perform intent recognition, metric lookup, query planning, controlled execution, and result explanation.
This is fundamentally different from general text generation. A text answer can express uncertainty, but enterprise business data typically corresponds to explicit statistical definitions, authorization scopes, and time boundaries. An answer that is fluent and includes polished charts is still wrong if it confuses revenue recognition timing or ignores organizational permissions.
When evaluating data agents, enterprises should break the goal into four layers:
- Understand: Correctly identify the user’s question, terminology, and context.
- Execute: Translate the question into executable, controllable data operations.
- Verify: Check metric definitions, query processes, and output results.
- Govern: Operate continuously under identity, permission, network, and audit constraints.
Natural-language interaction lowers the barrier to use; it should not lower data governance standards.
2. “Data Never Leaves the Domain” Must Be an Auditable Boundary
The “domain” is not automatically equivalent to a data center or private network. It must be explicitly defined by the enterprise based on data classification, system ownership, network isolation requirements, and management responsibility. Without a defined boundary, there is no way to judge whether data actually stays within a controlled environment.
2.1 More than raw data must stay in-domain
Running a data agent produces multiple types of content that may contain sensitive information:
- User questions and conversation history;
- Table schemas, field descriptions, and business terminology;
- Query conditions, execution plans, and query results;
- Document fragments used for retrieval and their vector representations;
- Model inputs, outputs, runtime logs, and error stacks;
- Temporary files, caches, exported files, and backups.
For example, even without uploading a full data table, embedding customer names, transaction amounts, and anomaly records into an external model request may constitute data leakage. Vector representations should not be treated as anonymous data either—their risk must be assessed based on source, usage, and access conditions.
2.2 On-premises deployment does not automatically create a closed loop
Deploying the application on an intranet only proves the application entry point is on the intranet; it does not prove that the entire processing chain stays there. Model inference, text vectorization, content inspection, telemetry reporting, and fault diagnosis can all create additional network connections.
Technical teams should draw a complete data flow diagram identifying where each component runs, its inputs and outputs, storage locations, and network destinations. For scenarios that strictly prohibit data from leaving the domain, key components such as inference, retrieval, execution, logging, and backup must all run within the approved boundary, with outbound access controlled by explicit rules.
Whether industry compliance requirements are met must be judged based on applicable regulations, actual system configuration, and audit results—not deployment form alone.
3. Three Technical Routes for Enterprise Implementation
The routes differ not in whether they have a conversational interface, but in where semantic governance lives, who executes queries, and which capabilities must be built in-house.
Route 1: General workflow orchestration plus data query tools
This approach connects the model, knowledge retrieval, and database query services through a workflow. It suits rapid validation of interaction patterns or narrow-scope business assistants.
Its advantage is flexible composition—query, approval, and notification steps can be chained together. But general orchestration capability is usually not equivalent to mature data analysis governance. Metric mapping, row- and column-level permissions, query limits, error recovery, and audit trails must be implemented by the team piece by piece.
If you simply hand a database connection to the model and let it generate and execute queries freely, risks concentrate in three areas: misunderstanding table relationships, inconsistent metric definitions, and excessive tool-call permissions.
A safer approach is to provide an encapsulated read-only query service where the server controls accessible datasets, filter conditions, and resource consumption. The workflow organizes steps; it should not act as the final authorization authority.
Route 2: Self-built controlled query service
Here the enterprise builds a unified data access service, and the model only produces structured query requests or candidate query statements. Identity verification, permission checks, statement validation, and actual execution are all performed server-side.
For teams with few datasets, clear business rules, and strong engineering capability, this route supports incremental construction. Initially it can support only fixed metrics and limited dimensions, then expand the analysis scope.
The main cost is continuous maintenance. As the business grows, metric changes, schema adjustments, cross-table joins, and exception handling continuously increase engineering complexity. Without unified semantic management, the system tends to accumulate scattered prompts, query templates, and patch rules.
A self-built solution should therefore maintain the query service as a long-term product, not a one-off interface.
Route 3: Data agent platform based on a unified semantic layer
This route centrally manages metrics, dimensions, business terms, relationships, and authorization rules. The model first understands the question, then generates a constrained analysis request, which the semantic layer resolves into an executable plan.
For enterprises that already have reporting systems, metric management, and data permission foundations, this architecture can reuse existing assets and reduce the cost of redefining metrics. Whether reuse actually works depends on data asset quality, permission model compatibility, and integration approach—do not assume every enterprise can plug in directly.
The main investment in a platform approach is often not the conversational interface but semantic cleanup: which metrics are authoritative, which dimensions can be joined, which historical definitions need to be distinguished, and who approves changes.
During selection, prioritize checking whether these governance capabilities are configurable, verifiable, and portable—rather than just comparing demos.
4. Turning Natural Language into Reliable Data Operations
4.1 Benefits and risks of direct query generation
Natural-language-to-query generation covers flexible questions, but the model must understand underlying table structures, join relationships, time fields, and business rules. In complex scenarios, a statement can execute successfully without answering the right question.
For example, “sales” might mean tax-inclusive order amount, recognized revenue, or actual receipts. If the system has no explicit definition, successful execution proves nothing about correctness.
Direct query generation is not off-limits, but it should run in a controlled environment with statement parsing, permission constraints, resource limits, and business testing.
4.2 Constraining query intent through domain representations
An alternative is to first convert natural language into a domain-specific expression, then let the semantic layer generate the execution plan. Below is a conceptual analysis request, not an interface of any specific product:
Analysis request:Metric: Recognized revenueDimension: RegionTime: Current quarterComparison: Same quarter last yearSort: YoY decline, highest first
This type of expression hides underlying join details, so the model focuses on “what to analyze” rather than freely deciding “how to access arbitrary data.”
The server then checks whether the metric exists, whether dimensions can be combined, whether the user is authorized, and whether the time range is explicit, before converting it into an execution plan.
This design reduces unconstrained query generation but does not eliminate errors. Wrong semantic definitions, poor source data quality, or model misunderstanding of intent can still affect results.
4.3 Deterministic execution does not mean a correct business conclusion
Deterministic execution means consistent results given the same data, rules, and inputs—it does not mean metric definitions are inherently correct.
A trustworthy answer depends on at least three conditions:
- The input question is correctly understood;
- Business semantics and data relationships are accurate;
- Execution strictly follows validated rules.
If any link is missing, successful execution by the compute engine alone cannot make an answer trustworthy.
5. Recommended In-Domain Closed-Loop Architecture
The system can be divided into seven modules with clear responsibilities:
User entry→ Identity and session management→ In-domain model understanding and analysis planning→ Semantic parsing and policy checks→ Controlled query execution→ Result validation and answer composition→ Audit logging and runtime monitoring
Retrieval services, data catalogs, and metric definitions provide context for the understanding and validation stages; caches and storage follow unified data protection requirements.
5.1 The model proposes; the server decides whether to execute
Any tool call generated by the model should be treated as input pending validation. Authorization decisions must be made on a trusted server—never by instructing the model via prompt to “avoid sensitive data.”
The execution service should use least-privilege identities. Read scenarios should default to read-only capabilities, with no database administration permissions exposed to the model. If write operations are needed in the future, add independent authorization, manual confirmation, and rollback mechanisms.
5.2 Permissions must cover the full chain
Controlling permissions only on query results is insufficient. Metric catalogs, field descriptions, retrieved documents, and cached content can also leak information.
Cross-user shared caches deserve particular caution. If cache keys contain only the question text without the user’s permission scope and data version, results from a high-privilege user may be returned to a lower-privilege user. Cache policies must be tied to identity, authorization context, and invalidation rules.
5.3 Query cost must be constrained
Legitimate queries can still create resource pressure. The execution layer must limit scan scope, returned rows, concurrency, execution time, and high-risk join operations.
When a question exceeds limits, the system should ask the user to narrow the scope or route to a controlled asynchronous analysis flow—rather than retrying indefinitely. Specific thresholds should be determined through testing based on data scale and business requirements; uniform values should not be applied blindly.
6. Making Results Traceable, Not Just Plausible
Result validation can be split into three stages.
Pre-execution validation: Check terminology, metrics, dimensions, time ranges, and authorization conditions. For ambiguous expressions like “current period” or “key customers,” ask for clarification.
In-execution validation: Check query structure, permitted data objects, resource consumption, and execution status to ensure the actual plan does not deviate from the authorized scope.
Post-execution validation: Check for empty results, outliers, duplicate aggregations, units, and comparison intervals. Sanity checks can surface problems but cannot substitute for correct data modeling.
The final answer should carry appropriate evidence, including metric definitions, statistical scope, data freshness, key filter conditions, and traceable identifiers. Evidence display must itself respect permissions, avoiding exposure of underlying information the user is not entitled to see.
When a user asks “why did revenue decline,” the system can provide a decomposition of changes by region, product, or customer structure—but should distinguish contribution analysis from causal conclusions. A dimension moving in sync with the decline is not proof that it caused the decline.
7. Select Through Acceptance Testing, Not Feature Checklists
Enterprises can build a unified evaluation matrix:
| Dimension | Key checks |
|---|---|
| Data boundary | Are inference, retrieval, logs, caches, and backups within the approved scope |
| Semantic governance | Are metrics uniformly defined; can versions and changes be managed |
| Permission control | Does it cover row/column permissions, tool calls, retrieval, and caching |
| Execution safety | Read-only isolation, query validation, and resource limits |
| Result trustworthiness | Metric definitions, data freshness, and query tracing |
| Engineering maintenance | How rules and tests are updated after schema changes |
| Integration cost | Can existing identity, data catalogs, and analytics assets be reused |
The acceptance test set should cover real business questions, not only easy demo questions. It should include at least normal queries, ambiguous questions, unauthorized access attempts, empty data, cross-time comparisons, complex joins, and anomalous data.
Add prompt injection tests as well: embed text in user input or retrieved material that instructs the system to ignore rules or expand access, and verify that execution remains governed by server-side policy. Retrieved content should be treated as business material, never as new system instructions.
Evaluation results should distinguish intent understanding errors, semantic mapping errors, execution errors, and interpretation errors. Only by locating the specific layer can you decide whether to fix the model prompt, metric definition, or data service.
8. Start with a Small Closed Loop, Then Expand
A four-phase rollout is recommended.
Phase 1: Define the data boundary, sensitivity levels, identity sources, and permitted datasets, and produce an auditable data flow diagram.
Phase 2: Choose a business domain with stable metric definitions and good data quality, establish a small set of authoritative metrics and test questions, and validate the end-to-end pipeline.
Phase 3: Complete permission enforcement, auditing, cache isolation, query throttling, and exception handling before opening a pilot to real users.
Phase 4: Expand metrics, analysis dimensions, and business scenarios based on error classification and user feedback, while continuously running regression tests.
In long-term operation, metric changes, permission adjustments, and schema changes should be incorporated into the release process. After model or rule upgrades, re-validate existing questions to avoid improving the interaction experience while breaking result consistency.
Conclusion
A data agent that keeps data in-domain is, in essence, a governed data analysis system—not a model with database access.
Workflow orchestration suits validating interactions and organizing processes; self-built query services suit engineered control within a defined scope; unified semantic platforms suit continuously managing complex data analysis assets. Whichever route you choose, hold to the same principle: the model handles understanding and suggestions, trusted services handle authorization and execution, semantic rules ensure consistent metric definitions, and audit evidence supports verification. Only when these capabilities form a closed loop can natural-language data querying evolve from a demo feature into a reliable enterprise application.
