Skip to content
This documentation covers the kagent 1.0 alpha. For the latest 0.x release, see the 0.x docs.

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Agent harness

Page as Markdown

Configure a Harness, the resource that defines which runtime executes an agent and what infrastructure it runs on.

Review configuration guidelines and reference for the Harness resource: every field it takes, the four runtimes it can select, and what each runtime supports. To understand a Harness and why an Agent, rather than the Harness itself, names the AgentTemplate that runs on it, see the core concepts.

Configure a Harness

The following configuration is for a complete Harness resource. Only workload, substrate, and one runtime block are required.

kubectl apply -f - <<EOF
apiVersion: api.kagent.dev/v1alpha3
kind: Harness
metadata:
  name: my-harness
  namespace: kagent
spec:
  # Exactly one runtime block: kagent, codex, claude, or byo.
  kagent: {}
  workload:
    image: ghcr.io/kagent-dev/kagent/golang-adk@sha256:ae01c3a6d7e0ed2e044253a26abbfb1a9426f3176363842ca9a954762c274d36
  env:
    - name: OTEL_BSP_SCHEDULE_DELAY
      value: "2000"
  substrate:
    workerPoolRef:
      name: kagent-default
    snapshotPolicy:
      location: s3://ate-snapshots/kagent/
EOF

Review the following table to understand this configuration. For more information, see the API reference.

FieldRequiredDescription
One of kagent, codex, claude, byoYesThe runtime that executes the agent. Naming none, or more than one, is rejected. For the available runtimes, see Choose a runtime.
workload.imageYesThe runtime image, pinned by sha256 digest. A tag alone is rejected, because a revision must be reproducible.
workload.commandFor byoOverrides the image entrypoint, up to 32 entries. Required for the byo runtime, optional otherwise. Every runtime honors an explicit value, the kagent runtime included, regardless of the language its image is written in.
workload.argsNoOverrides the image arguments, up to 64 entries. An override that you omit stays unset rather than taking a default.
envNoEnvironment variables for the runtime, up to 100. Each entry sets a literal value, which is required and can be an empty string. The schema does not define a secret-backed source, so the API server rejects a credentialRef entry as an unknown field. Put credentials on a ModelConfig or a RemoteMCPServer instead. For more information, see About model providers. Note that the kagent installation’s settings, such as the runtime log level, come from the Helm chart’s config.runtimeDefaults block rather than from this setting.
substrate.workerPoolRef.nameYesThe WorkerPoolWorkerPoolA Kubernetes custom resource declaring how many Workers to keep running and which sandbox class they use. An operator must provision one before any Agent can compile.Learn more that this Harness’s Actors are scheduled onto. An operator must provision one before any agent can run.
substrate.snapshotPolicy.locationYesThe object storage location for Actor snapshotsSnapshotThe stored state that an Actor suspends to, held in object storage. Resuming restores the Actor from its most recent snapshot, which is what makes suspending idle agents cheap.Learn more.

A Harness names no AgentTemplate. An AgentAgentA Kubernetes custom resource that pairs one AgentTemplate with one Harness. Each side takes either an inline spec or a reference to an existing resource, and the controller compiles the pair into a revision.Learn more pairs the two through spec.harnessRef, so whoever writes the Agent decides which template runs on which Harness. spec.harnessRef takes a reference only, so a Harness must exist before an Agent can name it. For more information about the pairing, see Core concepts.

A command or argument override belongs to the revision that kagent prepares. Changing one prepares a new revision rather than altering a running agent. A SessionSessionA running conversation with one Agent. Unlike the resources it is built from, a Session is not a Kubernetes resource: kagent's gRPC API creates it and its PostgreSQL database tracks it.Learn more pinned to an earlier revision keeps the command it was prepared with until it moves to the new one.

Choose a runtime

A Harness names exactly one of the following four runtimes, and that choice decides what executes an agent and how much of kagent’s feature set the agent can use.

