You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5f9a6cf
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs-site/content/kagent/concepts/agent-substrate.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ weight: 5
5
5
author: kagent.dev
6
6
---
7
7
8
-
Agent Substrate is a Kubernetes-native runtime for running AI agents and other stateful workloads efficiently. Instead of dedicating one pod per agent — which wastes capacity while agents sit idle — Substrate decouples an agent's lifecycle from pod infrastructure. Idle agents are snapshotted to object storage and rehydrated on demand, so a small pool of pre-warmed workers can host far more agents than there are pods.
8
+
Agent Substrate is a Kubernetes-native runtime for running AI agents and other stateful workloads efficiently. Instead of dedicating one pod per agent, which wastes capacity while agents sit idle, Substrate decouples an agent's lifecycle from pod infrastructure. Idle agents are snapshotted to object storage and rehydrated on demand, so a small pool of pre-warmed workers can host far more agents than there are pods.
9
9
10
10
kagent can run workloads on Agent Substrate in two ways:
11
11
@@ -14,10 +14,10 @@ kagent can run workloads on Agent Substrate in two ways:
14
14
15
15
## Why Agent Substrate
16
16
17
-
-**Fast startup** — Agents cold-start by restoring a compressed snapshot rather than booting a fresh pod, so they resume in a fraction of the time.
18
-
-**Efficient resource usage** — A pool of pre-warmed workers multiplexes many actors across far fewer pods, persisting idle actors to object storage instead of holding a pod each.
19
-
-**Secure execution** — Each workload runs inside a gVisor sandbox, isolating untrusted agent code from the host and from other actors.
20
-
-**Declarative management** — WorkerPools and ActorTemplates are Kubernetes CRDs, so the runtime is configured and versioned with the same GitOps workflow as the rest of your platform.
17
+
-**Fast startup**: Agents cold-start by restoring a compressed snapshot rather than booting a fresh pod, so they resume in a fraction of the time.
18
+
-**Efficient resource usage**: A pool of pre-warmed workers multiplexes many actors across far fewer pods, persisting idle actors to object storage instead of holding a pod each.
19
+
-**Secure execution**: Each workload runs inside a gVisor sandbox, isolating untrusted agent code from the host and from other actors.
20
+
-**Declarative management**: WorkerPools and ActorTemplates are Kubernetes CRDs, so the runtime is configured and versioned with the same GitOps workflow as the rest of your platform.
21
21
22
22
## Core concepts
23
23
@@ -31,7 +31,7 @@ kagent can run workloads on Agent Substrate in two ways:
31
31
32
32
## How it works
33
33
34
-
When an agent is invoked, Substrate restores its actor onto an available worker from the WorkerPool — rehydrating from a snapshot if the actor was idle. The agent runs inside a gVisor sandbox for the duration of the session. When the actor goes idle, its state is checkpointed back to object storage and the worker is freed to host another actor. This snapshot-and-restore cycle is what lets a single worker pool serve many more agents than a pod-per-agent model.
34
+
When an agent is invoked, Substrate restores its actor onto an available worker from the WorkerPool, rehydrating from a snapshot if the actor was idle. The agent runs inside a gVisor sandbox for the duration of the session. When the actor goes idle, its state is checkpointed back to object storage and the worker is freed to host another actor. This snapshot-and-restore cycle is what lets a single worker pool serve many more agents than a pod-per-agent model.
35
35
36
36
## Architecture
37
37
@@ -56,7 +56,9 @@ Agent Substrate is composed of a control plane, a data plane, and snapshot stora
56
56
57
57
### Declarative agents
58
58
59
-
Run a (Go) declarative agent on Agent Substrate by creating a `SandboxAgent` resource. It carries the same spec as a regular `Agent`, but the kagent controller runs it as a sandboxed workload on the runtime instead of a plain Deployment.
59
+
Run a declarative agent on Agent Substrate by creating a `SandboxAgent` resource. It carries the same spec as a regular `Agent`, but the kagent controller runs it as a sandboxed workload on the runtime instead of a plain Deployment. All three declarative runtimes are supported: **Go** (default), **Python**, and **BYO**.
60
+
61
+
Session history for Go and Python declarative sandbox agents is persisted to a local SQLite database backed by the agent's `durableDir` volume, so conversation state survives pod restarts and Deployment rollouts. Session metadata is mirrored to PostgreSQL to support session-listing APIs. BYO agents do not get local session storage automatically; set the `kagent.dev/local-session-storage` annotation on the `SandboxAgent` if your BYO agent implements its own local store.
@@ -15,7 +15,7 @@ Each agent consists of the following components:
15
15
16
16
## Agent Instructions
17
17
18
-
Agent instructions tell the agent what its role is, how to interact with the user, what actions it can take, how to behave and respond to user queries, and how to interact with other agents. Here's an example of simple agent instructions:
18
+
Agent instructions tell the agent what its role is, how to interact with the user, what actions it can take, how to behave and respond to user queries, and how to interact with other agents. The following example shows simple agent instructions:
19
19
20
20
```yaml
21
21
You're a Kubernetes agent that can help users manage their Kubernetes resources.
@@ -24,7 +24,7 @@ Your responses should be clear and concise; you should provide helpful informati
24
24
25
25
Instructions are an important part of the agent's behavior. They define the agent's role and capabilities and help the agent understand its environment and the tasks it can perform.
26
26
27
-
Writing good instructions is an art and a science. It requires a good understanding of the task at hand, the tools available, and the user's needs. In order to make it easier to write good instructions, we've created a [system prompt tutorial](/docs/kagent/getting-started/system-prompts) that can help you get started.
27
+
Writing good instructions is an art and a science. It requires a good understanding of the task at hand, the tools available, and the user's needs. To help you write good instructions, see the [system prompt tutorial](/docs/kagent/getting-started/system-prompts).
28
28
29
29
### Prompt templates
30
30
@@ -86,13 +86,13 @@ Tools are functions that the agent can use to interact with its environment. For
86
86
87
87
Tools definitions and their descriptions are made available to the agent and are sent to the LLMs together with the instructions. Based on the user query, the agent can use the tools to interact with the environment and generate responses.
88
88
89
-
For example, we could add the **list_resources** tool to agent that would allow it to list resources in the Kubernetes cluster. The agent will determine based on the user input if it makes sense to invoke any of the available tools.
89
+
For example, add the **list_resources** tool to your agent to allow it to list resources in the Kubernetes cluster. The agent determines, based on user input, whether to invoke any available tools.
90
90
91
-
If the user asks "List all pods in the cluster", the agent can use the **list_resources** tool to list all pods in the cluster. Note that depending on how the instructions/tools are written and configure, the agent might list all the namespaces first then list all the pods in each namespace. Alternatively, if the **list_resources** tool allows listing resources across namespaces, the agent will pick that option.
91
+
If the user asks "List all pods in the cluster", the agent can use the **list_resources** tool to list all pods in the cluster. Depending on how the instructions and tools are configured, the agent might list all namespaces first, then list all pods in each namespace. Alternatively, if the **list_resources** tool allows listing resources across namespaces, the agent picks that option.
92
92
93
-
Some tools support additional configuration that can be set in when adding the tool to the agent. For example, any Grafana or Prometheus tools will require an API endpoint URL to be set.
93
+
Some tools support additional configuration that you set when adding the tool to the agent. For example, any Grafana or Prometheus tools will require an API endpoint URL to be set.
94
94
95
-
kagent comes with a set of built-in tools that you can use to interact with your environment. kagent also supports the [MCP (Model Configuration Protocol)](https://modelcontextprotocol.io/introduction) tools. Using MCP, you can bring any external tool into kagent and make it available for your agents to run.
95
+
kagent comes with a set of built-in tools that you can use to interact with your environment. kagent also supports [MCP (Model Context Protocol)](https://modelcontextprotocol.io/introduction) tools. Using MCP, you can bring any external tool into kagent and make it available for your agents to run.
96
96
97
97
## Human-in-the-Loop
98
98
@@ -149,7 +149,7 @@ Skills can refer to two broad types:
149
149
150
150
### A2A skills metadata
151
151
152
-
Actions-to-actions (A2A) skills are metadata—structured descriptions of capabilities, not executable code. Think of A2A skills as a machine-readable catalog entry about what a tool can do.
152
+
Actions-to-actions (A2A) skills are metadata: structured descriptions of capabilities, not executable code. Think of A2A skills as a machine-readable catalog entry about what a tool can do.
153
153
154
154
A2A skills metadata describes:
155
155
@@ -214,6 +214,35 @@ skills:
214
214
215
215
A single `gitAuthSecretRef` applies to all Git repositories in the agent. You can combine Git and OCI skills in the same agent by specifying both `refs` and `gitRefs`.
216
216
217
+
### S3-based skills
218
+
219
+
You can load skills directly from S3 — either a folder prefix (a path ending with `/` that contains a `SKILL.md` and sibling files) or a single `.zip` archive. Credentials use the AWS SDK default credential chain, which you supply as environment variables on the skills init container.
- uri: s3://kagent-skills-bucket/bundles/ops.zip # zip archive
227
+
region: us-east-1
228
+
initContainer:
229
+
env:
230
+
- name: AWS_ACCESS_KEY_ID
231
+
valueFrom:
232
+
secretKeyRef:
233
+
name: aws-creds
234
+
key: AWS_ACCESS_KEY_ID
235
+
- name: AWS_SECRET_ACCESS_KEY
236
+
valueFrom:
237
+
secretKeyRef:
238
+
name: aws-creds
239
+
key: AWS_SECRET_ACCESS_KEY
240
+
- name: AWS_REGION
241
+
value: us-west-2
242
+
```
243
+
244
+
You can combine S3 skills with OCI and Git skills in the same agent by specifying `refs`, `gitRefs`, and `s3Refs` together. For the full field reference, see [S3SkillRef](/docs/kagent/resources/api-ref/#s3skillref).
245
+
217
246
### Best practices for skills
218
247
219
248
Containerize and store your skills in a specialized registry so that you can reuse them across agents. You can use the [agentregistry project](https://github.com/agentregistry-dev/agentregistry) to build and push skills to a registry.
@@ -230,35 +259,75 @@ To learn more about using skills in your agents, see the [Skills example guide](
230
259
231
260
## Runtime
232
261
233
-
You can choose between two Agent Development Kit (ADK) runtimes for declarative agents: **Python** (default) and **Go**.
262
+
You can choose between two Agent Development Kit (ADK) runtimes for declarative agents: **Go** (default) and **Python**.
234
263
235
-
| Feature | Python ADK | Go ADK |
236
-
|---------|-----------|--------|
237
-
| Startup time | ~15 seconds | ~2 seconds |
238
-
| Ecosystem | Google ADK, LangGraph, CrewAI integrations | Native Go implementation |
Select the runtime via the `runtime` field in the declarative agent spec.
246
276
247
277
```yaml
248
278
spec:
249
279
type: Declarative
250
280
declarative:
251
-
runtime: go # or "python" (default)
281
+
runtime: go # or "python"
252
282
modelConfig: default-model-config
253
283
systemMessage: "You are a helpful agent."
254
284
```
255
285
256
-
**Choose Go when** fast startup matters (autoscaling, cold starts), lower resource consumption is important, or you don't need Python-specific framework integrations.
286
+
**Choose Go when** fast startup matters (autoscaling, cold starts), lower resource consumption is important, or you do not need Python-specific framework integrations.
257
287
258
288
**Choose Python when** you need Google ADK-native features, CrewAI/LangGraph/OpenAI framework integrations, or Python-based custom tools.
259
289
260
290
For more benchmarks and details, see the [Go vs Python runtime blog post](https://kagent.dev/blog/go-vs-python-runtime).
261
291
292
+
## Deployment configuration
293
+
294
+
Control how the agent's Kubernetes Deployment is configured in the `spec.declarative.deployment` stanza.
295
+
296
+
### Environment variables
297
+
298
+
Use `env` to set individual environment variables, or `envFrom` to bulk-inject all keys from a ConfigMap or Secret.
299
+
300
+
```yaml
301
+
spec:
302
+
declarative:
303
+
deployment:
304
+
env:
305
+
- name: LOG_LEVEL
306
+
value: debug
307
+
envFrom:
308
+
- configMapRef:
309
+
name: my-agent-config
310
+
- secretRef:
311
+
name: my-agent-secrets
312
+
```
313
+
314
+
### Deployment annotations
315
+
316
+
Use `deploymentAnnotations` to add annotations to the Deployment object itself. This field is distinct from the `annotations` field, which targets pod template metadata only.
`deploymentAnnotations`is useful for GitOps tooling such as Argo CD sync waves and Flux annotations, which key off Deployment-level metadata rather than pod metadata.
330
+
262
331
## Memory
263
332
264
333
Your agents can save and retrieve relevant context across conversations using vector similarity search. When you enable memory on an agent, it receives three additional tools (`save_memory`, `load_memory`, `prefetch_memory`) and automatically extracts key information every 5th user message.
@@ -292,15 +361,37 @@ Compaction removes older conversation events to free up space in the context win
292
361
293
362
## Sandboxed Agents
294
363
295
-
You can run a declarative agent in an isolated sandbox by creating a `SandboxAgent` resource instead of a regular `Agent`. A `SandboxAgent` runs on [Agent Substrate](/docs/kagent/concepts/agent-substrate): the kagent controller runs it as a gVisor-sandboxed actor instead of a Deployment, snapshotting it to object storage when idle and rehydrating it on demand. The spec mirrors the `Agent` spec, with a few constraints: sandboxed agents always use the Go ADK runtime, and `spec.skills` and `BYO` agents are not supported. Configure substrate placement with the optional `spec.substrate` field (for example, `workerPoolRef`).
364
+
You can run a declarative agent in an isolated sandbox by creating a `SandboxAgent` resource instead of a regular `Agent`. A `SandboxAgent` runs on [Agent Substrate](/docs/kagent/concepts/agent-substrate): the kagent controller runs it as a gVisor-sandboxed actor instead of a Deployment, snapshotting it to object storage when idle and rehydrating it on demand. The spec mirrors the `Agent` spec. All three runtimes are supported: **Go** (default), **Python**, and **BYO**. For Go and Python agents, session history is persisted to a local SQLite database in the agent's `durableDir` volume, so conversation state survives pod restarts and Deployment rollouts. BYO agents do not get local session storage automatically. Configure substrate placement with the optional `spec.substrate` field (for example, `workerPoolRef`).
296
365
297
366
For setup steps, see the [Agent Substrate example](/docs/kagent/examples/agent-substrate).
298
367
368
+
## A2A AgentCard metadata
369
+
370
+
When another agent or client discovers your agent over the [A2A protocol](https://google.github.io/A2A/specification/#5-agent-discovery-using-an-agent-card), it reads a machine-readable AgentCard from your agent's `/.well-known/agent.json` endpoint. You can enrich that card with optional metadata fields on the `Agent` spec.
| `iconUrl` | URL to an icon image representing the agent. Must be a valid URI. |
385
+
| `documentationUrl` | URL to human-readable documentation for the agent. Must be a valid URI. |
386
+
| `version` | Version string for the agent, such as `"1.0.0"`. |
387
+
| `provider.organization` | Name of the organization responsible for the agent. |
388
+
| `provider.url` | URL to the agent provider's website or documentation. Must be a valid URI. |
389
+
299
390
## Agents as Tools
300
391
301
392
kagent also supports using agents as tools. Any agent you create can be referenced and used by other agents you have. An example use case would be to have a PromQL agent that knows how to create PromQL queries from natural language. Then you'd create a second agent that would use the PromQL agent whenever it needs to create a PromQL query.
302
393
303
-
Here's how you could reference an existing agent (`promql-agent`) as a tool:
394
+
The following example shows how to reference an existing agent (`promql-agent`) as a tool:
304
395
305
396
```yaml
306
397
...
@@ -326,6 +417,22 @@ Here's how you could reference an existing agent (`promql-agent`) as a tool:
326
417
namespace: other-namespace
327
418
```
328
419
420
+
### Per-call session isolation
421
+
422
+
By default, all calls to the same sub-agent share a single session, which preserves stateful continuity across calls. When a coordinator agent calls the same sub-agent in parallel, shared sessions can cause calls to interfere with each other.
423
+
424
+
Set `isolateSessions: true` on the Agent-type tool to give each call its own fresh session, enabling safe parallel fan-out.
425
+
426
+
```yaml
427
+
spec:
428
+
declarative:
429
+
tools:
430
+
- type: Agent
431
+
agent:
432
+
name: worker-agent
433
+
isolateSessions: true
434
+
```
435
+
329
436
### MCP server endpoint
330
437
331
438
A2A-enabled agents are automatically exposed as an MCP server on the kagent controller. The MCP endpoint is available at `/mcp` on the same port as the A2A endpoint (default 8083).
0 commit comments