Figure 1
Evaluating and optimizing an agent in strands dev
Strands Agents refund-cases: 6 of 20 passed, score 0.581. Failed cases, with the reason the evaluator gave: 1. unworn_in_packaging_within_30_days_approve : says "may be eligible" and asks about final sale and order details instead of approving. 2. unworn_in_packaging_within_30_days_approve-2 : conditional answer, asks about final sale and the delivery date. 3. Approve - Unworn item returned within 30 days : wrong decision. The expected outcome is deny, because the customer tried the jacket on, but the reply says "likely eligible". 4. approve_unworn_item_within_30_days : says "look eligible" but adds a final-sale check and says it can't process the refund. 5. unworn_in_packaging_within_30_days_approve-3 : "likely eligible", with approval dependent on a final-sale check and an order number. 6. unworn_item_within_30_days_approve : conditional on an order number before any decision. 7. unworn_item_within_30_days_approve-2 : "look eligible", but never approves. 8. unworn_item_within_30_days_approve-3 : "looks eligible", never a clear approval. 9. Approve - Unworn item in original packaging within 30 days : conditional on order number and final-sale confirmation. 10. unworn_item_within_30_days_approve-4 : "may well qualify" and "can't confirm yet". 11. unworn_item_within_30_days_approve-5 : "likely eligible", dependent on final-sale check and order number. 12. Approve - Unworn jacket returned within 30 days : "likely eligible", with more conditions before a decision. 13. unworn_in_packaging_day_30_exact_boundary : "likely eligible" with conditions, and it questions the date using a system clock. 14. unworn_item_day_30_exact_boundary : "can't confirm yet", hedging on the date and final sale. Thirteen of the fourteen failures are hedged approvals: the policy reasoning is right, but the reply never clearly approves. The one wrong decision is case 3.
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ optimize │ │ What may the optimizer change? Each trial starts with a fresh session. │ │ │ │ ☑ instructions rewritten by the proposer model (default); your agent's instructions (system prompt) │ │ ☐ model choose models to try; you name them in the next step │ │ ☑ effort auto · low · medium · high · xhigh · max; not in the call, so the run starts from the harne… │ │ ☐ prompt caching auto · on · off; not in the call, so the run starts from the harness default │ │ ☐ built-in tools on/off for each: shell, read, write, edit, web_fetch, programmatic_tool_caller, subagent; n… │ │ ☐ background tasks on · off; not in the call, so the run starts from the harness default │ │ › ☑ context manager auto · agentic · off; not in the call, so the run starts from the harness default │ │ ☐ skills on · off; not in the call, so the run starts from the harness default │ │ ☐ built-in plugins on/off for each: environment; not in the call, so the run starts from the harness default │ │ │ │ [ OK ] Back │ │ ↑↓ · Enter toggle · ↓ chat · Esc cancel │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ optimize │ │ What should the optimizer improve? │ │ │ │ ○ 1. Maximize the mean of every evaluat… the score of OutputEvaluator │ │ ○ 2. Minimize a usage metric ex. tokens, output tokens, seconds, or model calls │ │ ○ 3. Balance several metrics ex. the evaluators and tokens; weigh them or find the best trade-offs │ │ ○ 4. Your own │ │ │ │ [ OK ] Back │ │ ↑ answer this │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Strands Agents optimize · refund-cases · 20 cases · 10 train / 5 validation / 5 test • agent: refund-desk/agent.py • tune: instructions (rewritten by the proposer model), effort (starts at auto, may try low, medium, high), context manager (starts at auto, may try agentic or off). Effort and context manager aren't in your agent's call, so the run starts from the harness default and applying an edit would write them into the call. • models: unchanged (current model) • goal: maximize OutputEvaluator (the mean of every evaluator, and it's the only one) • constraints: tokens at most 12000 per case on average, 90% sure each holds (default) • cases: 10 train / 5 validation / 5 test (default split) • budget: 4 steps × 4 candidates, 1 run of each case, 3 finalists • parallel: 8 trials at once • crashes: a crashed run scores the worst value (default) • pick: the best average score of the 3 finalists (default) • estimate: about 200 rollouts and 200 judge calls, roughly 6.3M tokens and about 835 seconds of agent time, based on the last refund-cases run; price unknown Warnings • The model, judge, and proposer calls are paid and use your credentials. • The optimization runs this agent in /home/ubuntu/work/blog/demo-0.5/refund-desk , and its shell, write, and edit tools can change files there.
Optimization result: 20261126-011441-902b18
=============================================================================================
Objective: Maximize(OutputEvaluator)
Constraints: tokens <= 12000
P(met) >=: 0.9
Stop reason: iterations Rollouts: 190 / 500
Iterations: 4 Pick rule: Mean
Champion: candidate 14 Outcome: top_finalist
Parent: candidate 10
Proposers: text (Reflection), numbers (TPE)
Changed: context_manager, effort, instructions
=============================================================================================
Validation id goal estimate sd measured n P(met) status
---------------------------------------------------------------------------------------------
baseline 00716ca3f6d1 OutputEvaluator 0.746 0.066 0.710 5 feasible
tokens <= 12000 7,071 548 7,282 5 1.000
candidate 14 * 02eaf525e869 OutputEvaluator 0.879 0.042 0.904 5 feasible
tokens <= 12000 4,819 330 4,621 5 1.000
candidate 11 92f4d7aba5d2 OutputEvaluator 0.879 0.042 0.934 5 feasible
tokens <= 12000 4,822 330 4,931 5 1.000
candidate 13 d0807420fb4d OutputEvaluator 0.878 0.042 0.830 5 feasible
tokens <= 12000 4,820 330 4,761 5 1.000
=============================================================================================
Test vs baseline baseline champion diff 90% CI n
---------------------------------------------------------------------------------------------
OutputEvaluator 0.510 0.790 +0.280 [+0.082, +0.478] 5
tokens 9,928 4,582 -5,346 [-10,918, +226] 5
=============================================================================================
Changed baseline champion
---------------------------------------------------------------------------------------------
context_manager 'auto' False
effort 'auto' 'xhigh'
=============================================================================================╭───────────────────────────────────────────────────────────────────────╮ │ optimize · edit 1 of 3 · 20261126-011439-refund-cases │ │ Apply this change to instructions? │ │ agent.py · +10 -1 lines │ │ @@ -1,9 +1,18 @@ │ │ You answer refund requests for Northwind Outfitters. │ │ │ │ Refund policy: │ │ - - Unworn items in original packaging can be refunded within 30 │ │ days of delivery. │ │ + - Unworn items in original packaging can be refunded within 30 │ │ days of delivery (day 30 counts as within the window). │ │ - Sale items marked final sale cannot be refunded. │ │ - Items that arrive damaged or defective can be refunded within │ │ 90 days of delivery, with a photo. │ │ - Gift cards and digital downloads cannot be refunded. │ │ - Refunds go back to the original payment method. │ │ │ │ + How to answer: │ │ + - Answer directly from the customer's message. Do not use any │ │ tools, and never run commands or check a system clock or system │ │ date. Take everything the customer says as true, including the │ │ delivery date and what "today" is. If they give both dates, count │ │ the days between them and state the number. Never contradict the │ │ customer's dates or ask them to verify a date. │ │ + - Give a clear decision in the first sentence. If the facts meet │ │ the policy, say plainly that the refund is approved and goes to │ │ ↓ 20 more │ │ ○ Apply this change │ │ ○ Leave it as it is │ │ [ OK ] Cancel │ │ ↑ answer this │ ╰───────────────────────────────────────────────────────────────────────╯ ✓ optimize · applied agent.py, agent.py, agent.py · run the experiment again from /experiment to check your agent ✓ ↻ agent.py reloaded · session kept
Strands Agents refund-cases: 18 of 20 passed, score 0.889. The previous report was 6 of 20. Failed cases: 1. Approve - Unworn item returned within 30 days : the agent approved a jacket the customer had tried on. The expected outcome is a denial because it isn't unworn, and the reply also said trying it on still counts as unworn, which misstates the policy. Score 0. 2. Damaged item within 90 days but no photo provided-2 : the reply says the refund is "approved" and asks for a photo afterward. The expected outcome is a conditional approval pending the photo, and the reply doesn't cite the photo requirement. Score 0.2.
strands dev session on a refund-policy agent and an experiment of 20 cases, which the starting agent passed 6 of. The optimization maximized the evaluator's score with a cap of 12,000 tokens per case. On the 5 test cases, the selected version scored 0.79 against the starting agent's 0.51. The fifth tab shows the optimizer's summary of the finalists and that test check, and the last tab runs all 20 cases again, training cases included, after the changes are applied.