RuntimeWhat it runsWhen to use it
kagentkagent’s own Go and Python enginesYou want the full feature set: every model provider, agent-as-tool composition, skills, plugins, and long-term memory.
codexThe Codex coding agentYou want Codex to do the work, and your model is OpenAI or an OpenAI-compatible Bedrock deployment.
claudeThe Claude coding agentYou want Claude to do the work, with Anthropic, Bedrock, or Anthropic on Vertex AI as the model.
byoAny container image of your own that implements kagent’s A2A contractYou have an agent framework kagent does not adapt, and you would rather bring the image than the integration. For more information, see Bring your own agent.

The kagent and byo runtimes compile through the same path, so they accept the same model providers and the same AgentTemplate features, except structured output, which only the kagent runtime supports. The codex and claude runtimes are purpose-built adapters, and each accepts a narrower slice.

The agent chat in the kagent UI allows file attachments only on the kagent runtime, so an agent on a byo, codex, or claude Harness has no attachment option in the chat. For the file types and size limits that the UI enforces, see Attach files to a message.

Runtime-specific settings

spec.kagent is the only runtime block that takes settings of its own. The rest are empty.

spec:
  kagent:
    memory:
      modelConfigRef:
        name: embedding-model-config
      ttlDays: 30
FieldDescription
memory.modelConfigRef.nameThe ModelConfig supplying the embedding model, in the Harness’s namespace. Required when memory is set.
memory.ttlDaysHow many days a stored memory entry stays valid. Minimum 1. When omitted, the server applies a default of 15 days.

Setting memory gives every agent on this Harness memory that persists across conversations. For how agents store and retrieve it, see Agent memory.

Setting compaction summarizes older session events so an agent’s prompt stays bounded as a conversation grows. For the two strategies and the rules the API server enforces, see Context management.

Codex and Claude examples

A codex or claude Harness has the same shape as a kagent one, and differs in the runtime block, the image, and the ModelConfigs that it accepts. For the providers and settings that each runtime accepts, see Model provider support, and for the limits each one places on an AgentTemplate, see Tool and skill support.

The ModelConfig reads its API key from the kagent-openai Secret that the OpenAI guide creates. The key must be entitled to the model that you name. A key without access to it fails the turn with Codex execution failed.

kubectl apply -f - <<EOF
apiVersion: api.kagent.dev/v1alpha3
kind: ModelConfig
metadata:
  name: codex-model-config
  namespace: kagent
spec:
  apiKeySecret: kagent-openai
  apiKeySecretKey: OPENAI_API_KEY
  model: gpt-5.2-codex
  provider: OpenAI
  openAI:
    apiFormat: responses
---
apiVersion: api.kagent.dev/v1alpha3
kind: Harness
metadata:
  name: codex-harness
  namespace: kagent
spec:
  codex: {}
  workload:
    image: ghcr.io/kagent-dev/kagent/codex-harness@sha256:04788e85c9e1ef98b3f568b9aa749a5e16d2250d115449332dba98baa26305fa
  substrate:
    workerPoolRef:
      name: kagent-default
    snapshotPolicy:
      location: s3://ate-snapshots/kagent/
---
apiVersion: api.kagent.dev/v1alpha3
kind: AgentTemplate
metadata:
  name: codex-template
  namespace: kagent
spec:
  modelConfig:
    name: codex-model-config
  systemPrompt: You are a concise, helpful coding assistant.
---
apiVersion: api.kagent.dev/v1alpha3
kind: Agent
metadata:
  name: codex-agent
  namespace: kagent
spec:
  template:
    ref:
      name: codex-template
  harnessRef:
    name: codex-harness
EOF

Model provider support

The runtime that a Harness selects decides which ModelConfig an Agent that runs on it can use. This table covers every value that the ModelConfig provider field accepts, including the four that kagent 1.0 rejects on every runtime.

Providerkagentbyocodexclaude
OpenAI✅✅✅❌
Anthropic✅✅❌✅
Bedrock✅✅✅✅
AnthropicVertexAI❌❌❌❌
GeminiVertexAI❌❌❌❌
AzureOpenAI✅✅❌❌
Gemini✅✅❌❌
Ollama✅✅❌❌
SAPAICore❌❌❌❌
Foundry✅✅❌❌
Mistral❌❌❌❌

kagent rejects AnthropicVertexAI, GeminiVertexAI, and SAPAICore on every runtime, because each authenticates with a credential that the egress gateway cannot place in an HTTP header. No agent can use these providers. For the alternatives, see About model providers.

