# kagent, acp, agent substrate and other concepts

> This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to [original Chinese version](<https://blog.wendain.ing/posts/kagent-acp-and-other-concepts/>). I am continuously working to improve the translation.

## About kagent

Upstream: https://github.com/kagent-dev/kagent

Let me write a tldr of the core elements:

- One agent runtime runs inside a pod
- k8s is responsible for managing the agents' execution
- Rather than being a coding agent, it's more like consolidating the previous dashboard-like functionality onto a single platform by exposing interfaces to the agent, because the platform can **share** agents

The upstream is more like a distributed system (referring to kagent as a whole), while the secondary development part is deployed in a centralized manner.

The Agent's Runtime and the Agent's definition are decoupled; an Agent is defined in a declarative-like way (model, system prompt, mcp, tool lists, etc.).

> [!note]
>
> I feel that kagent, rather than being the coding agent everyone understands it to be, is more like — or at least what I currently believe — its ultimate form is something like ChatGPT Web
>
> Because right now it already feels more like consolidating the previous dashboard-like functionality onto a single platform by exposing interfaces to the agent, since the platform can **share** agents
>
> ChatGPT Web also has a virtual machine for each session where things can run, and it can be resumed and continued at any time — behind the scenes it must be a similar approach

## ACP

(For now) the secondary development part uses Agent Runtimes built with Google ADK

> [!note]
>
> It's an Agent development framework fairly similar to Langchain, providing interfaces such as Agent definitions, Tool Schemas, and so on.

But the upstream has implemented the so-called "**decoupling of Harness and Agent Runtime**" — in short, you can use things like Codex, Pi, etc. as the Harness, without having to build it with Google ADK.

When thinking about this requirement, the first thing that came to my mind was **ACP**, i.e. the **Agent-Client Protocol**. This protocol is mainly used in the **Zed** editor. Without going into technical details, purely in terms of UX: the editor provides an agent panel, and this panel can invoke a local agent and use it directly and normally. Behind the scenes, simply put, it's a unified protocol — once an Agent implements the ACP Client, the client can use any Agent Runtime under a single Interface.

> Suppose Zed wants to support Claude Code. Zed needs to do the following:
>
> 1. Launch the Claude Code process.
> 2. Create an Agent Session.
> 3. Send user input to the Agent.
> 4. Receive the Agent's streaming output.
> 5. Display which tools the Agent is calling.
> 6. Handle the Agent's permission requests.
> 7. Notify the Agent when the user cancels a task.
>
> By implementing the ACP Client once, Zed can integrate with all ACP-compatible Agents.

Specifically, ACP specifies the following:

1. `initialize`, the "**handshake**" step for establishing a connection;
2. Management of the session lifecycle: creation, loading, resuming, closing;
3. Session interaction: prompt, cancel, update;
4. Bidirectional interaction, e.g. agent request persmission from user

But clearly this set of things seems a bit lacking... The various agents on the market have far too many proprietary features, so the upstream first introduced ACP, then later removed it and switched to writing their own Runtime interface.

> [!note]
>
> ACP can't be that bad, right? Otherwise why would Zed still be using it? Besides, I think once the core functionality is supported, the rest can just be a panel in the dialog box that simply implements slash commands — I can't think of any feature that couldn't be supported that way. It's like the QQ Bot interface: through Slash Commands you can do a lot of things, yet the user is just interacting with it in a simple chat box.

## Agent Substrate

A feature integrated into kagent upstream, developed by Google. It works like this:

- Previously, spinning up an agent meant one pod
- With the traditional Kubernetes Deployment approach, each Agent is assigned a Pod, so even if the Agent is idle 99% of the time, the corresponding Pod resources are still continuously occupied.

For Agent Substrate:

- There is a Worker Pool
  - A Worker is **one** pre-started **Pod** that hosts Actors
- One Worker can host **multiple** isolated Actors
  - An Actor is an independent Agent running instance, with its own process, memory, filesystem, and running state
- One Agent Session corresponds to **one** Actor
  - When a session is created, the actor is in a suspended state, and is only resumed when a message is sent
- When an Actor is idle, its state snapshot is saved to OSS and compute resources are released
- On resume, the snapshot is restored

From this mechanism, it's easy to think of Cloudflare's [Durable Objects](https://developers.cloudflare.com/durable-objects/concepts/what-are-durable-objects/) and [Containers](https://developers.cloudflare.com/agents/harnesses/container/) — the only difference is that the Container here runs an Agent.

Regarding Snapshots: you need to consider whether it's **simply restoring persisted data** or **restoring the entire runtime state**:

- For the former, consider creating subvolumes based on the BTRFS filesystem — snapshots are very convenient with this
- The latter is a bit more troublesome, but honestly I don't think it matters much — after all, in everyday computer use, shutting things down and letting the Agent continue later isn't really a big hassle
  - That said, there are two implementation technologies for a full process Sandbox: gVisor and microVM, which I won't go into here for now.

## Benchmarking Against ChatGPT Chat (Web)

kagent's ultimate goal is certainly not client-distribution level, but rather a centrally deployed, service-providing SaaS-like product, with the following characteristics:

- Generally, it **cannot read** the user's local environment, and the user **cannot freely operate** the environment the agent belongs to
  - The former distinguishes it from ordinary Coding Agents; the latter distinguishes it from the likes of Dot or Grok Bot
- The tools available to the agent are restricted, or rather, there is fairly heavy permission management
- From a UX perspective, it mainly provides interfaces to intranet services for a general-purpose LLM, so users can conveniently have the Agent use these services

So no matter how you look at it, it's very similar to ChatGPT Web:

- Each ChatGPT Web Session has an Agent, and the Agent Runtime necessarily depends on a virtual machine
- It's impossible for the VM behind every Session to exist all the time — it must be dynamically released according to compute resource allocation
  - Isn't this exactly Agent Substrate?
- Sessions need to be resumed, and the degree of restoration upon resume is limited
  - For OpenAI, there's also the question of the model's own KV Cache (perhaps), but we don't need to worry about that here

But honestly, having said all this, it's basically just reinventing the wheel — just with some specialization, such as exposing permissions for different Agents based on the user or the organization the user belongs to. But these are higher-level concerns that can be layered on later; there doesn't seem to be anything particularly novel about it.

> [!note]
>
> In fact, the wheel doesn't even need to be reinvented... it feels like there are plenty of truly open-source options out there. I previously saw that Tencent, Alibaba, and others have open-sourced their own Agent sandboxes, but I haven't seen their orchestration strategies — worth investigating later.

Once the lowest-level functionality is all built, what remains here is simply integrating various internal tools — this has little to do with kagent itself, and is instead a matter of each responsible department developing the corresponding CLI Tool / Skill / MCP etc.
