AI Agent Self-Hosting: Separate Data Retention from Outbound Data Flow
Self-hosting an AI agent does not automatically mean all data stays local. This article explains why retention and outbound inference traffic must be evaluated separately, breaks the agent stack into execution, service and control, and model inference layers, and provides a review checklist and practical controls for documenting data boundaries.
1. Clarify What “Hosting” Means
In the context of AI agents, “hosting” usually means handing part of the infrastructure needed to run an agent to a provider for maintenance. Common hosted components include the run loop, session and state storage, credential management, and the tool execution environment. Hosting boundaries vary widely across options. If they are all grouped under the single term “hosting,” decision-makers may assume that all data has left the local environment or that all of it still remains local.
In practice, evaluation should be split into two questions: which data is stored in whose system, and where data is sent on each model call. The answers to these questions are independent and cannot replace each other.
2. Three-Layer Structure of an Agent System
A runnable agent broadly consists of three parts:
| Layer | Responsibility | Typical data |
|---|---|---|
| Execution environment (sandbox) | Isolate command execution, file reads and writes, and external tool calls | Temporary files, command output, working directory |
| Service and control plane | Receive requests, drive the agent loop, store sessions and state, manage credentials | Session history, task state, access credentials, permission configuration |
| Model inference | Generate responses or tool-call instructions from context | Request context, model output |
Differences in deployment form essentially come down to who operates each layer:
- Fully managed: The provider runs all three layers, and the customer is mainly responsible for business logic and integration.
- Self-hosted execution layer: The sandbox remains on the customer side, while the service and inference are still provided by the provider. Files and command output in the execution layer no longer pass through the provider’s execution environment.
- Self-hosted service layer: The sandbox, service, and control plane are run by the customer, and sessions and credentials are stored by the customer. Inference usually still calls an external model service.
A layered view helps teams write clear responsibility boundaries. The same “self-hosted” label may cover only one layer or two.
3. Retention and Outbound Transfer Must Be Checked Separately
3.1 Retention: Where Data Lives and Who Deletes It
Session history, credentials, and audit logs are retention issues. At a minimum, the following four points should be answered:
- In which region is the database or object storage located, and which team operates it?
- How long is data retained, which party triggers deletion, and does deletion cover backups and logs?
- How are access permissions divided, and which roles can read session content?
- Are credentials stored encrypted, who performs rotation, and who revokes them after a leak?
3.2 Outbound: Where Requests Go and What They Carry
Model calls are another data path. Each agent step usually packages system instructions, history messages, tool inputs, and tool results into an inference request. The following is an illustrative request structure; the field names are for explanation only and are not the real format of any specific API:
{"endpoint": "<inference service endpoint>","messages": [{"role": "system", "content": "system instructions"},{"role": "user", "content": "user input"},{"role": "tool", "content": "file content or query result returned by a tool"}],"tools": ["tool definition list"]}
Tool results often contain business data or personal information. Even if the session store is deployed locally, this content still leaves the local network with the inference request. Therefore, “data does not leave the network” cannot serve as a deployment conclusion; it describes only part of retention.
4. Applicable Boundaries of Zero Data Retention
Zero Data Retention (ZDR) refers to a class of contractual and technical arrangements that constrain how an inference provider stores request and response data after returning a response. ZDR governs the inference provider’s storage behavior and is separate from where sessions are stored.
This leads to two judgments:
- Moving session history to an owned database does not automatically give inference requests zero-retention eligibility.
- Whether zero retention applies depends on the model used, enabled features, the provider, and contract terms. Deployment form alone cannot establish these conclusions; they must be confirmed item by item.
If certain features create logs, diagnostic records, or caches on the provider side, this content may fall outside the scope of zero retention. Such features should be listed as separate items during review.
5. What Self-Hosting Shifts and What It Does Not
Self-hosting usually shifts the following responsibilities:
- Backup, disaster recovery, and compliance retention-period management for sessions and state;
- Credential issuance, rotation, and revocation;
- Audit log collection, storage, and access control;
- Isolation policy and resource quotas for the execution environment.
The following responsibilities do not disappear because of self-hosting:
- Data handling rules for inference requests are still determined by the inference provider and the contract;
- The availability of the inference service remains a dependency, and system operation still relies on external models;
- Safety review of model output still requires the customer to design validation and interception mechanisms.
The scope of shifted responsibility must be documented. Otherwise, the operations team may assume that a responsibility has been covered until an incident reveals the gap.
6. Review Checklist
During review, it is recommended to split retention and outbound transfer into two tables and fill in answers item by item:
[Retention]- Session store location and region:- Deletion owner and trigger conditions:- Retention period in backups and logs:- Credential storage method and rotation interval:[Outbound]- Destination of inference requests:- Fields included in requests (system instructions, history messages, tool inputs, tool results):- Inference provider's retention and training-use terms:- Model and feature scope covered by zero-retention terms:
Only when both tables can be completed can an auditable conclusion be given on whether data leaves the environment.
7. Practical Recommendations
- Split “whether data leaves the environment” into two conclusions, retention and outbound transfer, and record them separately in the review.
- Redact or minimize tool results, and place only the fields needed for inference into the context.
- Keep credentials out of the model context. Have the execution layer inject them on demand when calling tools, with a limited validity period.
- During the pilot phase, record the field list for each inference request to support later audits and troubleshooting.
- At release, document the boundaries: which data is stored in the owned environment and which data is sent to external services with inference requests.