kagent rejects Mistral for a different reason. The controller does not resolve the provider at all, so a Mistral ModelConfig reports unsupported model provider: Mistral.

Some supported combinations still carry restrictions.

CombinationRestriction
codex with OpenAIRequires openAI.apiFormat: responses, and does not accept any other openAI setting beyond baseUrl.
codex with BedrockAccepts only OpenAI gpt-* model IDs, and no bedrock settings beyond region.
claude with AnthropicAccepts no anthropic settings beyond baseUrl.
claude with BedrockAccepts no bedrock settings beyond region.
Bedrock on any runtimeThe Secret must hold an AWS_BEARER_TOKEN_BEDROCK key. A Secret of IAM access keys is rejected, because IAM signs each request locally.

Important

Neither codex nor claude accepts a ModelConfig that sets defaultHeaders, tls, or apiKeyPassthrough. Separately, every runtime rejects a credential that the egress gateway cannot place in an HTTP header, such as an IAM key pair or a Google service account key. For more information about that limitation, see About model providers.

Tool and skill support

The coding-agent runtimes also constrain what an AgentTemplate can ask for.

ConstraintApplies to
A subagent binding cannot itself carry tools, skills, plugins, or nested agents, and must use the same provider and credentials as the agent that binds it.codex, claude
An MCPMCPModel Context Protocol, an open protocol for exposing tools and resources to a model. kagent reaches an MCP server through a RemoteMCPServer resource, and an AgentTemplate binds individual tools from it.Learn more server is bound whole. Claude does not support partial tool selection, so the agent sees every tool the server offers rather than only the ones a binding names. The compiler warns rather than failing.claude
A RemoteMCPServer must use the STREAMABLE_HTTP protocol. SSE is rejected.codex

The kagent and byo runtimes take the full set. For more information about what an AgentTemplate can bind, see About tools.

Telemetry content settings

Tracing carries the prompts and replies that an agent exchanges with a model, and so does log export on the claude runtime. Two settings in the kagent Helm chart decide whether that content leaves the runtime, and each one reaches a different set of runtimes. Both default to false, and both take effect only where tracing or log export is already enabled.

config:
  runtimeDefaults:
    telemetry:
      captureContent: false
      captureRawApiBodies: false
      maxCaptureBytes: 16384
SettingWhat it includesApplies to
config.runtimeDefaults.telemetry.captureContentPrompts and assistant replies in the runtime’s telemetry. On the kagent runtime, the content appears in the span for each model call. That runtime records a tool call’s arguments and reply on the span for the tool call instead, regardless of this setting. On the claude runtime, tool results require tracing, and assistant replies require log export through config.runtimeDefaults.telemetry.logs.kagent, codex, claude
config.runtimeDefaults.telemetry.captureRawApiBodiesThe complete provider API request and response bodies. This setting returns more than captureContent does, and it takes effect only when you set the logs endpoint.claude
config.runtimeDefaults.telemetry.maxCaptureBytesThe budget for each captured prompt or reply, in bytes. Defaults to 16384, with a maximum of 65536.codex, claude

The controller sets OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT in every compiled runtime from config.runtimeDefaults.telemetry.captureContent, so a Harness cannot change the capture decision for itself. Naming that variable in the Harness spec.env field fails the claude and codex runtimes outright, and is discarded on the kagent runtime. For the rest of the variables that behave this way, see Controller-owned telemetry variables.

The controller compiles the telemetry environment into the byo runtime as well whenever any signal is enabled, so OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT reaches a byo image. The byo runtime is the exception to the ownership rule. The controller applies the Harness spec.env field after the telemetry environment, so a spec.env entry wins where the two name the same variable, and an image that exports to its own backend keeps doing so. Whether the image acts on either setting depends on its own instrumentation. For more information, see Tracing.

Controller-owned telemetry variables

