Table of Contents
In the AgentCore Optimization Loop article, I let AWS rewrite the system prompt of my DevOps agent. The recommendation was good, but it had an effect I didn’t measure at the time: the prompt grew. The optimizer kept everything I had written and added two new blocks.
The Advanced Prompt Optimization documentation acknowledges this: by default it optimizes for quality only, with no length constraint, and an optimized prompt can end up longer than the original. Longer means more input tokens on every call and, potentially, a longer time to first token.
On October 20, 2026, AWS announced an option for that, shortenPrompt, which asks the optimizer for a prompt shorter than the original with an equal or better score. If it can’t find one, it gives you yours back.
I wanted to answer a concrete question: how much does shortening a prompt that already works actually save me, and at what volume is it worth it? To find out, I used the real classifier prompt of my news agent, the 205 classifications it made in production as the reference, and three target models. The result wasn’t what I expected, and neither were the reasons.
📌 TL;DR — What I found
- In all six optimizations (three models, with and without
shortenPrompt), the prompt the service returned is identical to the original, character for character.compressionRatio = 1.0on all three models.- One job reported a +45% improvement (0.575 → 0.833) for that identical prompt. The cause: 12 failed inferences on the original side, with zero tokens, scored as 0.
- Another job finished as
CompletedwithSUCCESSeven though the optimizer failed on 684 of 689 calls. I only saw it in the CloudWatch error metrics.- Even with the 30% cut from the announcement’s example, at my volume (~267 calls a month) the job would take between 9 and 55 years to pay for itself.
- The same prompt with the same news item measures 1,621 tokens on Haiku 5.5, 1,132 on Haiku 4.5, and 917 on Nova 2 Lite. The service counts it as 600 on all three.
What Advanced Prompt Optimization Is and What shortenPrompt Adds
Advanced Prompt Optimization is Bedrock’s full optimizer, different from the simple OptimizePrompt. You give it a JSONL file with your templates (variables in double braces, {{variable}}), up to 100 evaluation samples per template, and an evaluation method: the default judge, free-text criteria (steeringCriteria), an LLM judge with your rubric, or your own Lambda. The service runs an inference, evaluation, and rewrite loop on each target model and returns one optimized prompt per model. A job accepts up to 10 templates and 5 models, and the documentation talks about 15 to 20 minutes for a prompt with few samples and several hours for many. My jobs took 14 and 29 minutes.
shortenPrompt is enabled per template, inside the JSONL, not in the API call:
{
"version": "bedrock-2026-05-14",
"templateId": "news-classifier-shorten",
"promptTemplate": "...",
"optimizationConfig": { "shortenPrompt": true },
"customEvaluationMetricLabel": "clasificacion_vs_produccion",
"evaluationMetricLambdaArn": "arn:aws:lambda:us-east-1:<cuenta>:function:apo-news-classification-evaluator",
"evaluationSamples": [ "..." ]
}
The return logic is simple: the shortened prompt is returned only if it is shorter and scores at least as high as the original. If either condition fails, you get your original prompt back with compressionRatio = 1.0. The ratio is optimizedTokenCount / originalTokenCount, measured on the template and not on the prompt with the variables filled in.
On cost, the documentation says there is no separate service charge: you pay for the tokens it consumes. The pricing page gives the formula: about 16 × N target model inferences per template, where N is the number of samples, plus the optimizer (currently Claude Sonnet 4.6) with 101 × (3700 + 0.35 × P) input tokens, where P is the token count of your template. The optimizer’s output tokens have no formula.
The Experiment
The prompt: my news agent’s classifier
My agent processes the AWS RSS feed three times a day. Since late September the model no longer computes relevance: it only classifies each news item into a topic (topic_tier) and a change type (change_type), and a rubric with editable weights computes the 0 to 10 score. If the score reaches 6, a post is generated; if it reaches 7, the item goes into the newsletter.
I chose this prompt for three reasons. It has an objective answer, so it can be evaluated without a subjective judge. It runs every day, so it has real volume to compute savings against. And it was already compact, about 1,900 characters: if shortening finds something to cut here, it will find it in almost any prompt. A fragment:
topic_tier: el tema al que pertenece el servicio o la capacidad (elige el más específico):
• genai_agentes: Bedrock, IA generativa, agentes, MCP, Amazon Quick, AgentCore, SageMaker AI
• serverless_core: Lambda, Step Functions, API Gateway, EventBridge, DynamoDB
...
change_type: qué tipo de cambio anuncia la noticia (juzga el cambio, no el servicio):
• nueva_capacidad: una función o servicio que antes no existía
• mejora: una mejora incremental de algo que ya existía (límites, rendimiento, integraciones)
...
The reference: what production decided
I didn’t label anything by hand. The reference for each news item is the classification production made, stored in DynamoDB: 205 news items classified between September 30 and October 22, 2026. I split the set deterministically, by ID hash: 60 items for the optimizer and 145 as a holdout it never sees.
With this reference I’m not measuring whether the shortened prompt is more accurate, but whether it behaves the same as the current one. For a shortening, that seems like the right question to me: I’m looking for a cheaper prompt that doesn’t break anything, which makes it a regression test. The downside is that if production was wrong, the optimizer learns to repeat the mistake.
The evaluator: a deterministic Lambda
Advanced Prompt Optimization offers four ways to evaluate, and I ruled out three. The default judge scores accuracy, completeness, and Expression Quality, and that last criterion rewards short answers, so it would have optimized the brevity of the output instead of the classification. steeringCriteria are too vague for a task with an exact answer. An LLM judge adds cost, because the judge reads prompt, response, and reference on every evaluation, and it adds its own noise to something you can settle by comparing two values.
I went with a Lambda. The contract the service requires is simple: you receive {"preds": [...], "golds": [...]} and return {"score": float, "scores": [...]}, higher is better. My rule: if the output isn’t valid JSON with all the allowed keys and values, the sample scores 0; if it is, it gets 0.5 for the right topic and 0.5 for the right change type.
def compute_score(preds, golds):
"""Mandatory JSON contract; 0.5 for the right topic_tier and 0.5 for the right change_type."""
scores = [score_one(p, g) for p, g in zip(preds, golds)]
return {"score": sum(scores) / len(scores) if scores else 0.0, "scores": scores}
The service reads the docstring as the metric description and reviews the full code before using it. That review cost me my first job; I cover it in the gotchas.
The template: what the optimizer can touch and what it can’t
In production the prompt goes in as the system prompt, the news item as the user message, and the output uses Structured Outputs. Advanced Prompt Optimization takes a single text template and doesn’t accept structured outputs, so the JSON contract has to live inside the prompt. I protected it with <advpo:exclude>: the optimizer can rewrite the classification instructions, but not the news item or the output format.
<advpo:exclude>Noticia a clasificar:
Título: {{title}}
Descripción: {{description}}
Responde ÚNICAMENTE con un objeto JSON, sin texto antes ni después, con exactamente estas claves:
change_type, topic_tier, topic, reason, keyPoints (lista de textos) y emojis (lista de textos).
En topic_tier y change_type usa solo las claves listadas arriba.</advpo:exclude>
In the same job I put two identical copies of the template, one optimized for quality only (the default behavior) and one with shortenPrompt: true, to compare them under the same conditions.
Three models and two accounts
This part of the design changed along the way. Since October 8, my agent consumes Claude Haiku 5.5 through the Anthropic API, not through Bedrock. Advanced Prompt Optimization only optimizes Bedrock models, and my working account can’t invoke Haiku 5.5 on Bedrock. The account that can hadn’t submitted the Anthropic use case form, so Haiku 4.5 didn’t run there.
I ended up running one job per account, with the same data and the same evaluator: Claude Haiku 5.5 (the production model) in one, and Claude Haiku 4.5 (the production model until October 8) plus Amazon Nova 2 Lite in the other. Nova is the model I dropped in March because it didn’t support structured outputs; since Advanced Prompt Optimization works with plain text, that limitation doesn’t matter here. That same missing form ended up affecting the Haiku 5.5 job too, as I explain in Finding 3.
Hypotheses, written before seeing results
I followed the same method as in previous articles: before reading the job results, I wrote down each hypothesis with the criterion that would refute it.
- H1 — Shortening finds something to cut. At least one model returns
compressionRatio < 0.9. Refuted if all three return 1.0 or a ratio above 0.9. - H2 — The shortened prompt behaves the same on the holdout. The score difference against the original, on the same model, stays within the noise floor. Refuted if it falls below that floor.
- H3 — At my volume, the savings don’t pay for the job. At ~267 calls a month, the monthly savings don’t cover the job cost in under 12 months on any model. Refuted if any model recovers the cost in a year or less.
- H4 — Optimized prompts aren’t portable. The prompt optimized for one model loses more than the noise floor when run on another. Refuted if they perform the same on all three models.
📋 Recorded deviations: (1) the original design used only Nova 2 Lite, because Haiku 5.5 wasn’t available on Bedrock in my working account; (2) I moved to three models split across two accounts; (3) the job runs Haiku 5.5 with its default configuration, which uses thinking, unlike production (see gotchas); (4) the first two jobs failed because of the Lambda code validator; (5) I stopped a job running the old evaluator, and its window overlaps by a few minutes with the good job in that account, which slightly inflates the costs measured there; (6) my holdout baseline ran in parallel with the Haiku 4.5 job.
All the code is at github.com/codecr/bedrock-prompt-shortening: scripts numbered 01 to 07, the evaluator, and the cleanup.
Baseline: How Much the Prompt Differs from Itself
Before looking at any optimized prompt, I ran the original on the 145 holdout news items, twice on each model. The second run matters because the model isn’t deterministic: if two variants differ by less than the original prompt differs from itself, that difference means nothing. Haiku 5.5 ran as it does in production, without thinking and with low effort.
| Model | Score vs production | JSON contract | Agrees with itself | Tokens in / out | Median TTFT | Cost per 1,000 calls |
|---|---|---|---|---|---|---|
| Claude Haiku 5.5 | 0.848 | 100% | 133/145 (91.7%) | 1,621 / 334 | 1.11 s | $0.36 |
| Claude Haiku 4.5 | 0.840 | 100% | 128/145 (88.3%) | 1,132 / 284 | 0.66 s | $2.81 |
| Amazon Nova 2 Lite | 0.760 | 100% | 140/145 (96.6%) | 917 / 191 | 0.47 s | $0.83 |
Nova is the most stable and the one that agrees least with production: it repeats its answer 96.6% of the time, but being consistent doesn’t make it more accurate. Haiku 5.5 doesn’t reach 1.0 even against references it mostly generated itself, because in production it runs with a separate system prompt and structured outputs, and changing how you call the model already moves the result. And the noise floor is high: the same prompt changes the classification of between 5 and 17 of 145 news items from one run to the next. An improvement smaller than that can’t be told apart from chance.
A business data point: with the active rubric, Haiku 5.5’s classification changes the decision to generate a post on 10 of the 145 news items compared with what production decided. That margin of error already exists in my pipeline today, and I hadn’t measured it.
🔢 ProTip #1: The same text doesn’t measure the same on every model. My prompt with the same news item is 1,621 tokens on Haiku 5.5 versus 1,132 on Haiku 4.5: 43% more. Before calculating how much trimming a prompt saves you, measure its tokens on the model where it will run. And don’t use the job’s
originalTokenCountfor that: the service counted my template as 600 tokens on all three models, with its own count that isn’t the tokenizer you’re billed for.
Finding 1: Six Optimizations, Zero Changes
This is the complete result of the two jobs. “Identical” means identical character for character to the original, once the <advpo:exclude> tags are removed, which the service always strips.
| Model | Template | Original score → “optimized” | compressionRatio | Failed inferences (orig / opt) | Did the prompt change? |
|---|---|---|---|---|---|
| Haiku 5.5 | quality | 0.808 → 0.850 | — | 0 / 0 | No |
| Haiku 5.5 | shorten | 0.825 → 0.825 | 1.0 | 0 / 0 | No |
| Haiku 4.5 | quality | 0.575 → 0.833 | — | 12 / 0 | No |
| Haiku 4.5 | shorten | 0.625 → 0.625 | 1.0 | 13 / 13 | No |
| Nova 2 Lite | quality | 0.708 → 0.708 | — | 1 / 1 | No |
| Nova 2 Lite | shorten | 0.708 → 0.708 | 1.0 | 0 / 0 | No |
H1 is refuted: no model returned a ratio below 1.0. But of the six rows, only the two Nova rows are a clean result.
On Nova 2 Lite the optimizer worked, the model answered almost every inference, and the service found neither a better prompt nor a shorter one that scored as high. For a prompt that was already compact, evaluated with a strict criterion, that’s a reasonable answer: there was nothing to cut without losing quality. When it returns the original, the service copies the original’s measurement into the “optimized” metrics, which is why both columns match down to the last decimal.
Haiku 4.5 and Haiku 5.5 aren’t clean cases, for two different reasons the job result doesn’t mention.
Finding 2: The +45% That Never Existed
Back to the third row. For Haiku 4.5, optimizing for quality only, the job summary reports that the score rose from 0.575 to 0.833, a 45% gain, and that average time to first token dropped from 1.12 s to 0.60 s. The “optimized” prompt is identical to the original.
I went through the results file sample by sample. On the original side, 12 of the 60 inferences came back empty: a blank response, inputTokens: 0, outputTokens: 0, zero latency. The evaluator received an empty string, which isn’t valid JSON, and scored it 0. On the “optimized” side none failed. The entire improvement comes from those 12 failed calls.
Bedrock’s CloudWatch metrics show what happened: during the job window, Haiku 4.5 logged 607 server errors (InvocationServerErrors). Some may be mine: my holdout baseline ran 230 calls against the same model in parallel, and my client retried 5xx errors. But the job’s 25 empty inferences belong to the job. The quota wasn’t the problem: Haiku 4.5 has 10,000 requests per minute in that account.
There’s another detail in that same row. Even excluding the 12 failures, the original scores 0.719 versus 0.833 for the same text in the same job. It’s the same noise floor as the baseline, now inside the job: with 60 samples and a model that agrees with itself 88% of the time, two measurements of the same prompt differ by more than 10 points.
🚨 ProTip #2: Don’t trust the summary’s
averageScore. Before accepting an optimized prompt, do two things the service doesn’t do for you: compare the prompt text against the original (in my six cases it was identical), and count how many samples indataset[]haveoutputTokens: 0. A failed inference enters the average as one more 0.0, and in my case it produced a 45% improvement on a prompt that didn’t change. The repo’s05_fetch_results.pyscript runs both checks.
Finding 3: SUCCESS Without an Optimizer
The Haiku 5.5 job finished as Completed, with both entries at SUCCESS, no errors in the results file, and a +5% improvement on the quality template (0.808 → 0.850) for, once again, a prompt identical to the original. That +5% is the size of how much the same prompt varies against itself: in my baseline, Haiku 5.5 changed the classification of 12 of 145 news items between two runs. On its own it says nothing. The problem was in the optimizer’s metrics.
Haiku 5.5 ran 1,925 inferences during the job window. The pricing formula predicts 16 × 60 × 2 = 1,920: the target model did exactly the expected work. But the optimizer, Claude Sonnet 4.6, logged 689 invocations and 684 client errors (InvocationClientErrors), with only 7,756 input tokens in total. In the other account, the same optimizer consumed 2.49 million tokens.
I found the cause by invoking Sonnet 4.6 by hand in that account: “Model use case details have not been submitted for this account”. It’s the same Anthropic form that kept me from using Haiku 4.5 there. The optimizer runs with my credentials, not a service role, and my account couldn’t invoke it. The job didn’t catch it at creation, and didn’t report it in failureMessage or in the result entries. It evaluated the original prompt, couldn’t generate candidates, and handed it back to me with SUCCESS.
This kind of failure is hard to spot because the result looks normal. If I hadn’t checked CloudWatch to calculate costs, I would have written that Haiku 5.5 found nothing to cut.
🔍 ProTip #3: Advanced Prompt Optimization doesn’t use a service role: it invokes the target models, the optimizer, and your Lambda with the credentials of whoever creates the job (Forward Access Session). Before launching a job, verify that your account can invoke Claude Sonnet 4.6 with a test call. At job creation the service validates that you can invoke the target models (“No inference API is accessible for model”), but it doesn’t validate the optimizer. And after each job, check
InvocationClientErrorsforus.anthropic.claude-sonnet-4-6in Bedrock’s CloudWatch metrics.
Finding 4: Would It Have Been Worth It?
No prompt changed, so there are no measured savings. Even so, the original question can be answered with the jobs’ real costs, assuming shortening had achieved the announcement’s example: compressionRatio = 0.7, 30% fewer tokens in the template.
According to CloudWatch, the jobs consumed:
| Model | Role in the job | Invocations | Tokens in / out | Cost |
|---|---|---|---|---|
| Claude Sonnet 4.6 | Optimizer (4 pairs) | 384 | 2,488,824 / 262,585 | $12.55 |
| Claude Haiku 4.5 | Target | 3,396 | 3,152,146 / 766,911 | $7.69 |
| Amazon Nova 2 Lite | Target | 2,811 | 2,673,178 / 553,897 | $2.41 |
| Claude Haiku 5.5 | Target | 1,925 | 3,107,401 / 1,021,435 | $0.90 |
| Claude Sonnet 4.6 | Failed optimizer (2 pairs) | 689 | 7,756 / 2,733 | $0.07 |
Total: $23.61, plus about $1.40 for the holdout validation. The Haiku 4.5 and Nova figures include a few minutes of the job I stopped, so a clean job comes out somewhat cheaper. The optimizer is the most expensive part: about $3.14 per template-model pair.
With that data I calculated the cost of optimizing one template for one model and what it would save per month at my real volume (205 news items in 23 days, about 267 calls a month), with the 30% cut applied to the template’s 600 tokens:
| Model | Job cost (1 template) | Savings per month | Pays for itself in | Calls per month to pay for it in one month |
|---|---|---|---|---|
| Claude Haiku 5.5 | $3.48 | $0.0053 | 55 years | 175,955 |
| Claude Haiku 4.5 | $5.83 | $0.0529 | 9 years | 29,453 |
| Amazon Nova 2 Lite | $3.93 | $0.0159 | 21 years | 66,168 |
H3 is confirmed by a wide margin. The table also shows that shortening pays off more on the more expensive model: Haiku 4.5 costs 10 times more per input token than Haiku 5.5 on Bedrock. On the production model, which is the cheapest, shortening matters less. My table slightly underestimates the Haiku 5.5 savings, because it calculates on the 600 tokens the service counts and not on the ones its tokenizer bills; even correcting for that, the order of magnitude doesn’t change.
This doesn’t mean shortening is useless; it means the math depends more on volume than on the cut percentage. At about 30,000 calls a month on Haiku 4.5, or about 176,000 on Haiku 5.5, the job pays for itself in a month. At 267, it doesn’t.
As for latency, the other benefit the announcement mentions, I have nothing to measure: without a shorter prompt there’s no TTFT difference. The improvement the job summary shows (1.12 s → 0.60 s on Haiku 4.5) is two measurements of the same text, taken while the model was returning server errors; I don’t attribute it to the prompt.
What the Documentation Doesn’t Tell You
Beyond the findings above, these are the gotchas that cost me a job or a good while.
🧪 ProTip #4: In
modelConfigurations, theadditionalModelRequestFieldsfield only acceptstopK. I tried passingthinking: disabledandoutput_config.effort: lowfor Haiku 5.5, the way I run it in production, and the job was rejected at creation: “contains unsupported keys: [output_config, thinking]. Supported keys: [topK]”. The optimizer tunes the prompt for Haiku 5.5 with its default configuration, which uses thinking: on a sample of 12 news items that meant 57% more output tokens and 0.75 s more latency than the production configuration, with the same score. In practice, you’re optimizing for a different configuration than the one you’ll run.
🛑 ProTip #5: The service reviews your Lambda evaluator’s code before using it, and rejects it if it finds anything it considers dangerous. My first job failed with “Metric code validation failed: Uses potentially dangerous builtin: compile()” because of a
re.compile(): the analysis doesn’t distinguish theremethod from thecompilebuiltin. Usere.match(pattern, text)directly. The job doesn’t fail at creation either: it fails about three minutes later, with a genericfailureMessagethat points you to the results file in S3, where the real per-entry reason is.
⏱️ ProTip #6: A job’s terminal states are
Completed,Failed,Stopped, andPartiallyCompleted. The official sample’s wait loop only considers the first three, so with a partial result it waits forever.
I also found some differences between the user guide and the real API:
- The delete operation is
BatchDeleteAdvancedPromptOptimizationJob, singular (the guide uses the plural), and it returnsadvancedPromptOptimizationJobs[]anderrors[]. - The
ListAdvancedPromptOptimizationJobsresponse uses thejobSummarieskey, not the one shown in the guide’s example. - The encryption parameter is called
encryptionKeyArn, notencryptionConfig. - The evaluation page asks for a resource-based policy so
bedrock.amazonaws.comcan invoke your Lambda; the prerequisites page says the service invokes it with your credentials. I configured both.
Hypothesis Verdicts
| Hypothesis | Result |
|---|---|
| H1 — Shortening finds something to cut | Refuted. compressionRatio = 1.0 on all three models. The only clean result, Nova 2 Lite, returned the original. |
| H2 — The shortened prompt behaves the same on the holdout | Couldn’t be tested. There was no shortened prompt. |
| H3 — At my volume, the savings don’t pay for the job | Confirmed. Not even with a hypothetical 30% cut: between 9 and 55 years. |
| H4 — Optimized prompts aren’t portable | Couldn’t be tested. The six “optimized” prompts are the original. |
Two of the four hypotheses went untested. The portability matrix I had ready made no sense with six identical prompts, so I didn’t run it.
Limits of the Experiment
- One template, one domain. My prompt was already compact and the task has an exact answer. With a long, redundant prompt, shortening would probably cut something. I didn’t run that positive control, so I can’t separate “the service doesn’t cut” from “my prompt had nothing to cut.” The Nova case suggests the latter.
- The reference is production, not the truth. I’m measuring regression, not accuracy.
- 60 samples and a single job per model. I don’t know how much the optimizer varies between runs of the same job.
- Haiku 5.5 was optimized with a different configuration than production, and its job had no working optimizer. That result doesn’t count.
- Haiku 4.5 had server errors during the job, and my own baseline was running in parallel against the same model.
- Production doesn’t run on Bedrock but on the Anthropic API, so even if the prompt had changed, taking it to production would have been another experiment.
- The human decision doesn’t work as a second reference: of the dataset’s news items with a post, 133 were approved and only 3 rejected.
Conclusion
Back to the opening question: how much does shortening a prompt that already works save me?
In my case, nothing, for two reasons. My prompt was already compact, and the experiment’s only clean result returned the original. And even if it had been cut by 30%, at 267 calls a month the savings would be cents per year against a job costing several dollars. Shortening prompts is a volume optimization, and it’s worth doing the math before launching the job: tokens saved per call, times calls per month, times price per token, against roughly $3 to $6 per template and model.
What helped me most from the exercise was seeing how the service reports. In one day I got a +45% improvement that came from failed inferences counted as zero, and a SUCCESS from a job whose optimizer never managed to run. Neither case shows up in the job result. I found them by comparing the text of the returned prompt and checking CloudWatch’s error metrics.
Something similar happened to me with the Optimization Loop A/B test: the number an optimizer reports has to be verified independently before you make a decision with it.
🚀 Final ProTip: Before optimizing a prompt for cost, calculate the break-even point with your real volume and the price of the model where it runs. If it doesn’t pay for itself within a year, there’s no point running it for cost; run it only if you have a quality problem to solve. And if you run it, check three things before accepting the result: whether the text changed, how many inferences came back empty, and whether the optimizer logged errors in CloudWatch.
Have you measured how many calls a month your production prompts make? Is your volume at the scale where this math actually matters? If anyone is seeing real savings with shortening, I’d really like to know at what volume — the comments are open.
See you in the next article! 🚀
Official Resources 📚
- Announcement: Advanced Prompt Optimization now supports prompt shortening (October 20, 2026)
- Shorten prompts
- How Advanced Prompt Optimization works
- Prepare your input dataset
- Define evaluation methods (includes the Lambda evaluator contract)
- Selective optimization:
<advpo:optimize>and<advpo:exclude> - Create and manage optimization jobs
- View and interpret results
- Prerequisites (permissions and Forward Access Session)
- Quotas
- API Reference: CreateAdvancedPromptOptimizationJob
- Amazon Bedrock pricing (Advanced Prompt Optimizer formula)
- Official sample: aws-samples/amazon-bedrock-samples, advanced-prompt-optimization
Frequently asked questions
What does the shortenPrompt option in Bedrock Advanced Prompt Optimization do?
It asks the optimizer for a prompt that is shorter than the original and scores at least as high on your evaluation. You enable it per template in the input JSONL file with optimizationConfig.shortenPrompt: true, not in the API call. If the optimizer can’t find a prompt that meets both conditions, it returns the original with compressionRatio 1.0. The ratio is optimizedTokenCount / originalTokenCount, measured on the template. It was announced on October 20, 2026.
How much does an Advanced Prompt Optimization job cost?
There is no separate service charge: you pay for the tokens of the target model, the optimizer (Claude Sonnet 4.6), and the invocations of your Lambda evaluator. In my experiment, with 60 samples per template, the target model ran about 16 inferences per sample, as the formula on the pricing page says, and the optimizer consumed about 2.5 million input tokens for four template-model pairs. The jobs cost about 23.6 dollars in total, measured in CloudWatch.
Why can an Advanced Prompt Optimization job report an improvement without changing the prompt?
Because the summary compares two separate measurements, and failed inferences from the target model are scored as 0.0. In my Claude Haiku 4.5 job, 12 of the 60 inferences for the original prompt came back empty, with zero tokens, and averageScore went from 0.575 to 0.833 for an optimized prompt identical to the original. Check how many samples in dataset[] have outputTokens equal to 0, and compare the prompt text, before trusting the summary.
What permissions does Advanced Prompt Optimization need?
It doesn’t use a service role. The job invokes the target models, the optimizer, and your Lambda with the credentials of whoever creates it (Forward Access Session). Your account must be able to invoke Claude Sonnet 4.6, which is the optimizer, including having submitted the Anthropic use case form. In an account where that was missing, 684 of 689 optimizer calls failed and the job still finished as Completed with SUCCESS.
Start the conversation