What Managed AI Agents Actually Offload: A Layer-by-Layer Analysis

    This article breaks down AI agent managed hosting by separating the system into three independently replaceable layers—sandbox, service and control plane, and model—and comparing how responsibility shifts across three deployment forms. It explains what self-hosting agents really removes, such as credential exposure and session data residency concerns, and what it does not, notably the data still sent to inference providers on every model call. It also offers a practical evaluation framework that splits "does data leave our environment?" into two distinct questions—where data is stored and what is transmitted during inference—alongside key technical considerations for teams adopting self-hosted agents.

    Introduction: Why “Managed” Needs to Be Defined Precisely

    In enterprise AI agent deployments, “managed” is a high-frequency but loosely defined term. Different teams interpret it very differently: some assume managed means handing all data to a vendor, while others think it only means letting a vendor run a bit of scheduling logic. This ambiguity directly affects architecture choices, cost budgets, and compliance reviews.

    The first step to clearing this up is to break the agent’s runtime chain into several independently replaceable “layers,” then examine who provides each layer, where data flows, and where credentials are stored. Using common industry AI agent managed hosting options as a backdrop, this article analyzes the core question of “what trouble does managed hosting actually save you from” and provides a practical evaluation framework.


    Part 1: The Three-Layer Structure of an Agent System: Sandbox, Service, Model

    A typical AI agent runtime chain can be abstracted into the following three layers:

    1. Sandbox Layer — an isolated execution environment for code and tools

    Agents need to call external tools to complete complex tasks, such as running scripts, reading and writing files, accessing databases, and making network requests. These operations have side effects; once maliciously induced or subject to logic errors, they may affect the host system. The sandbox provides an isolated execution environment, typically including:

    • An independent file system view (to prevent unauthorized reads and writes)
    • Restricted process and network permissions
    • Resource quota limits (CPU, memory, execution time)
    • Lifecycle management (creation, reuse, destruction)

    2. Service and Control Plane — APIs, the agent run loop, and state storage

    This layer is the agent’s “scheduling brain,” responsible for:

    • Exposing API interfaces to receive task requests from users or upstream systems
    • Driving the agent run loop (Agent Loop), the iterative process of “receive input → call model → parse output → execute tool → call model again”
    • Managing sessions and context state
    • Persisting session history, intermediate artifacts, and audit logs
    • Managing credentials and permissions required for model calls

    3. Model Layer — inference and generation

    Each agent “thought” ultimately lands on one or more model inference requests. The model is responsible for understanding instructions, generating decisions, and outputting structured or natural-language results. This layer is usually provided by dedicated inference infrastructure, which can be a cloud vendor’s managed model service or a customer’s self-built inference cluster.

    A common misconception is equating “agent hosting” with “model hosting.” In reality, the three layers can be deployed and replaced independently—this is the key to understanding the value of managed hosting options.


    Part 2: Comparing Hosting Boundaries Across Three Deployment Forms

    The industry divides agent managed hosting options by “which layer the customer takes over” into several forms, which can be compared intuitively in the table below:

    Deployment Form Sandbox Service & Control Plane Model
    Cloud sandbox (default form) Vendor-managed Vendor-managed Vendor-managed
    Self-hosted sandbox Customer-managed Vendor-managed Vendor-managed
    Self-hosted agent service Customer-managed Customer-managed Vendor- or customer-selected

    Form 1: Cloud sandbox (default form)

    The customer barely needs to worry about infrastructure. Sandbox, service control plane, and model inference are all handled by the vendor. This suits rapid validation, prototype development, and lightweight applications involving non-sensitive data. The trade-off is the weakest control over data retention location, credential management, and session ownership.

    Form 2: Self-hosted sandbox

    The vendor hands the execution layer to the customer. The isolated environment for tool calls runs on the customer’s own infrastructure, with the file system, network boundaries, and execution logs all residing on the customer’s side. But the agent’s API, run loop, and session storage remain managed by the vendor.

    This form suits teams with strong compliance requirements around “tool execution security” but that want to reduce the operational burden of the service layer. Typical scenarios include financial risk-control agents (where tools interact with core transaction interfaces) and medical information processing agents (where tools handle data containing personal health information).

    Form 3: Self-hosted agent service

    The customer takes over the sandbox and the service control plane, maintaining the API gateway, agent run loop, session database, and credential storage themselves. Model inference can continue using the vendor’s inference service, or be switched to a customer-selected or self-built inference provider.

    This is currently the option with the strongest “data sovereignty” demands, and it is the primary focus of this article.


    Part 3: What Trouble Does Self-Hosting Actually Save You From? And What New Trouble Does It Bring?

    3.1 Trouble Removed

    Credentials no longer pass through the vendor’s control plane

    In managed hosting, credentials required for the agent to call tools—API keys, database passwords, OAuth tokens, and so on—must be submitted to the vendor’s service layer for centralized management. With self-hosting, credentials can be stored in the customer’s own key management system (KMS), with access controlled by the customer’s own identity and permission system.

    This means:

    • The blast radius of credential leaks shrinks; the vendor side no longer holds access rights to the customer’s business systems
    • Credential rotation, revocation, and auditing are completed entirely under the customer’s control
    • It satisfies compliance requirements such as “keys must not leave the enterprise security boundary”

    Session history ownership becomes clear

    Session history contains user inputs, agent outputs, and tool call parameters and results. In many industries (finance, healthcare, legal), this data constitutes business records that require long-term retention and are subject to regulation. With self-hosting, session history is stored in the customer’s own database, allowing the customer to:

    • Set retention periods and deletion policies independently
    • Integrate agent sessions with existing business audit chains
    • Avoid the risk of migrating historical data due to vendor service shutdown or contract changes

    Improved controllability of agent runtime logic

    Controlling the service control plane yourself means you can deeply customize the behavior of the Agent Loop: inserting custom approval nodes, adding business rule validation, applying data masking logic before and after model calls, and replacing or running multiple model providers in parallel.

    3.2 New Trouble Introduced

    Model calls still send data outward

    This is the most easily overlooked—and most critical—point. After self-hosting the agent service, each model inference request still sends the complete conversation context up to that point to the inference provider. This includes:

    • The user’s original input
    • All previous rounds of agent outputs
    • Tool input parameters (which may contain database query statements and file contents)
    • Tool return results (which may contain business data and PII)

    In other words, self-hosting recovers “where data is retained” and “identity management rights,” not “whether data passes through an external network link.”

    Session storage compliance exclusion clauses may become void

    In fully vendor-managed solutions, some vendors offer a Zero Data Retention (ZDR) mechanism, promising not to store request data after responding. But ZDR typically targets the vendor-side session storage behavior. When the customer self-hosts session storage, exclusion clauses targeting “vendor-side session storage” naturally no longer apply—because retention happens on the customer’s side, not the vendor’s.

    At the same time, note carefully: self-hosting does not automatically grant all model requests zero-retention eligibility. The models used, functional modules, inference providers, and contract terms all need to be verified separately. Different inference providers may have different data retention policies; some may temporarily cache request data during load balancing, monitoring, troubleshooting, and other processes.


    Part 4: Evaluation Framework: Splitting “Does Data Leave Our Environment” into Two Independent Questions

    When evaluating managed hosting options, many teams habitually summarize all security concerns with the single phrase “does data leave our environment.” The danger of this approach is that it conflates two fundamentally different questions:

    Question A: Where is data stored? Who is responsible for deletion?

    This concerns data retention ownership. You need to verify:

    • Is the database for session history the vendor’s or your own?
    • Whose key management system stores the credentials?
    • What is the retention period? Who executes deletion after expiration? Is deletion verifiable?
    • Are there backups, snapshots, logs, and other copies that also need to be included in retention management?

    Question B: Where is data sent during calls? What content does it carry?

    This concerns the data transmission path. You need to verify:

    • Where does each model call send requests to—which inference endpoint?
    • Which fields are included in the request body? Are tool results included?
    • Does the inference provider have data retention policies? Are there regional restrictions?
    • Is the transmission link encrypted? Are there intermediate proxies or gateways?

    Breaking these two questions apart and answering each explicitly is a basic requirement for project review. Merging them into the single phrase “does data leave our environment” easily causes one column to be missed—especially the “retention ownership” column, because it is often masked by the fact “we used self-hosting.”


    Part 5: Key Technical Considerations for Self-Hosted Solutions

    For teams that decide to adopt self-hosted agent services, the following technical details need to be considered at the design stage:

    1. State management of the agent run loop

    With self-hosting, every state in the Agent Loop must be managed by yourself. This includes: which iteration round you are currently in, which tools have been called, how model-returned Function Calls are parsed and routed, error retry strategies, and timeout and interruption handling. It is recommended to use a state machine pattern or an explicit DAG (directed acyclic graph) to manage the runtime logic of complex agents, avoiding the debugging difficulties caused by implicit state.

    2. Session database selection and isolation

    Session data typically has high write frequency, medium read frequency, and strong consistency requirements. Both relational databases and document databases can handle this; the key is to ensure multi-tenant isolation, encrypted storage (encryption at rest), and access auditing. If sessions may contain sensitive information, you also need to perform masking before writing, or use field-level encryption.

    3. Credential management and least privilege

    With self-hosting, credential management is an independent engineering problem. It is recommended:

    1. Credential storage: Use a dedicated key management service (KMS), not mixed with business databases
    2. Credential distribution: Inject credentials via short-lived tokens or dynamic credentials, avoiding long-lived keys on disk
    3. Credential auditing: Record the time, source IP, and caller identity of every credential use
    4. Credential rotation: Set automatic rotation cycles and support emergency revocation

    4. Data minimization for model calls

    Even with self-hosting, model calls still send context outward. The following strategies can be considered to reduce transmitted data volume:

    • Perform context trimming before sending, keeping only the conversation fragments truly needed for the current inference round
    • Summarize or filter tool return results, avoiding stuffing large chunks of raw data into the context
    • Perform tokenization or placeholder replacement for fields containing PII, then restore after inference completes
    • Evaluate whether local inference or privately deployed models can replace external inference services

    5. Observability and auditing

    Self-hosting means vendor-side logs are no longer visible, so you need to build a complete observability system yourself:

    • Input and output logs for every step of the Agent Loop
    • Request body summaries and response latency for model calls
    • Tool execution parameters (after masking), results, and status
    • Credential access audit logs
    • Context snapshots of exceptions and errors

    Part 6: Suitable Scenarios and Selection Recommendations

    Scenarios recommended for self-hosting:

    • Industry regulations require session data to be stored domestically or in a specific region
    • Credential management has strict compliance requirements (such as not being handed to a third party)
    • You need to deeply customize agent behavior, inserting custom logic like business approvals or risk-control checks
    • Multi-model provider strategy: you need to flexibly switch inference backends to avoid vendor lock-in
    • Agent session data needs deep integration with existing business systems (CRM, ticketing, risk control)

    Scenarios where cloud hosting or self-hosted sandbox can be considered first:

    • Rapidly validating agent feasibility, with the long-term architecture not yet determined
    • Data sensitivity is relatively low and compliance pressure is small
    • Limited team operations capacity; you want to reduce infrastructure burden
    • The main pain point is tool execution security, not session data ownership

    Part 7: Summary

    “Managed” is not an on/off switch but a layered continuum. The key to understanding agent hosting is seeing three things clearly:

    1. The sandbox, service, and model layers can be hosted independently, and different forms correspond to different levels of control and operational burden.
    2. Self-hosting recovers data retention and credential management, not the data transmission of model calls. When evaluating, you must answer “where data is stored” and “where it is sent during calls” separately.
    3. Zero data retention has prerequisites; self-hosting does not automatically grant all model requests zero-retention eligibility and requires verification model by model, provider by provider, and contract term by contract term.

    For enterprise teams stuck on retention ownership and credential management, self-hosted agent services are a path worth seriously evaluating. But the starting point of evaluation is not “whether to self-host” but “where each layer of data flows to, where it is stored, and who is responsible for deleting it”—answer this question clearly, and the selection basis naturally follows.