The controller compiles an installation’s telemetry decisions into every runtime revision, so a Harness cannot override them through its spec.env field. The controller owns the following variables.

  • OTEL_SDK_DISABLED and OTEL_SERVICE_NAME
  • OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL, and OTEL_EXPORTER_OTLP_TIMEOUT
  • OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, and OTEL_LOGS_EXPORTER
  • OTEL_EXPORTER_OTLP_<SIGNAL>_ENDPOINT and OTEL_EXPORTER_OTLP_<SIGNAL>_PROTOCOL, where <SIGNAL> is TRACES, METRICS, or LOGS
  • OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT

A runtime that meets one of these names in spec.env either refuses the Harness or discards the entry, as described in the following table.

RuntimeResult of naming a controller-owned variable in spec.env
claudeEvery Agent on the Harness reports Compatible as False, and the controller reports Harness env "<name>" conflicts with Claude-owned runtime configuration.
codexEvery Agent on the Harness reports Compatible as False, and the controller reports Harness env "<name>" conflicts with Codex's compiled configuration.
kagentThe entry is dropped and the controller’s own value is compiled in its place. No error is reported.

Two further variables fall outside that table:

  • OTEL_RESOURCE_ATTRIBUTES is merged rather than refused. The value in spec.env is kept, and the agent identity attributes that the controller adds win where the two name the same attribute.
  • OTEL_EXPORTER_OTLP_HEADERS is neither owned nor rendered. No Helm setting produces it, so the controller never adds it to a runtime, but a value in the Harness spec.env field reaches every runtime unchanged. To attach headers without holding them in an Actor environment, export to an in-cluster collector that adds them.

Every other OTEL_* variable, such as the OTEL_BSP_* batch span processor settings, stays available for per-Harness tuning.

Baggage propagation

Baggage is a W3C header that travels with a request alongside its trace context. Each entry in that header is a member, which pairs a name with a string value. Every service that the request reaches can read the members that it carries.

When the environment leaves OTEL_PROPAGATORS unset, kagent runtimes set it to tracecontext. A caller’s baggage does not reach the tools that an agent calls or the agent’s model provider, but trace context still propagates. To carry baggage as well, set OTEL_PROPAGATORS to tracecontext,baggage in the Harness spec.env field. The kagent controller reads its own value only from the controller.env Helm value, so enabling baggage on a runtime does not enable it on the kagent controller.

OTEL_PROPAGATORS is a list of wire formats that apply to both incoming and outgoing requests. If an incoming request has a format that is not in the list, the format is not read. Similarly, the runtime does not write an omitted format to an outgoing one. When the list omits baggage, the runtime’s own members are dropped too.

When baggage is listed, the kagent runtime adds the request’s identity to the baggage of each model call and each MCP tool call.

MemberModel callsMCP tool calls
gen_ai.agent.nameYesYes
gen_ai.conversation.idYesYes
a2a.task.idYesYes
gen_ai.tool.call.idNoYes

These members serve as identifiers only, and the runtime can replace a caller’s member of the same name.

Warning

Enabling baggage sends the caller’s own members to your model provider. A caller baggage member that kagent does not replace is forwarded unchanged in the baggage header of each model API request and each MCP request. This means that a caller controls what reaches those external services in the header. Enable baggage only where you trust what your callers attach.

Review and plan for the following considerations.

  • The claude and codex runtimes receive OTEL_PROPAGATORS, but kagent does not add identity to their model and tool calls. The Python runtime does not add any either, so the four members reach the kagent runtime alone.
  • kagent never copies a baggage member onto a span. To make these values searchable, add a baggage-to-attributes span processor to the service that receives the request or to its OpenTelemetry Collector.

When an agent requires an MCP server, the first tool listing or tool call opens a session with the MCP server, and every later request to that server shares it. The session makes three requests: the event stream, the replies to server requests, and the close. These requests do not carry trace context or baggage, because these name a request that has already ended.

Check that a Harness is ready

The READY column reports whether a Harness’s dependencies resolved.

kubectl get harness -n kagent

A Harness that is not Ready most often names a WorkerPool that does not exist yet. For the specific reason, read its conditions with kubectl describe harness <harness-name> -n kagent.

Ready covers the Harness’s own dependencies, not whether a given agent runs on it. Whether a template compiles against this Harness is reported on the Agent that pairs the two, because an AgentTemplate does not report status of its own. For that check and the conditions it reports, see Your first agent.

Next steps