A dense revision pass on prompt engineering for Amazon Bedrock: what each technique buys you, when to reach for it, and where the tempting wrong answer lives.
Techniques at a glance
| Technique | What it does | Use when |
|---|---|---|
| Zero-shot | Instruction only, no examples | Task is common and well understood by the model |
| Few-shot | Instruction plus 2 to 5 examples | Output format or edge cases need pinning down |
| Chain-of-thought | Asks the model to reason step by step | Multi-step logic, maths, or layered decisions |
| ReAct | Interleaves reasoning with tool actions | Model must call tools and act on results |
| Tool / function calling | Model returns a typed, schema-bound call | You need reliable structured output |
| System prompt | Sets role, tone, and standing constraints | Behaviour must hold across every turn |
| Delimiters | Fences instructions off from input data | Untrusted or long user content is in the prompt |
| Prompt templates | Parameterised, reusable prompt bodies | The same prompt runs with varying inputs |
| Prompt versioning | Tracks prompt revisions over time | Changes need testing, rollback, and audit |
| Guardrails | Filters input and output by policy | Safety and compliance must be enforced |
Decision rules
- If the task is simple and common, then zero-shot; do not spend tokens on examples.
- If the format keeps drifting, then few-shot with 2 to 5 tight examples.
- If reasoning has multiple steps, then chain-of-thought; expect more tokens and latency.
- If the task is trivial, then skip chain-of-thought; it wastes tokens for no gain.
- If the model must use tools, then ReAct: reason, act, observe, repeat.
- If you need machine-readable output, then tool or function calling, not JSON asked for in prose.
- If you asked for JSON in prose and parsing fails, then move to function calling.
- If role, tone, or rules must persist, then put them in the system prompt.
- If user content sits beside instructions, then wrap it in delimiters.
- If the same prompt runs many times with inputs, then build a template.
- If a prompt change needs rollback or audit, then version it in Bedrock Prompt Management.
- If output must be deterministic, then temperature 0 and a low top-p.
- If output should be varied or creative, then raise temperature and top-p.
- If responses get truncated, then raise max tokens.
- If safety or compliance is required, then add Guardrails; a system prompt alone is not enough.
- If a prompt injection slips through delimiters, then rely on Guardrails and least privilege, not the fence.
Traps
- Treating a system prompt as a security boundary. It steers behaviour; it does not enforce it. Pair it with Guardrails.
- Treating delimiters as a full defence against prompt injection. They help the model separate data from instructions, but they are not a hard boundary.
- Asking for JSON in prose and assuming it always parses. It is unreliable; tool or function calling enforces the schema.
- Adding chain-of-thought to trivial tasks. It burns tokens and adds latency with no accuracy gain.
- Piling in more few-shot examples to fix a reasoning gap. Examples fix format, not multi-step logic; use chain-of-thought.
- Cranking temperature to fix wrong answers. Temperature changes variety, not correctness.
- Setting temperature and top-p both high and expecting stable output. Combined randomness widens the spread.
- Confusing top-k and top-p. Top-k caps the candidate count; top-p caps cumulative probability mass.
- Forgetting max tokens covers output, so truncation looks like a model fault.
- Hardcoding prompts in application code instead of managing and versioning them.
- Expecting ReAct without any tools defined. No tools means nothing to act on.
- Putting untrusted user text directly next to instructions with no delimiters.
Say it in one line
- Zero-shot gives instructions only; few-shot adds a handful of examples to shape output.
- Few-shot fixes format and edge cases, not multi-step reasoning.
- Chain-of-thought helps layered problems and wastes tokens on trivial ones.
- ReAct interleaves reasoning and tool calls: reason, act, observe, repeat.
- Tool or function calling enforces structured output against a schema.
- JSON requested in prose is unreliable and can fail to parse.
- System prompts set role, tone, and standing constraints across turns.
- A system prompt is a control, not a security boundary; pair it with Guardrails.
- Delimiters separate instructions from untrusted data and add a partial, not full, security boundary.
- Prompt templates make a prompt reusable across varying inputs.
- Bedrock Prompt Management versions prompts for testing, rollback, and audit.
- Temperature and top-p control randomness; top-k caps candidate tokens; max tokens caps output length.
- Low temperature and top-p for deterministic tasks; raise both for creative ones.
- Guardrails enforce safety and compliance that prompts alone cannot.