Hosted vs. Self-Hosted AI Agents: What You Save and What Stays Your Responsibility
This article compares hosted and self-hosted AI agent deployments. It explains which operational work a hosted service can take over, which responsibilities remain with the enterprise, and why self-hosting the agent does not keep data in-house when the model is an external service. It also provides a checklist for verifying a deployment before launch.
1. Clarifying the Concept: The Hosted Unit Is the Agent System, Not Necessarily the Model
When people discuss hosting an agent, the most common misunderstanding is treating the agent service, business data, and model inference as one indivisible unit. In practice, these parts often run in different systems, and different parties may operate them.
An agent that handles real business tasks usually includes the following components:
- Task entry point: Receives user requests and performs identity verification, permission checks, and basic parameter validation.
- Execution and orchestration service: Maintains task state, coordinates model calls, and decides when to run tools, wait for results, or end a task.
- Tool execution environment: Accesses business APIs, queries databases, reads files, or performs constrained operations.
- Credential management component: Stores or references the keys, tokens, and authorization information needed to access business systems.
- State and history storage: Records sessions, task progress, tool results, and necessary audit information.
- Model inference service: Receives the input context and generates answers, structured results, or suggestions for the next tool call.
Therefore, hosting an agent is first a question of operational responsibility: which of these components does the service provider maintain, and which does the enterprise run itself?
Self-hosting an agent does not automatically mean self-hosting the model. An enterprise can deploy the execution service, credentials, and session records in its own environment while still calling an external model service over the network. This architecture takes back some control, but inference requests still leave the enterprise’s environment.
Here, “leaving the boundary” means leaving the network or trust boundary set by the enterprise. It should not be equated with legal cross-border data transfer.
2. What Hosting Removes
The core value of hosting is not running fewer processes. It is reducing the engineering work needed to keep a stateful, tool-calling execution system running.
1. Runtime Environment and Capacity Management
Resource consumption for agent tasks is often uneven. A simple question may involve a single model call, while a complex business process may include several rounds of inference, file reads, and external API calls.
When an enterprise runs this itself, it must account for concurrent tasks, resource quotas, startup speed, dependency isolation, and capacity scaling. For long-running tasks, it also needs to prevent one execution instance from holding resources for an extended period and affecting other tasks.
A hosted solution that covers these capabilities can reduce infrastructure maintenance. However, whether it includes automatic scaling, execution isolation, or resource limits must be verified against the service agreement. The word “hosted” alone does not confirm these features.
2. State Management for Long-Running Tasks
Agent execution often spans multiple steps. When a user closes the page, the task does not necessarily stop. A dropped network connection does not always mean the whole process must start over.
To support reliable execution, the system usually needs to save task state, step results, and any recovery information. For tasks that perform external write operations, it must also handle duplicate execution.
For example, a request to create a business order is sent, but the response is lost due to a network error. The system cannot conclude from the absence of a success response that the operation failed. If it retries directly, it may create a duplicate order. Reliable execution therefore requires more than a retry mechanism. It also needs business idempotency keys, result lookup, or manual verification.
Hosting can ease the infrastructure burden of state persistence and execution recovery, but the enterprise typically still has to define idempotency semantics for its business operations.
3. Credential Lifecycle Management
An agent may need to access several internal systems. Putting all access keys directly in configuration files, or mixing them into the model context, widens the risk of leakage.
Mature credential management includes encrypted storage, access control, rotation, revocation, and usage auditing. Where possible, short-lived authorization should also be used to reduce long-term key exposure.
A hosted service may offer credential storage and injection mechanisms, but the enterprise still decides which resources a credential can access, on whose behalf it acts, and under what conditions it expires. Storing an over-privileged key securely does not remove the risk of unauthorized access.
4. Monitoring, Troubleshooting, and Version Maintenance
Agent failures can originate in several places: a model response that does not meet expectations, a tool call timeout, insufficient permissions, a backlog in the task queue, or an overly long conversation history.
Without a unified task identifier and execution records, developers struggle to determine where a problem occurred. A hosted service may take over some logging, monitoring, and runtime maintenance. The enterprise should still confirm whether it can export execution traces, how long they are retained, and whether it supports the audit queries it needs.
Observability data also creates copies of information. More complete logs do not mean greater safety. Filtering sensitive fields and applying tiered retention policies matter just as much.
3. What Self-Hosting Returns and What It Adds
The main value of self-hosting is that the enterprise can control more directly where the runtime sits, how it connects to the network, what permission policies apply, and how data is stored.
For example, an enterprise can deploy the tool execution service inside its internal network and allow it to reach only designated business APIs. It can also store session history in enterprise-managed storage and set retention periods according to internal policy.
These controls, however, become operational responsibilities:
| Responsibility Area | Key Work After Self-Hosting |
|---|---|
| Service availability | Capacity planning, failure recovery, dependency management |
| Security maintenance | Vulnerability patching, network isolation, access control |
| Data governance | Encryption, backup, deletion, retention management |
| Credential management | Authorization scope, rotation, revocation, access auditing |
| Runtime governance | Concurrency limits, timeouts, retries, task termination |
| Cost governance | Resource utilization, model call volume, control of abnormal consumption |
Therefore, self-hosting is not the same convenience with more control. It trades some operational investment for clearer deployment and governance capabilities. Whether that trade is worthwhile depends on which boundaries the enterprise needs to control and whether it can maintain them.
4. The Key Distinction: Where Data Is Stored Versus Who Receives It During Calls
When evaluating a deployment, answer at least two separate questions:
First, where is the data ultimately stored?
Second, during task execution, which data is sent to which processors?
Keeping session history inside the enterprise shows only that the storage location is under enterprise control. If the system reassembles history, retrieved passages, or tool results into context for each model call, that content may still be sent to an external inference service.
A common data flow can be represented as:
User request → Enterprise-hosted agent service → Context filtering and redaction → External model inference → Enterprise-hosted tool execution → Result filtering → Subsequent model call or final response
This flow includes at least two types of outbound content that need review:
- Initial inference input: The user’s question, system instructions, conversation history, and any materials retrieved to complete the task.
- Content returned after tool execution: Database query results, file excerpts, API responses, and error messages.
The second type is easy to overlook. Even if the first request contains no sensitive information, data that a tool reads later may leave the internal environment in the next inference round.
Teams should also check attachment handling, retrieval indexes, runtime logs, and troubleshooting paths. Whether these create additional copies depends on the specific implementation. The deployment location of the main service alone does not answer that question.
5. Establishing Security Boundaries: Do Not Give the Model Direct Business Permissions
A model can suggest operations, but a business system should not treat model-generated content as trusted authorization.
