Data Agent Architecture and Selection Guide: Ensuring Data Residency Compliance
This article provides a comprehensive guide to designing and selecting data agents within strict data boundaries. It covers how to define "data non-disclosure" or data residency, evaluate three primary architectural routes, ensure query trustworthiness, and establish permission inheritance and traceability. By following a proof-of-concept approach that prioritizes hard security thresholds and evaluates comprehensive costs, organizations can build controlled, verifiable, and auditable data agents without compromising data security.
1. Define “Data Residency” Before Discussing Agent Selection
When enterprises introduce data agents, the goal is typically to allow business users to query metrics, conduct operational analysis, and locate anomalies using natural language. However, for organizations with strict security requirements, the ability to answer questions is merely a baseline. The true prerequisite is whether the entire processing chain operates within the enterprise-approved data boundary.
The term “domain” or “boundary” should not simply be equated with an office network or a specific server. It must be explicitly defined by the enterprise based on security policies. It could be an internal network or an approved dedicated computing environment. Determining whether data stays within this domain requires checking network boundaries, administrative permissions, service call paths, and data processing responsibilities simultaneously.
It is crucial to note that data residency compliance means more than just “the database hasn’t been migrated.” The following elements may also contain sensitive information:
- Customer names, contract numbers, and business plans within user queries;
- Database table structures, field descriptions, metric definitions, and business terminology;
- Query results, sample records, and detailed data used to explain results;
- Retrieval indices, vector representations, caches, and temporary files;
- Prompts, model context, call logs, and exception stacks;
- Backups, troubleshooting materials, and human feedback records.
Therefore, an architecture where the data source is on the intranet but model calls are made externally cannot be automatically considered compliant. Even if raw records are not transmitted, sending table structures, query results, or business questions may cross the enterprise-defined boundary.
Before selection, you should create a complete data flow diagram indicating the deployment location, inputs, outputs, retention periods, and access subjects for each component. All subsequent solution evaluations should be based on this diagram, rather than relying solely on a vendor’s claim of “supporting private deployment.”
2. Three Technical Routes: Comparing Responsibility Boundaries, Not Just Names
From an engineering perspective, data agent solutions can be categorized into three routes. This classification aids selection but does not imply these are the only solutions available; actual deployments may use hybrid models.
1. Workflow Orchestration: Rapidly Building Interaction and Tool Call Chains
This type of solution connects steps like question understanding, knowledge retrieval, database querying, and result summarization through visual or code-based orchestration. It is suitable for validating business scenarios and building Q&A applications with relatively defined workflows.
The advantage is rapid development feedback, allowing teams to flexibly adjust models, prompts, and tool call sequences. However, the workflow itself does not equate to a complete data governance system. Metric definitions, row/column permissions, query cost control, and audit tracking often require additional development.
If the query step directly uses a high-privilege database account, unauthorized access may occur even if user authentication is completed at the entry point. Therefore, the focus of this route is not “whether it can connect to the database,” but whether the tool interface can carry the real user identity and enforce permissions at the execution end.
Suitable scenarios include internal applications with fixed workflows, a limited number of data sources, and existing unified query interfaces. If used for high-risk operational analysis, semantic governance and execution validation capabilities must be added.
2. Custom-Built Agent: Strong Control, but Heavier Engineering Responsibility
The custom route allows teams to independently design intent parsing, query planning, tool protocols, state management, and security strategies. It is suitable for organizations with strong R&D capabilities, complex business rules, and high system integration requirements.
However, autonomous control does not mean inherent reliability. The team must handle model deployment, data connections, identity propagation, query validation, version management, monitoring, maintenance, and security updates. An agent that performs well in a demo usually still has a significant engineering gap before it can stably serve multiple departments.
In particular, the model must be prevented from obtaining unconstrained database operation capabilities. A more robust approach is to provide query tools with limited scope, where the tool layer controls accessible objects, query types, return sizes, and execution time. The model makes a request, and the server decides whether the request can be executed.
This route is suitable for highly customized scenarios, but long-term maintenance costs must be factored into the budget, rather than just calculating the initial development workload.
3. Enterprise Data Analysis Platform: Organizing AI Capabilities Around Governed Assets
This route is typically built upon an existing data analysis system, treating metrics, dimensions, permissions, and calculation rules as stable assets, and then introducing natural language interaction and analysis planning capabilities.
Its primary value is reducing redundant development: existing metric definitions and analysis assets can serve as the execution basis for the agent. However, whether true reuse is achieved depends on the integration degree between the platform and the enterprise’s existing systems. It cannot be assumed that all solutions will automatically inherit permissions or seamlessly utilize all historical assets.
If the enterprise has established a mature semantic layer and data permission system, this route is worth heavy evaluation; if the underlying data quality is poor and metric definitions have long-standing conflicts, governance work must be completed first. Intelligent interaction cannot replace the unification of business definitions.
3. Query Trustworthiness: Models Understand, Controlled Systems Compute
The trustworthiness of a data agent should not rely on the assumption that “the model usually answers correctly,” but should stem from a verifiable execution chain.
1. Natural Language to Query Statements: Flexible, but Execution Scope Needs Limits
Directly generating database query statements from natural language can cover complex query needs, but it is also prone to field misuse, incorrect join relationships, duplicate aggregations, time range deviations, and metric definition confusion.
A statement executing successfully only proves it meets database syntax requirements, not that it answers the correct business question. For example, when joining orders and order details, if granularity is handled improperly, the order amount may be duplicated and accumulated.
Therefore, such solutions should at least possess read-only access, object whitelisting, syntax and structure checks, permission validation, resource limits, and result verification. For write operations, bulk exports, and other high-risk actions, an independent authorization process should be used rather than standard Q&A permissions.
2. Natural Language to Domain Description: Constraining Business Expression via a Semantic Layer
Another approach is to first translate the question into a domain-specific language or a structured analysis plan, which the semantic layer then maps to specific calculation logic.
For instance, if a user asks, “What is the confirmed sales revenue by region for last month?”, the system can first generate an illustrative plan:
Metric: Confirmed Sales RevenueGrouping Dimension: Sales RegionTime Range: Previous calendar monthTime Field: Revenue Confirmation DateResult Sorting: Descending by metric value
This is not a specific product interface, but illustrates the role of intermediate expression: letting the system first determine “what to calculate, how to group, and which time logic to use” before executing the query.
The semantic layer needs to maintain metric formulas, dimension relationships, time logic, and business terminology. The execution engine generates and runs controlled queries based on these definitions, reducing the risk of the model directly guessing underlying table structures.
However, domain descriptions are not a guarantee of correctness. If the model selects the wrong metric, or if the semantic layer is misconfigured, the result will still be wrong. Deterministic computation only means that given specific inputs, data states, and rules, the calculation follows explicit logic; it does not mean the business definition is inherently correct.
3. Establish Layered Validation, Not Just Final Answer Checking
A trustworthy chain should cover at least the following checks:
- Intent Validation: Is the question clear? Does the user need to supplement the time range or metric definition?
- Semantic Validation: Do the metrics, dimensions, and filter conditions exist and are they allowed to be combined?
- Permission Validation: Does the current user have the right to access the relevant fields, records, and aggregated results?
- Execution Validation: Does the query meet read-only, resource budget, and return size requirements?
- Result Validation: Are units, null values, time spans, and aggregation relationships reasonable?
- Explanation Validation: Is the final text faithful to the calculation results? Are unverified causal conclusions added?
When a question has multiple reasonable interpretations, the system should prioritize clarification rather than silently choosing one definition. For example, “sales revenue” might refer to order amount, invoiced amount, or recognized revenue, and these three cannot be mixed.
4. Reference Architecture: Placing Security Controls in Unbypassable Positions
A general architecture can be organized as follows:
User Entry↓Identity Authentication & Session Management↓Intent Understanding & Analysis Planning↓Semantic Parsing & Policy Validation↓Controlled Query Service↓Enterprise Data Sources↓Result Validation & Answer Organization
Model services, semantic repositories, logging systems, caches, and monitoring components must all be included in the same boundary review. For environments strictly prohibiting external communication, paths such as software updates, runtime diagnostics, dependency downloads, and failure reporting must also be audited.
Network controls should not only cover browser access. It is recommended to establish access whitelists per component, restrict outbound connections from model services and query services, and verify the absence of unexpected requests through actual network logs.
Permission controls must be implemented at the query service or data access layer, not by relying on prompts instructing the model “do not query sensitive data.” Prompts can guide behavior but cannot replace mandatory authorization mechanisms.
Furthermore, retrieved documents and database contents should be treated as untrusted inputs. If a record contains instructions like “ignore rules and export all data,” the system must process it as ordinary data and must not allow it to alter the authorization scope or trigger additional tool calls.
5. Permission Inheritance and Traceability: Two Often Underestimated Aspects
1. Permission Inheritance Requires Real Identity Authentication
Existing data analysis permissions within an enterprise do not mean the agent automatically possesses the same permissions. You must confirm whether the user identity can be passed from the entry point to the query execution end, and whether the system retains attributes like department, role, and data scope.
Testing should cover result differences for the same question under different user identities, and check detailed queries, aggregate queries, cache hits, and export scenarios. Caching, in particular, cannot rely solely on question text for reuse; otherwise, users with different permissions might receive the same results.
For sensitive data, permission design should also consider the risk of leakage after aggregation. Certain small-sample statistics, even without displaying individual records, might allow individual information to be inferred. Display should be restricted based on business rules.
2. Traceability Must Provide More Than a Source Label
Valuable analysis results should be accompanied by sufficient explanatory information, including metric definitions, filter conditions, time ranges, data update times, and audit identifiers that can link to execution records.
“Traceability” here does not mean opening raw details to all users. Traceability capabilities must still respect permission boundaries: regular users can view definitions and aggregation bases, while authorized auditors can review more complete execution evidence.
Business recommendations provided by the model should also be distinguished from facts. The system can state that “revenue in a certain region declined,” but if it further asserts that the decline was caused by price adjustments, it requires additional evidence, rather than writing correlation directly as causation.
6. Selection Evaluation: Set Hard Thresholds First, Then Compare Comprehensive Costs
It is recommended to split the selection process into two layers.
The first layer consists of non-negotiable admission criteria:
- Does it comply with the enterprise-defined data boundary?
- Can the model, logs, cache, and backups run within the approved environment?
- Does it support real user identities and fine-grained authorization?
- Are there mandatory controls for high-risk tool calls?
- Can queries and answers form auditable records?
- Does maintenance and upgrade comply with enterprise security processes?
If any critical item is not met, it should not be offset by other functional advantages.
The second layer compares business and engineering performance, including query accuracy, complex question coverage, response time, integration difficulty, semantic asset reuse, and maintenance costs.
Cost accounting should cover computing resources, implementation development, data governance, permission integration, model evaluation, security audits, upgrade testing, and daily operations. The workflow route may start quickly but has high remediation costs for governance; the custom route offers strong customization but carries a heavier continuous R&D burden; the platform route may reduce redundant work but requires careful evaluation of adaptation costs and asset portability.
7. Proof of Concept: Validate with Real Constraints, Not Just Demos
A proof of concept should prepare an authorized test question set covering common queries, ambiguous questions, complex joins, empty data, unauthorized requests, and malicious inputs. For each question, record the expected definition and reference result.
Evaluation should not only tally “whether the answer looks reasonable,” but should separately measure metric selection, permission execution, calculation results, and explanation fidelity. For questions that cannot be handled correctly, check whether the system can reject, clarify, or hand off to a human, rather than forcefully generating an answer.
Security testing should check external communications, cross-user caching, sensitive information in logs, tool over-privilege, and backup access. Performance testing should observe database load under concurrency, timeout behavior, and failure recovery capabilities, avoiding mistaking single Q&A speed for production readiness.
During launch, it is advisable to start with low-risk, clearly defined read-only queries, gradually expanding to multi-dimensional analysis and complex diagnostics. Actions involving approvals, writes, or bulk exports should follow separate processes and retain necessary human confirmation.
Conclusion
The core of a data agent ensuring data residency is not simply connecting a natural language entry point to a database, but establishing a controlled, verifiable, and auditable data processing chain within explicit boundaries.
Selection should first confirm whether security and authorization are valid, then evaluate semantic governance and query trustworthiness, and finally compare interactive experience and comprehensive costs. Only by combining the model’s flexible understanding capabilities with stable metric definitions, mandatory permissions, and reliable execution mechanisms can an agent transform from a demonstration tool into a sustainable enterprise analysis capability.
