Harness optimization for AI agents in Strands Evals Strands released the `strands_evals.optimization` module in Strands Evals, a tool that automatically searches for better harness configurations — system prompts, tool descriptions, skills, thinking effort and context management — against a team's own test cases. The release follows an earlier Strands experiment of 94,000 trials that found the harness alone changed the cost of a task by 2x or more with the same model on the same tasks. The optimizer can target the fewest tokens that keep a pass rate above a floor or the best pass rate within a token budget, reports the tuned harness against the current one on a separate set of test tasks with a confidence interval, and returns every proposed change as a reviewable diff that nothing applies until the user approves it. A few weeks ago, we ran 94,000 trials to measure the cost of harness choice https://strandsagents.com/blog/we-ran-94000-trials-to-measure-the-cost-of-harness-choice . With the same model on the same tasks, the harness alone changed the cost of a task by 2x or more. We used what we learned to choose default settings for Strands harness that work well across many kinds of tasks. Your harness may still benefit from settings optimized for your specific use case, such as its system prompt, its tool descriptions and skills, how long the model thinks, how it manages context, and which components are switched on. Most teams tune them by hand, but that’s hard to do well. A better prompt comes from reading failed transcripts, working out why they failed, and writing a fix that doesn’t break the tasks that already pass. A better setting comes from running your harness with each option and comparing the results. These changes also interact with one another, so a prompt that works well at one effort level can fall short at another. Teams rarely have time to explore more than a few options, so the settings that would work best for their agent often go untested. Today we’re releasing harness optimization in Strands Evals, the strands evals.optimization module, to make this tuning easy. You tell it which components of your harness you want to tune and what to optimize for, and it searches for a better configuration on your own tasks. It improves on tuning by hand in five ways. - Your agent gets better at the tasks you care about. The optimizer tunes the whole harness against your own test cases, including its instructions, skills and settings. - You can cut costs without giving up quality. Ask for the fewest tokens that keep your pass rate above a floor, or the best pass rate within a token budget. - You get performance you can rely on. The optimizer measures the tuned harness against your current one on a separate set of test tasks, with a confidence interval. - You stay in control of your agent. Every proposed change comes as a diff you can review, and nothing changes until you apply it. - It works where you already work. Work with your favorite coding agent to run the optimizer through a skill, or use the strands dev environment or the Python SDK directly. Get started The easiest way to start is to point your coding agent to the optimize skill https://github.com/strands-agents/evals/tree/main/.agents/skills/optimize in the Strands Evals repository. The skill works in any coding agent that can load skills, such as Claude Code, and it optimizes an agent built with Strands harness against an experiment, a set of test cases with the evaluators that score your agent’s answers. Ask for an optimization in your own words, such as “optimize my support agent’s instructions and effort on the triage experiment, with at most 3,000 tokens per ticket.” The skill finds your agent file and your experiment and asks what may change, what to improve, and what limits to keep. Before anything runs, it shows the plan with an estimate of the model calls it will make. When the run ends, it reports how the selected version compares with your current agent on the test tasks, with a confidence interval, and it leaves the proposed changes for you to apply. You can also optimize from strands dev , a mode of the Strands CLI for building, testing and improving a harness in its own workspace. Inside a dev chat, /experiment creates, runs and reviews experiments, and /optimize tunes the agent against it. /optimize asks which experiment to use, what may change, what to improve and what must stay true, then shows a plan for you to approve. When the run finishes, it reports how the selected version scored against your agent on the test cases and shows each proposed change as a diff for you to apply or leave Figure 1 . You can also run the optimizer from the command line with strands-evals optimize run , or configure it directly with the Strands Evals SDK in Python, as an Optimizer object built from an agent factory whose tunable arguments you mark with @tunable . Choose what to optimize A key part of setting up any optimization is deciding what you’re optimizing for. In Strands Evals, you state that as an objective and, optionally, constraints. The objective is the one quantity it tries to improve, such as an evaluator’s mean score, which it maximizes, or the tokens the agent uses per task, which it minimizes. A constraint is a limit that the selected harness has to stay within, such as at most 3,000 tokens per task or a pass rate of at least 90%. The objective decides which candidate is best, and the constraints decide which candidates can be selected at all. Combining an objective with a constraint lets you balance accuracy against cost, which often pull in opposite directions. If you maximize the pass rate with no constraint, the optimizer may select a harness that thinks longer and uses many more tokens for a small gain. Sometimes that’s the right trade, but if cost matters to you, add a constraint on tokens. If you’re already satisfied with your agent’s performance but want it to be more cost-effective, you can turn the problem around and minimize tokens, with a minimum pass rate as the constraint. Figure 2 shows each harness’s pass rate against its token consumption per task, and each point represents one harness configuration. The plot on the left illustrates what it looks like to optimize for task success subject to a maximum allowed token consumption. Every harness to the right of the dashed line uses more than 3,000 tokens per task, including the one with the highest pass rate, so the optimizer selects the best harness to the left of the line. The plot on the right illustrates what it looks like to place a floor on task success and minimize token consumption. Only the harnesses above the 90% line qualify, and the optimizer selects the one with the fewest tokens, which matches the baseline’s pass rate with about a third fewer tokens. How it works Before the search starts, the optimizer splits the tasks in your experiment into three sets. It searches on the training tasks, picks its result on the validation tasks, and measures that result against your current harness on the test tasks. Keeping the three sets apart guards against overfitting, because a harness that only does well on the training tasks won’t show a gain on the test tasks. You can mark any argument of the function that builds your agent as tunable, including a component you wrote yourself. Each component of your harness that the optimizer may change is represented by a type, and each type has its own method for proposing new values during optimization. Text, such as the agent’s instructions, tool descriptions, or the contents of its skill files, goes to the rewriter, a Strands agent that reads the transcripts and scores of the best candidate so far and writes new versions of the text. Numbers, such as the context manager’s summarization threshold, and settings with a fixed list of values, such as the reasoning effort or prompt caching, go to a Bayesian optimizer. Each search step proposes several candidates from the best one so far and runs each of them on every training task, once or several times. Sometimes a component is a choice between several options, each with settings of its own. Strands harness offers ready-made context managers, "auto" and "agentic" , and you can also build one from strategies, such as summarizing older turns once a set share of the context window is used, or truncating tool results above a set number of tokens. With choice in an agent factory, you can let the optimizer pick between options like these, and it keeps a separate model of the settings for each option it has tried. When the space includes a choice like this, the search runs in rounds. Each round first picks an option, then alternates text steps and settings steps under it Figure 3 . Because agent runs are noisy, a candidate can reach the top of the ranking on a few lucky runs. So the optimizer doesn’t rank candidates by their raw average scores. After each step, it fits a Bayesian model to all the results so far and ranks candidates by the model’s estimates. The model gives less weight to a score that rests on only a few runs, so a lucky result doesn’t carry a candidate to the top. When the search ends, the top finalists and your baseline run again on validation tasks, and a model fitted only to those runs picks the best of them that meets every constraint. It counts a constraint as met when the model is at least 90% sure of it, and if no candidate meets them all, the result is the baseline. The pick and the baseline then run once on the test tasks, paired task by task, and the result reports the difference with a 90% interval. A trial that fails because a model call was throttled or a connection dropped runs again instead of counting as a failed task. The run’s folder records every trial, with its transcript, scores and token usage, and every candidate’s changes, so you can trace how the harness changed from step to step. The selected changes go to best.diff for text and best.values.json for settings, for you to review and apply. How does it perform? To measure how much tuning helps, we ran the optimizer on four public agent benchmarks, with Claude Haiku 5.5 as the model in Strands harness. In τ²-bench telecom and τ³-bench banking, the agent helps a simulated customer fix a problem over a conversation. In AppWorld, it completes everyday tasks across simulated apps, such as email and payments, and in Terminal-Bench 2.1, it completes tasks in a Linux terminal. Some studies maximized the task success rate, and others also set a cost objective or a constraint, as in Figure 2. In every study, the optimizer could try 48 candidate harnesses, and the table compares the harness it selected with the starting harness on the benchmark’s test tasks. | Benchmark test tasks | Objective | Baseline → selected | Tokens vs. baseline | |---|---|---|---| | τ²-bench telecom 114 | maximize reward, then minimize cost | 59.9% → 99.1% | ×0.84 | | τ³-bench banking 96 | maximize reward, then minimize cost | 20.1% → 32.3% | ×1.29 | | AppWorld test challenge 417 | maximize reward | 70.4% → 87.3% | ×1.52 | | AppWorld test challenge 417 | reward and cost together, prompt only | 71.6% → 84.0% | ×0.70 | | Terminal-Bench 2.1 40 | maximize reward | 63.7% → 76.2% | ×0.86 | | Terminal-Bench 2.1 40 | minimize cost, reward within 5 points | 61.3% → 66.2% | ×0.29 | On telecom, the selected harness solved 99% of the test tasks, up from 60%, with a 16% lower token cost. On AppWorld, maximizing reward raised the pass rate by 17 points, and optimizing reward and cost together raised it by 12 points with 30% fewer tokens. On Terminal-Bench 2.1, a cost objective with a constraint to keep success within 5 points cut tokens by 71%. Try it out Install Strands Evals with the optimization extra: To optimize from your coding agent, add the optimize skill https://github.com/strands-agents/evals/tree/main/.agents/skills/optimize from the Strands Evals repository. To use strands dev , install the Strands CLI, which includes it: The rewriter runs shell commands to analyze your agent’s transcripts, and those commands have the same file and network access you do. Run the optimizer where you’re comfortable running model-written commands, such as a container or a development machine with limited credentials. A run’s folder holds full transcripts of your test tasks, so keep it out of version control. Measure your own agent on your own tasks, with the model you plan to run in production. We’d like to hear what the optimizer finds, so open an issue https://github.com/strands-agents/evals/issues or come tell us on Discord https://discord.gg/strands .