AWS generative AI developer exam prep · Lesson 7 of 17
Prompt engineering and prompt management
A prompt that works in a demo has to keep working on thousands of real inputs. The habits that make it hold up: give the model a role and the goal in the system prompt; separate instructions from data (wrap the user's text or retrieved documents in clear tags or sections); say exactly what format to return, ideally with a JSON schema; show two or three examples of good output (few-shot); and tell it what to do when it doesn't know, such as "say you don't have that information".
For hard tasks, ask the model to work step by step before it answers (chain-of-thought), or to plan, then act. Break a big task into a chain of smaller prompts: extract, then classify, then write. Each step is easier to test and fix than one giant prompt.
Amazon Bedrock Prompt Management stores prompts as templates with variables (like {{customer_name}}), along with the model and inference settings they're meant for. You save versions, compare variants side by side, and have the app call a specific prompt version. Changing a prompt then doesn't need a code deploy, and rolling back means pointing at the previous version. Track who used and changed what with AWS CloudTrail and CloudWatch Logs.
Amazon Bedrock Flows (called Prompt Flows in the exam guide) links prompts, knowledge bases, Lambda functions and conditions into a workflow you build visually and call as one unit: for example, classify a message, branch on the result, retrieve from a knowledge base on one branch, and format the reply. It suits sequential chains and simple branching with little code.
Interactive apps need context and clarification. Keep the conversation in DynamoDB. Use Amazon Comprehend or a model to detect intent, and when the request is ambiguous, ask a clarifying question rather than guessing; Step Functions can run a multi-turn clarification workflow. Amazon Lex builds voice and chat bots with intents and slots when the conversation follows a set structure.
Test prompts like code. Keep a set of inputs with expected outputs, run them after every prompt change, and fail the change if quality drops (prompt regression testing). A Lambda function can check that output parses as valid JSON with the right fields; CloudWatch can track pass rates over time.
Practice
Product managers want to change the wording of a customer prompt weekly, test variants, and roll back if needed, without asking developers to redeploy. What fits best?
More info
Quick reference
System prompt
Role, goal and rules for the whole conversation.
Few-shot
A few examples of input and good output.
Chain-of-thought
Ask for the steps before the answer.
Prompt chaining
Several small prompts in sequence.
Prompt Management
Versioned templates with variables, called by id.
Bedrock Flows
Visual workflow of prompts, knowledge bases, Lambda and conditions.