Refining Prompts Iteratively with Evaluation and Feedback
This lesson describes a disciplined refinement process that improves prompts through measured changes driven by evaluation results and user feedback.
Learning outcomes
After completing this lesson, you will be able to:
- Measure before changing a prompt.
- Analyze failures by cause and change one thing at a time.
- Feed production signals back into evaluation.
Measure before changing
Prompt refinement without measurement is guesswork. A change that fixes the example a developer is looking at may silently break ten others. Refinement therefore starts with a baseline: the current prompt's scores on an evaluation set that covers typical inputs, difficult inputs and adversarial inputs such as prompt injection attempts.
Scores combine several kinds of check. Deterministic checks confirm format and required fields; comparisons with reference answers measure correctness; and an LLM judge rates qualities that are hard to check by rule, such as completeness and tone. Each proposed change is then scored on the same set, and it is accepted only if it improves the target behaviour without lowering other scores.
A refinement cycle
Analyse failures and change one thing
Failures are grouped by cause: ignored instructions, wrong format, missing information, wrong tone, hallucinated details or poor reasoning. Each cause suggests a change: clarify or reorder instructions, add an example, add an explicit rule for the edge case, add structure, add reasoning steps, or split the task. Changing one aspect at a time and re-running the full evaluation shows what actually helped. Amazon Bedrock's prompt optimisation feature can rewrite a prompt for a chosen model as a starting point, which is then evaluated like any other candidate.
The following diagram shows a disciplined prompt refinement loop that tests each change against a baseline.

Failure cause to prompt change
Feedback loops from production
No evaluation set anticipates every real input, so production provides evidence that testing lacks. User ratings, corrections, escalations to human agents and guardrail interventions identify interactions that failed. These are reviewed to diagnose the cause, such as a missing instruction, an ambiguous rule or a retrieval problem, and added to the evaluation set, so that the same failure cannot return unnoticed in a later version.
Prompt versions in Prompt Management, A/B tests that compare variants on real traffic, and monitoring of quality metrics complete the loop: observe, diagnose, change, evaluate, release and observe again. The following table maps common failure types to typical refinements.
| Failure | Typical refinement |
|---|---|
| Instruction ignored | Move it earlier, make it explicit, repeat near the end |
| Wrong or inconsistent format | Example output, schema, tool use, lower temperature |
| Hallucinated details | Require answers only from context; allow "not found"; grounding check |
| Faulty multi-step logic | Chain-of-thought or prompt chaining |
| Wrong tone or length | Explicit tone rules and word limits; examples |
A fix that broke other cases
A developer adds "Always include a discount offer" to a support prompt after a complaint. Satisfaction drops, and offers appear in replies to billing errors where they are inappropriate.
The change was made without evaluation. The disciplined approach adds the complaint case to the evaluation set, tests a narrower rule ("Offer a discount only when the customer reports a delayed delivery"), compares scores across all cases against the baseline, and releases the new prompt version only if no category regresses.
What should be done with failures found in production?
Show answer
Add them to the evaluation set, so later prompt changes are tested against them.
Exam Tips
Remember for the exam
- Establish a baseline score before changing a prompt.
- Group failures by cause and change one thing at a time.
- Add production failures to the evaluation set.
- Release prompt changes as new versions after evaluation.