Self-Hosted AI Agents: What You Control and What Still Leaves Your Network
Self-hosting an AI agent gives organizations more control over orchestration, credentials, and conversation history, but it does not necessarily keep model inference inside their network. This article explains the deployment boundary, separates data retention from data transmission, and provides a responsibility matrix, security checklists, and implementation steps for evaluating self-hosted agent architectures.
1. Self-Hosting Does Not Mean Local Model Inference
One of the most common misconceptions about AI agent hosting is that “self-hosted” means all data stays on the internal network and no model requests leave it. The distinction is more precise: managed agent services typically provide orchestration, credential management, and conversation history storage. Self-hosting moves some of those control-plane and data-plane components into an organization-controlled environment, while model inference may still use an external endpoint.
In this article, a self-hosted deployment of an otherwise managed agent architecture means that the organization takes responsibility for agent orchestration, tool-use policies, credential storage, and conversation history. However, each model call may still require the server to send the conversation context available at that point to an inference endpoint. That context can include user messages, tool inputs, tool results, system prompts, and intermediate state.
In other words, the organization regains control over components and data retention, but not necessarily control over the inference path.
This boundary must be explicit. Otherwise, teams may mistake “the database is in our environment” for “data never leaves our network,” or “we hold the keys” for “requests contain no sensitive information.” Those assumptions can leave gaps in compliance reviews and security audits.
2. What Is Being Hosted? Three Components and One Exception
From an engineering perspective, an agent hosting service has three main components:
- Agent service: Task orchestration, state machines, tool-call scheduling, policy enforcement, retries, and timeout handling. In a self-hosted deployment, these run on an organization-controlled container platform or compute environment. The organization becomes responsible for upgrades, capacity, availability, and consistent policy enforcement.
- Credentials: Keys, tokens, and certificates used to access external tools, internal APIs, and data sources. Self-hosting allows credentials to remain in the organization’s own secrets management system, reducing the risks associated with long-term platform-side storage. Runtime injection, least privilege, rotation, and auditing still remain the organization’s responsibility.
- Conversation history: Messages, tool-call records, tool results, intermediate state, and audit events. The organization takes responsibility for storage location, backups, deletion, and access control.
The exception is model inference. Wherever the agent service runs, if the model is not deployed locally, inference requests still need to send context to the inference endpoint.
That transmission is a dynamic data flow, separate from the question of where the database resides. An evaluation must therefore distinguish:
- Retention: Database location, backup copies, log copies, and responsibility for deletion.
- Transmission: Request destinations, network paths, included fields, and whether content can be trimmed or redacted before sending.
3. What Self-Hosting Actually Simplifies
The value of self-hosting is not a guarantee that model calls stay inside the network. It is the ability to bring several persistent operational responsibilities under organizational control.
Clearer Ownership of Conversation Retention
Organizations can decide which database or object store holds conversation history, which region it resides in, how long it is retained, who can access it, and how deletion is audited.
This is a practical benefit for teams that must satisfy internal data classification rules, retention schedules, and deletion-evidence requirements.
More Direct Control over Credentials
Tool credentials do not need to remain in platform-side storage. Organizations can use their own secrets management systems for storage, injection, and rotation.
Just as importantly, they can audit both where credentials are stored and how those credentials are used during execution.
Agent Policies That Fit the Enterprise Network
Tool calls can be restricted to internal networks or controlled egress routes. Policy engines can integrate with existing identity systems, approval workflows, and logging platforms.
For teams that need fine-grained control over tool access, this offers more flexibility than relying solely on platform-side settings.
Enforceable Deletion and Audit Responsibilities
Self-hosting lets organizations define the conversation data lifecycle and implement deletion jobs, backup cleanup, and audit records.
Deletion must extend beyond the primary database. Indexes, caches, logs, backups, and derived copies also need to be accounted for.
4. What Self-Hosting Does Not Eliminate: External Inference Requests
The central limitation is that, when inference remains external, model requests still leave the organization’s network. Those requests may include the conversation so far, tool inputs, and tool results.
An organization can take control of conversation retention and identity management while still relying on an external inference path. This creates three categories of risk:
- Insufficient context minimization: Sending complete tool results, conversation history, and system prompts can expose sensitive fields that are unnecessary for inference.
- Opaque network paths: Teams must identify every proxy, gateway, and logging component along the route, determine whether request bodies are recorded, and check for additional copies.
- Mismatch between contracts and configuration: The inference provider’s data-processing terms, retention policies, and logging configuration must match the actual content being sent. Checking static storage locations alone is not enough.
“Data never leaves the network” should therefore not be the default promise for this architecture. A more accurate statement is:
The agent service, credentials, and conversation history can be self-hosted. Model inference requests still go to the agreed inference endpoint, and the organization should control outbound content through field allowlists, redaction, egress gateways, and auditing.
5. Evaluation Framework: Assess Retention and Transmission Separately
Use a responsibility matrix and separate retention and transmission checklists rather than reducing the assessment to a vague statement about whether data “leaves the boundary.”
| Component | Location after self-hosting | Organizational responsibilities | Remaining checks |
|---|---|---|---|
| Agent orchestration service | Organization-controlled compute environment | Operations, upgrades, policies, capacity | Request egress and logging |
| Credentials | Organizational secrets management or controlled storage | Storage, injection, rotation, least privilege | Runtime leakage into logs |
| Conversation history | Organizational database or object storage | Retention, deletion, backups, access control | Backup, index, and cache copies |
| Model inference | External inference endpoint | Provider selection and contractual terms | Request fields, network paths, retention policies |
Retention Checklist
- Where is the database located?
- Where are backups stored?
- Do logging and tracing systems record conversation content?
- Who has permission to delete data?
- Do deletion procedures cover backups and derived copies?
- Is there auditable evidence of deletion?
- Are cross-region copies controlled?
Transmission Checklist
- Where are requests sent?
- Which gateways and proxies do they pass through?
- Is transport encryption enabled?
- Which fields are included in request bodies?
- Are complete tool results sent back to the model?
- Can content be trimmed using field allowlists?
- Is sensitive content redacted before transmission?
- Do egress logs record plaintext content?
- Do retries resend outbound data?
Credential Checklist
- Where are keys stored?
- How are they injected at runtime?
- Are permissions limited to the minimum necessary?
- What are the rotation schedule and invalidation mechanisms?
- Are credential-backed calls auditable?
- Can failed tool calls write credentials or sensitive responses into logs?
6. Reference Architecture and Pseudocode
A practical reference architecture places agent orchestration, the policy engine, the conversation database, secrets management, and audit logging in an organization-controlled environment.
All model requests pass through a centralized egress gateway that applies field allowlists, redaction, rate limits, and auditing. Tool execution stays on the internal network wherever possible. High-risk tool results are summarized or filtered before entering the model context.
General cloud service categories—such as container platforms, object storage, secrets management, and logging services, including those offered by Baidu AI Cloud—can host self-managed components. Specific service selection should follow the organization’s security baseline. A cloud product category is not, by itself, a compliance guarantee.
The following pseudocode illustrates the intended controls:
def assemble_context(session, tool_result, policy):ctx = session.window(policy.max_turns)ctx = redact(ctx, policy.sensitive_fields)ctx = allowlist_tool_result(tool_result, policy.tool_fields)audit.record(event="model_call",context_fields=ctx.keys(),egress=policy.egress_target,redaction=policy.redaction_version)return ctx
The focus is not a particular API, but three principles: trim before sending, redact before sending, and audit outbound calls.
Audit logs must also be sanitized. Recording plaintext context “for auditing” simply creates another sensitive data store.
7. Common Mistakes and Implementation Steps
Common mistakes include:
- Treating self-hosting as a guarantee that data never leaves the network.
- Checking only the primary database while overlooking backups, indexes, caches, and logs.
- Managing credential storage without managing injection, rotation, and runtime leakage.
- Sending complete tool results to the model.
- Recording plaintext context in audit logs.
- Deleting primary records without addressing derived copies.
Each mistake can turn greater control into a benefit that exists only on paper.
A rollout can proceed in six steps:
- Map the data flows. Identify the agent service, credentials, conversation database, tool execution layer, and inference egress.
- Classify the data. Define which fields must remain local, which may be sent externally, and which require redaction.
- Define a retention matrix. Cover primary databases, backups, logs, indexes, and caches.
- Centralize model-call egress. Enforce field allowlists and auditing at the outbound boundary.
- Apply least privilege and test credential rotation. Verify both access restrictions and rotation procedures.
- Run regular deletion exercises and outbound-content checks. Confirm that deletion works across copies and that requests contain only permitted content.
8. Conclusion
Self-hosted agent architectures are worth considering, particularly for teams struggling with conversation retention ownership, credential management, and audit responsibilities.
What they bring under organizational control is the hosting of agent services, credentials, and conversation history—not necessarily the external path used for model inference.
Evaluate retention and transmission separately. For retention, examine databases, backups, and deletion responsibilities. For transmission, examine request destinations, included fields, and network paths. Making both sides explicit allows organizations to regain control without mistaking self-hosting for a promise that data never leaves the network.
