AI Agent Hosting Layers: What Self-Hosting Actually Removes
This article explains how managed AI agent products divide responsibilities across the execution, service/control, and model layers, what operational work self-hosting can remove, and what remains when model inference requests still leave your environment. It separates data retention from data transmission and provides a practical review checklist for selecting a hosting model.
Introduction: What disappears after self-hosting, and what does not
When teams build AI agents in-house, they usually start with a demo: a loop of a few dozen lines, hand-built prompts, and two or three tools. Success means it runs once.
But moving to production shifts the questions to:
- Where is conversation history stored?
- What happens when it grows?
- Who has permission to delete it?
- Are tool credentials kept in code or centrally managed?
- Who isolates the code execution sandbox?
- How are timeouts reclaimed?
These issues were either handled by a managed platform or left unmanaged. So bringing the service back into your own environment often seems like the obvious answer.
However, what self-hosting actually means depends on which layer you take over. It may only move the execution environment into your own network, or it may move the entire AI agent service under your ownership. Different scopes remove different operational burdens and leave different compliance boundaries.
There is also a common misconception: storing conversations in your own database does not automatically mean that data will never leave your network.
Each time an AI agent decides “what to do next,” it must send the current context to an inference service. That context often includes business data returned by tools. A more accurate conclusion is:
Self-hosting changes where data is kept, not whether it is sent out.
This article addresses two questions:
- What burdens do managed AI agent products handle for you?
- After self-hosting, what boundaries still need to be verified?
1. Draw the boundary: retention and transmission are different
When evaluating any managed solution, the first step is to split data flows into two categories.
Retention: What data is persistently stored, where it is stored, how long it is kept, and who is responsible for deleting it. In AI agent scenarios, this mainly includes conversation messages, tool call inputs and outputs, and temporary artifacts such as attached files.
Transmission: What content leaves the local environment on each call, where it goes, and which systems it passes through. In AI agent scenarios, this mainly includes model requests sent to an inference service, and may also include calls to auxiliary capabilities such as content moderation, retrieval, or speech transcription.
The checkpoints for these two categories are different:
| Dimension | Core question | Common misunderstanding |
|---|---|---|
| Retention | Who stores it, where it is stored, how long it is kept, and who deletes it | Assuming that storing conversations in your own database means no data is sent externally |
| Transmission | Where requests go, what they carry, who retains them, and whether retention can be disabled | Assuming that signing a zero-data-retention clause automatically satisfies all requests |
| Responsibility | Who deletes data, who issues notifications, and who can audit | Confirming that deletion is possible, but not confirming that deletion is actually complete |
| Ownership | Which tenant owns the data, and what it may be used for | Confirming that data is not used for training, but overlooking human review processes |
If a review form contains only one line such as “Does data leave the environment?”, the team may answer only one dimension and implicitly mark the other as “No.”
A better practice is to treat retention and transmission as two independent review items from the very beginning of a project.
2. Three layers of hosted capabilities
Managed AI agent products usually run in platform-managed sandboxes:
- Each task executes in an isolated environment.
- The agent loops on the service side, calling models and tools.
- Conversation state is centrally stored by the platform.
- Inference is performed by a model provided by the vendor or selected by the customer.
By responsibility, a hosted AI agent product can be divided into three layers:
- Execution layer (sandbox): An isolated runtime environment responsible for executing commands, running code, and reading or writing files. It directly touches task files and data returned by tools.
- Service and control layer: The AI agent runtime loop, tool call orchestration, conversation and state storage, external APIs, and credential management. It is the central hub of agent execution and is usually the main carrier of conversation retention.
- Model layer (inference): The layer that understands context and generates the next action. Every “thought” means that a request leaves the runtime environment and travels to wherever the model is hosted.
Product forms often evolve along this chain:
- First, both the sandbox and services are fully managed by the platform.
- Then, the execution environment is opened up for customers to provide themselves.
- Later, customers may also take over the service and control plane.
Product names often emphasize the layer that the customer takes over, for example “self-hosted sandbox” or “managed AI agent.”
| Form | Execution layer (sandbox) | Service and control layer | Model layer (inference) |
|---|---|---|---|
| Cloud-hosted sandbox (default form) | Vendor | Vendor | Vendor |
| Self-hosted execution layer | Customer | Vendor | Vendor |
| Self-hosted service and control plane | Customer | Customer | Vendor or customer-selected inference provider |
In the first two forms, conversations are stored by the service provider responsible for each form. In the third form, conversation history is stored in the customer’s own database.
In other words, the difference among the three forms is not in the model layer, but in the ownership of execution and services:
- The sandbox determines where task files are processed.
- The service layer determines who keeps conversations and credentials.
3. What managed offerings remove from your workload
Regardless of the form, as long as the service is still managed by the vendor, most of the following work does not need to be handled by your team.
1. The AI agent runtime loop
A tool call is actually a loop:
- The model outputs a tool call intention.
- The platform parses the arguments.
- The tool is executed in the sandbox.
- The result is appended back to the context.
- The model decides the next step.
This looks simple, but production environments require many details to be handled:
- How to trim history when the context exceeds the limit.
- Whether multiple tools can be executed in parallel.
- How to retry or degrade when sandbox execution fails.
- How to finish cleanly when the loop count or total duration reaches its limit.
Writing this loop is not difficult. The difficult part is keeping it stable over time. A managed service hands this scheduling responsibility to the platform, leaving business code to focus only on defining tools and handling business logic.
2. Conversation and state storage
An AI agent’s “memory” is essentially a sequence of messages ordered by time:
- System prompts
- User input
- Model replies
- Tool inputs
- Tool results
This type of data has three characteristics:
- Each item can be large, and storage grows quickly.
- Write operations are frequent.
- Deletion timing requirements are strict.
Self-building this layer means choosing storage, designing tables, handling pagination and queries, controlling cost, and implementing data export and scheduled deletion. A managed version lets you store and retrieve conversations through a predefined API.
3. Credential management
AI agents often need to hold three types of credentials:
- Credentials for calling the model.
- Credentials for accessing external services involved in tool calls.
- Credentials for operating internal business systems.
A managed service usually binds these credentials to sessions within a controlled environment. They do not need to be written into business code, and they do not need to be scattered across each tenant’s configuration.
However, “platform-managed” does not mean “platform never accesses them.” The actual scope and visibility of credentials still need to be confirmed one by one.
4. Sandbox lifecycle
Tools may execute commands, compile code, or process uploaded files in a sandbox. Isolation is essential.
A self-built sandbox needs to handle:
- Creating sandboxes per task and destroying them per session.
- Restricting file system and network access.
- Reclaiming leftover processes.
- Maintaining base images.
In addition, teams need to handle elastic scaling and prevent sandbox escape.
A managed version leaves this work to the platform, removing an entire category of environment operations from the team.
5. Observability, quotas, and version compatibility
In a managed mode, questions such as:
- Where did the task run?
- Which step timed out?
- Which tool failed?
are usually supported by a unified runtime view for troubleshooting. Concurrency and usage quotas, runtime compatibility, and model version compatibility are also mostly maintained by the platform.
What needs attention instead is this: when relying on platform-provided runtime data, logs and monitoring data themselves may also fall within the scope of retention and transmission review.
4. Three things self-hosting does not remove
1. Inference requests still leave the network
After self-hosting, the model layer is usually still hosted by the vendor. Even if the customer selects an inference provider, requests still need to leave the customer’s own environment.
What does one request carry? The following is an illustrative request structure:
{"model": "<selected model identifier>","system": "You are an order support agent that can call the order lookup tool","messages": [{ "role": "user", "content": "Please check the logistics status of order A1024" },{"role": "assistant","tool_calls": [{ "name": "query_order", "arguments": { "order_id": "A1024" } }]},{"role": "tool","content": "{\"status\":\"shipped\",\"receiver\":\"User A\",\"phone\":\"138****0000\"}"}],"tools": [{ "name": "query_order", "description": "Look up logistics status by order ID" }]}
In this example, what leaves the local environment is not only the user’s sentence. It also includes:
- The system prompt.
- Tool definitions.
- Tool-returned business data, such as the recipient and phone number.
Every time the agent executes a round, this context is sent again.
Therefore, evaluating whether the inference path leaves the network requires checking layer by layer:
- Network layer: Which network environment does the request originate from? Does it use the public internet or a dedicated line? Does it pass through proxies, gateways, or log collection systems?
- Payload layer: Besides the conversation content, does the request include user identifiers, tenant identifiers, tool arguments, or tool results?
- Provider layer: Does the inference provider retain requests? For how long? Are they used for model improvement? Is there human review?
2. Zero data retention requires item-by-item verification
Zero data retention, often abbreviated as ZDR, usually refers to an arrangement where the provider does not save request and response content after receiving and returning them, or only retains them for a short period under strictly controlled conditions.
This is a contractual arrangement, not a feature automatically included in a particular hosting form. It usually needs to be signed separately, with clear applicable conditions.
A common industry logic is:
- Conversation storage in a managed service may be included in the scope of a zero-data-retention agreement.
- Customer-managed services and databases are not in that scope. Retention and deletion policies must be defined by the customer.
A more important point is this: self-hosting the service itself does not automatically make all model requests eligible for zero retention.
Teams need to verify:
- Which model is used, and whether it is a version that the provider marks as retaining requests by default.
- Which additional features are enabled, such as web retrieval, content moderation, speech processing, or image processing.
- Which provider processes the request, and what the contract covers.
- Whether the provider’s own logs and troubleshooting mechanisms retain necessary information.
3. Identity, audit, and data lifecycle are your responsibility
After self-hosting, the customer becomes the owner of conversation data.
Questions such as the following are no longer answered by the platform:
- Who has permission to access the data?
- Is access audited?
- After a deletion request, how long does actual removal take?
- Are copies still present in backups?
There is also a point that is easily overlooked when deploying in a private network: self-hosting may actually add outbound network requirements. Teams need to allow network access for model calls and tool calls, and include outbound traffic in monitoring.
5. Review checklist: retention and transmission
| Check item | Retention dimension: conversations, tool results, attachments | Transmission dimension: each model and tool call |
|---|---|---|
| Location | Which cloud and region is the database deployed in? | Which provider and region are requests sent to? |
| Content | Messages, tool inputs and outputs, user identifiers, attachments | Whether the full context or incremental context is sent, and whether tool results are desensitized |
| Retention period | How long data is kept, and when deletion is triggered | How long the provider retains data, and whether it is used for training |
| Permissions | Who can read the data, and whether tenant isolation is enforced | Who signs the contract with the provider, and who is the actual processor |
| Audit | Whether deletion can be verified, and whether backups are covered | Whether the link is encrypted, and whether outbound traffic can be monitored |
| Exceptions | Attached files, temporary directories, exported files | Additional features, human review paths, and other exception paths |
This table can be turned into a pre-deployment self-check script. It cannot replace a contract or legal review, but it can force the team to provide definite answers for each item rather than defaulting to “No”:
# Pre-deployment self-check for hosted mode (illustrative)def check_hosting_boundary(manifest: dict) -> list[str]:"""Return all missing or unconfirmed check items. An empty list means the boundary is confirmed."""dimensions = {"retention": ["storage_location", "retention_period","deletion_owner", "backup_coverage"],"transmission": ["inference_provider", "provider_region","payload_scope", "provider_log_retention"],}unresolved = []for dimension, keys in dimensions.items():for key in keys:# confirmed=True means the item has been confirmed in writing by the project owneritem = manifest.get(dimension, {}).get(key, {})if not item.get("confirmed"):unresolved.append(f"{dimension}.{key}")return unresolvedmanifest = {"retention": {"storage_location": {"value": "self-owned database", "confirmed": True},"retention_period": {"value": "30 days", "confirmed": True},"deletion_owner": {"value": "platform data administrator", "confirmed": True},"backup_coverage": {"value": "pending confirmation", "confirmed": False},},"transmission": {"inference_provider": {"value": "vendor-managed", "confirmed": True},"provider_region": {"value": "pending confirmation", "confirmed": False},"payload_scope": {"value": "includes tool results", "confirmed": True},"provider_log_retention": {"value": "zero-retention clause pending signature", "confirmed": False},},}
6. How to choose: follow constraints, not slogans
| Primary constraint | Recommended form | Reason |
|---|---|---|
| Fast launch, with no hard requirement on retention ownership | Cloud-hosted sandbox | All three layers are platform-managed, resulting in the lowest operational cost |
| Existing container platform or private network, and tasks need to process internal files | Self-hosted execution layer | Task data is processed in the local environment, without rebuilding the runtime loop |
| Conversation retention ownership and credential governance are hard requirements, and you have runtime and storage operations capability | Self-hosted service and control plane | Services and data are self-managed, and the model can be selected as needed |
| “Data must not leave the network” is non-negotiable | Re-evaluate the solution boundary | Inference involves outbound traffic in any form, so alternatives such as local models or desensitization must be considered |
The last row is especially important.
If “data must not leave the network” is a hard red line, then moving services back into your own environment does not automatically satisfy it. At that point, the real discussion should focus on:
- Can models be deployed locally?
- Can sensitive fields be desensitized before invocation?
- Which tasks can be downgraded to rule-based processing?
These approaches each have costs. Local inference requires compute resources, and desensitization may affect answer quality. But they act directly on the transmission layer.
Conclusion
The value of managed AI agent products is not that they keep data from leaving the network. Their value is that they prevent teams from rebuilding AI agent infrastructure from scratch:
- Runtime loops
- Conversation storage
- Credential management
- Sandbox lifecycle
The value of self-hosting is that it brings the most sensitive parts of that infrastructure — conversations, credentials, and execution environments — back under your own control.
But it also comes with equivalent responsibility:
- Retention policies must be defined by you.
- Deletion must be verified by you.
- The inference path must be reviewed by you.
When evaluating a hosting model, remember two separate questions:
- Self-hosting answers: “Where is the data kept?”
- Inference calls answer: “Is the data being sent out?”
Only when both questions have clear answers can the final choice be justified.
