2 December 2026 · 12 min read · Download as PDF

Strands harness, worked example: a Kubernetes agent that proves its fix before you approve it

AWS's open-source Strands harness gives you a fully assembled agent in one call. What's in the box, then a worked example run on a real cluster: a read-only kubectl agent, three models with three wrong answers, the few words of instruction that fixed it, and an approval gate before anything changes.

Part 1 of 2 · Strands Harness

Cover: Strands harness, worked example: a Kubernetes agent that proves its fix before you approve it

Strands harness is the open-source, "fully assembled" agent from the Strands Agents project at Amazon Web Services (AWS), built on its software development kit (SDK): one call, create_harness(), gives you an agent that already has shell and file tools, web access, context management, sessions, long-term memory, hooks and a tuned system prompt. This guide explains what's in the box, then builds something real with it: a Kubernetes troubleshooting agent that finds out why a Service isn't answering, proves its fix, and applies it only after a person says yes. Every run below happened on a local cluster on 2 Dec 2026, including the ones that went wrong, because those taught the most.

TL;DR

  • What it is: pip install strands-harness (or npm install @strands-agents/harness), then create_harness(). Apache 2.0. The Python and TypeScript harness reached version 0.6.0 on 27 Nov 2026; the Rust one is a 0.1.0 developer preview from 1 Dec.
  • What you get: a normal Strands Agent, not a wrapper, with eight built-in tools, sessions and memory on disk under ./.agent/, and context management that moves bulky tool output out of the way.
  • The default model is Claude Opus 5.5 on Amazon Bedrock. Any other is one argument away (plus that provider's package extra and key): other Bedrock models, Anthropic, OpenAI, Google, Ollama, LiteLLM, or any model object you build yourself.
  • The worked example: one custom read-only kubectl tool, the built-ins switched off, and an approval gate on the one tool that changes the cluster.
  • What the runs taught: the harness did its part every time; the model, the instructions and what the agent could check decided whether the answer was right. Telling the agent to test its theory before proposing a fix turned a wrong answer into a right one, twice in a row.

Harness, SDK, AgentCore: three names

Strands has two layers, and AWS has a third thing with a similar name, so it's worth sorting out first.


What it is

You write

Strands Agents SDK (strands-agents)

The agent loop and the parts you plug into it: model providers, tools, hooks, sessions, multi-agent patterns, Model Context Protocol (MCP) clients.

An Agent(...) you assemble yourself.

Strands harness (strands-harness)

The SDK, pre-assembled with tested defaults. Returns the same Agent type, so anything the SDK does still works.

create_harness(...) plus whatever you want to change.

AgentCore harness

A managed AWS service: you declare the model, prompt and tools as configuration and Amazon Bedrock AgentCore runs the agent for you. It is powered by Strands and can export to Strands code.

Configuration, no agent code.

This article is about the middle row: the library you run yourself, anywhere.

What's in the box

Part

Default

Change it with

Model

bedrock/global.anthropic.claude-opus-5-5

model="openai/…", "ollama/…", or a model object

Built-in tools

shell, read, write, edit, web_fetch, web_search (where the model can search), programmatic_tool_caller, subagent

builtin_tools=["read"], or [] for none

Your tools

None

tools=[my_tool]

Your instructions

None; the harness's own system prompt

instructions="…", added after it

Sessions

On, saved in ./.agent/sessions, a new one each run

session={"id": "…"} to resume, False to keep it in memory

Long-term memory

On: every few turns a small model picks out lasting facts, saved as Markdown in ./.agent/memory and searched before each turn

memory=False

Context management

On: large tool results are set aside with a preview, read back with retrieve_context

context_manager=False

Project context

Platform, date, working directory and your AGENTS.md, before each turn

builtin_plugins=[]

Hooks and plugins

The harness's own, for the features above

plugins=[…]; the SDK's hooks let you log, check or redirect any step

Approval of tool calls

Off: every call runs

interventions="ask", "smart", a policy, or a handler

The defaults suit a coding agent working in a repository: it can run commands, edit files and look things up. For anything that touches infrastructure, the first thing to do is take most of that away.

The worked example: a Service that doesn't answer

The broken app is two copies of plain nginx behind a Service. It has three faults, the kind that turn up in real clusters and in the Certified Kubernetes Application Developer (CKAD) exam:

YAML
apiVersion: apps/v1kind: Deploymentmetadata:  name: shop-apispec:  replicas: 2  selector:    matchLabels: {app: shop-api}  template:    metadata:      labels: {app: shop-api}    spec:      containers:        - name: api          image: nginx:1.27-alpine          readinessProbe:            httpGet: {path: /healthz, port: 8080}   # nginx listens on 80, and has no /healthz            periodSeconds: 5---apiVersion: v1kind: Servicemetadata:  name: shop-apispec:  selector: {app: shop-api}  ports: [{port: 80, targetPort: 8080}]           # nothing listens on 8080

What you see is the confusing part: both pods are Running, but 0/1 ready, so the Service has no ready endpoints and doesn't answer. To follow along you need Python 3.10 or later, a throwaway cluster (k3d cluster create strands-demo or kind create cluster --name strands-demo), and credentials for a model.

Shell
python -m venv .venv && . .venv/bin/activatepip install strands-harnesskubectl apply -f broken.yaml

Step 1: a read-only agent

Shell
import shleximport subprocessfrom strands import toolfrom strands_harness import create_harnessREAD_ONLY = {"get", "describe", "logs", "events", "top", "explain"}@tooldef kubectl(command: str) -> str:    """Run a read-only kubectl command against the current cluster.    Args:        command: The arguments after "kubectl", for example "get pods -o wide".            Only get, describe, logs, events, top and explain are allowed.    """    args = shlex.split(command)    if not args or args[0] not in READ_ONLY:        return f"Refused: only {', '.join(sorted(READ_ONLY))} are allowed."    run = subprocess.run(["kubectl", *args], capture_output=True, text=True, timeout=30)    return (run.stdout + run.stderr)[-8000:]agent = create_harness(    model="bedrock/openai.gpt-oss-120b-1:0",   # leave out for the default, Claude Opus 5.5    instructions=(        "You are a Kubernetes troubleshooter. Investigate with the kubectl tool, "        "find the root cause, and finish with the exact YAML change that fixes it. "        "You cannot change the cluster: a person applies the fix."    ),    tools=[kubectl],    builtin_tools=[],   # no shell, file or web tools: kubectl is the only way in    session=False,      # keep the conversation in memory: nothing saved to .agent/    memory=False,       # no long-term memory: nothing remembered between runs)agent("The shop-api Service in the default namespace isn't answering. Why?")

Three things carry the weight. The @tool decorator turns a typed function into a tool, and its docstring is what the model reads to decide when and how to call it. builtin_tools=[] removes the shell, so the only way the agent can touch the cluster is through a function that refuses anything but reads. Session and memory are off so each run starts clean and leaves nothing on disk, which is what you want while testing. The cluster is protected by the tool's code, not by asking the model nicely. Read-only isn't the same as harmless, though: get secrets is a read too. On a real cluster, the permissions of the identity the agent runs as are the real boundary (see the questions at the end).

The harness's default model needs Claude enabled in your Bedrock account. Ours isn't, so these runs used models we could call, which turned out to be the most interesting part.

What happened: same harness, different answers

Model (cluster it saw)

What it said

Right?

Amazon Nova 2 Lite on Bedrock (broken)

Both ports should be 80. Kept /healthz.

Two of three. Applied, the probe failed with a 404.

MiniMax M2 on Bedrock (after Nova's fix)

Edit the probe on the Pod.

No: a Deployment's pods are replaced, so you change the Deployment.

gpt-oss-120b on Bedrock (broken)

Change the Service's targetPort, "then the readiness probe will succeed".

No: the probe still points at 8080.

Each answer sounded sure of itself, and each was built on an unchecked assumption, the commonest being that nginx answers on /healthz. Results weren't steady either: on the half-fixed cluster, Nova read the old pods and repeated itself, while gpt-oss spotted the second ReplicaSet and got it right. The harness did its job every time: it called the tool, read the output and stopped with an answer. What it could not do was make the model check its theory. So the fix went into the instructions.

Step 2: make it prove the fix

The agent can't run curl inside a pod (no shell, no exec), but it doesn't need to. The Kubernetes API server can proxy a request to a pod's port, and that's a read: kubectl get --raw /api/v1/namespaces/default/pods/<pod>:80/proxy/healthz. A few more words in the instructions ("every root cause", the recipe, and what counts as a pass):

Shell
    instructions=(        "You are a Kubernetes troubleshooter. Investigate with the kubectl tool, "        "find every root cause, and finish with the exact YAML change that fixes it. "        "Prove a fix before you propose it: to see what a pod really answers on a port "        "and path, run: get --raw /api/v1/namespaces/<ns>/pods/<pod>:<port>/proxy/<path> "        "A probe passes only on a 2xx or 3xx answer. "        "You cannot change the cluster: a person applies the fix."    ),

With the same gpt-oss-120b model that had just been wrong, two runs in a row found all three faults. It tried :80/healthz through the proxy, got NotFound, tried :80/, got the nginx welcome page, read the Service's targetPort from its definition, and proposed port 80 and path / for the probe and targetPort: 80 for the Service. Each run took 8 to 10 tool calls and about 35,000 tokens. Applied by hand, the rollout finished, both pods went 1/1, and a request to the Service returned 200.

Step 3: let it apply the fix, with a person in the way

A troubleshooter that only writes YAML still leaves the typing to you. The next step is a tool that changes the cluster, behind an approval gate. The harness's interventions option takes the Strands SDK's HumanInTheLoop handler; allowed_tools lists the tools that run without asking, and everything else stops for a yes or no:

Shell
from strands.vended_interventions.hitl import HumanInTheLoop@tooldef kubectl_apply(manifest: str) -> str:    """Apply a complete Kubernetes manifest (YAML) to the cluster with kubectl apply.    Args:        manifest: The full YAML of every object to change, as it should be after the fix.    """    run = subprocess.run(["kubectl", "apply", "-f", "-"], input=manifest,                         capture_output=True, text=True, timeout=60)    return run.stdout + run.stderragent = create_harness(    model=...,          # see below    instructions="... (as before) ... Then apply the fix with kubectl_apply "                 "and check that the Service has ready endpoints.",    tools=[kubectl, kubectl_apply],    builtin_tools=[],    session=False,    memory=False,    interventions=HumanInTheLoop(        allowed_tools=["kubectl", "retrieve_context"],   # reads run freely        ask="stdio",                                     # everything else asks on the terminal    ),)agent("The shop-api Service in the default namespace isn't answering. Fix it.")

On the terminal, the run pauses with the whole manifest in front of you:

Shell
Approve "kubectl_apply"?  Input: {"manifest": "apiVersion: apps/v1\nkind: Deployment\n ... targetPort: 80\n"} (y/n):

Answer y or yes and it applies the change, waits for the rollout and checks the endpoints itself. Answer anything else and the call is refused, and the agent is told so. Two lessons came out of building this:

  • Allow-list retrieve_context. When a kubectl describe is long, the harness's context management sets it aside and the model reads it back with its own retrieve_context tool. That's a tool call too, so without the allow-list the gate asks you to approve the agent reading its own notes.
  • Some models write the call instead of making it. In two runs out of three, gpt-oss-120b on Bedrock printed the kubectl_apply arguments as text and stopped, so nothing was applied and the gate never fired. Safe, but useless. DeepSeek V4 Flash made the call properly, DeepSeek has no prefix of its own in the harness; LiteLLM is the string route, and a model object you build and pass in is the other:
Shell
import osfrom strands.models.openai import OpenAIModel   # pip install 'strands-agents[openai]'model = OpenAIModel(    client_args={"api_key": os.environ["DEEPSEEK_API_KEY"], "base_url": "https://api.deepseek.com"},    model_id="deepseek-v4-flash",)

With that model, the agent tested the probe's port and path through the pod proxy, found the Service's targetPort in its definition, asked to apply one manifest with both changes, and after the yes reported 2/2 ready and endpoints on port 80. The Service answered with a 200.

What to take from it

  • Start by removing things. The defaults are built for an agent working in your repository. For anything near infrastructure, switch off the built-in tools and give it narrow tools of your own.
  • Put the safety in code, not in the prompt. The read-only list lives in the tool, and the write lives behind an approval the model can't skip. A subagent inherits the same policy, so it can't get around it either.
  • Give it a way to check itself. Most wrong answers were confident guesses. In these runs, a few words of instruction and a read-only way to test the guess did more than changing the model.
  • Try more than one model. Swapping is one argument, and the differences are large, both in reasoning and in how reliably a model makes tool calls.

Common questions

Is the Strands harness the same as the AgentCore harness?

No. The Strands harness is an open-source library: you run the code, on your laptop, in a container or anywhere else. The AgentCore harness is a managed AWS service that runs an agent from configuration; it is powered by Strands and can export to Strands code when you need more control.

Does it only work with Amazon Bedrock?

No. Bedrock is the default, but the model is one argument: a string like "openai/…", "anthropic/…", "google/…" or "ollama/…", or a model object you build, as with DeepSeek above.

Why is there a .agent folder in my project?

Sessions and long-term memory are on by default and are saved there. session=False keeps the conversation in memory instead, memory=False turns long-term memory off, and session={"dir": ...} or memory={"dir": ...} moves them elsewhere. A new run starts a new session; to carry on a conversation, keep agent.session_id and pass it back as session={"id": ...}.

Can it run inside Kubernetes?

Yes. The Strands documentation has deployment guides for Kubernetes and Amazon Elastic Kubernetes Service (EKS), as well as AgentCore, Lambda, Fargate, App Runner, Amazon Elastic Compute Cloud (EC2) and Docker. Inside a cluster, the service account's role is the real limit, whatever the tool code says. For the read-only agent: get, list and watch on pods, pods/log, events, services, endpointslices, deployments and replicasets, plus get on pods/proxy for the prove-it check (the built-in view role doesn't include it), and nothing on secrets. Applying the fix needs patch on deployments and services as well, so give that to a separate identity, used only behind the approval gate.

Is interventions="ask" enough?

It gates every tool call, reads included, which gets tiring fast. HumanInTheLoop(allowed_tools=[...]) lets reads through; "smart" lets a model judge which calls are risky; a Cedar policy file allows or denies calls by rule, with no model involved.

Keep going

This is part 1 of the Strands Harness series. Part 2 runs the same agent on seven models, 28 times, and asks when a bigger model is worth it. The free Amazon Bedrock Deep Dive covers the pieces around this: your first Strands agent, Strands tools and MCP, and the AgentCore harness, Policy and Evaluations. To practise the troubleshooting itself, with nobody's agent to help, the CKAD course's observability and debugging labs break health checks on a real cluster for you to fix.

More from the blog