OCTOBER 30, 2026

Zero-shot prompting, context augmentation, and streaming with Amazon Bedrock

Amazon Bedrock | Nova Lite | Prompt engineering | Python

01

ONE MODEL, THREE LESSONS

Keep the experiment small enough to see what changes

This notebook uses Amazon Nova Lite through the Bedrock Runtime API. The model and question stay essentially the same while the request evolves in three deliberate steps: a zero-shot prompt, a prompt augmented with reference context, and a streamed invocation.

The example asks for the Krabby Patty recipe from SpongeBob SquarePants. That playful test makes an important failure mode obvious: a model can produce a polished answer even when the prompt gives it no authoritative facts.

Prompt quality is not only about wording. It is also about what evidence the model receives and how the application delivers the result.
02

ZERO-SHOT PROMPTING

First, ask the model without examples or supporting context

A zero-shot prompt gives the model a task but no worked example and no external reference material. The notebook assigns the role of cooking assistant and asks for a Krabby Patty recipe in one request.

Py Pythonzero-shot prompt
prompt = """
You are a cooking assistant.
Explain how to cook the famous Krabby Patty.
"""

body = {
    "messages": [{
        "role": "user",
        "content": [{"text": prompt}]
    }],
    "inferenceConfig": {
        "maxTokens": 2048,
        "temperature": 0,
        "topP": 0.9
    }
}
↗ Nova Liteactual notebook output · excerpt
Sure, let's dive into making a delicious "Crabby Patty"
inspired by SpongeBob SquarePants!

For the patty:
- 1 lb ground beef
- 1 cup breadcrumbs
- 1/2 cup finely chopped onion
- 1/2 cup finely chopped bell pepper
- 1 egg
- Worcestershire sauce and Dijon mustard
- Old Bay seasoning

Form four patties and cook them in a skillet or grill pan
for 4–5 minutes on each side. Toast conventional hamburger
buns, then add lettuce, tomato, pickles, ketchup, mustard,
and mayonnaise.

The response is fluent and complete, but it invents a conventional burger recipe instead of following the established Krabby Patty details. That is the useful lesson: zero-shot does not mean grounded. The model can follow the shape of the task while filling missing facts from patterns learned during training.

ZERO-SHOT RESULTUseful form, unreliable factsThe answer looks convincing, but the prompt never supplied the Krabby Patty reference facts the answer was expected to follow.
03

CONTEXT AUGMENTATION

Give the model the facts it should use—and define the boundary

The second request adds a compact reference block containing the permitted Krabby Patty ingredients and the single cooking instruction. It also tells the model to use only that material and specifies the desired output shape.

This is context augmentation in its simplest form. The application supplies relevant information at request time; the model is not retrained, and the reference text does not become part of its permanent knowledge.

ROLEYou are a cooking assistant.
+
CONTEXTUse only this reference material.
+
QUESTIONHow is the Krabby Patty prepared?
+
OUTPUT CONTRACTList the Krabby Patty ingredients and one instruction.
Py Pythonaugmented prompt
role = """
You are a cooking assistant. Explain how to cook the famous
Krabby Patty popularized by SpongeBob SquarePants.
"""

question = "How do you cook the famous Krabby Patty?"

context = """
Use these reference facts for the Krabby Patty.

Secret formula ingredients:
- Flour for the seaweed buns
- Barnacle shavings
- Salt and turmeric
- Seaweed paste
- Sea horseradish sauce
- Chum from the original recipe
- Chili peppers, liquid smoke, and breadcrumbs

Toppings:
- Seaweed buns
- Veggie patty
- Sea lettuce and sea cheese
- Sea onion and sea tomato
- Sea ketchup and sea mustard
- Sea pickles

Cooking instruction: Cook it with love.
"""

augmented_prompt = f"""
{role}

Use only the following reference for the ingredients:
<context>
{context}
</context>

Question: {question}
Answer: List only the Krabby Patty ingredients and the one cooking instruction.
"""
✓ Nova Liteactual context-augmented output
### Ingredients for the Krabby Patty

The Secret Formula:
- Flour for the seaweed buns
- Barnacle shavings
- Salt and turmeric
- Seaweed paste
- Sea horseradish sauce
- Chum from the original recipe
- Chili peppers, liquid smoke, and breadcrumbs

Toppings:
- Seaweed buns
- Veggie patty
- Sea lettuce and sea cheese
- Sea onion and sea tomato
- Sea ketchup and sea mustard
- Sea pickles

### Cooking Instruction
- Cook it with love.

The result now stays inside the supplied reference and ends with the requested instruction. The improvement comes from three controls working together: relevant context, an explicit source boundary, and a precise output contract.

CONTEXT-AUGMENTED RESULTRelevant facts, constrained answerThe application decides what evidence enters the request; the model organizes that evidence into the requested response.
04

BEDROCK RUNTIME

Send the Nova message envelope through Boto3

Nova Lite expects a message-shaped request body. The notebook keeps formatting and response parsing in small helper functions so the experiment can focus on the prompt rather than the transport details.

Py Pythoninvoke_model
import json
import boto3

bedrock = boto3.client("bedrock-runtime")

response = bedrock.invoke_model(
    modelId="amazon.nova-lite-v1:0",
    body=json.dumps(format_for_nova_lite(augmented_prompt)),
    accept="application/json",
    contentType="application/json",
)

payload = json.loads(response["body"].read())
answer = parse_nova_lite_response(payload)

invoke_model waits for the complete response body. That is convenient for batch work and short answers, but an interactive interface can feel idle while the model is generating.

05

STREAMING OUTPUT

Render each text delta instead of waiting for the final document

The streaming request keeps the same model, prompt, and generation settings. Only the invocation method and response handling change. Bedrock emits events; Nova text arrives inside contentBlockDelta records.

Py Pythonresponse stream
response = bedrock.invoke_model_with_response_stream(
    modelId="amazon.nova-lite-v1:0",
    body=json.dumps(format_for_nova_lite(augmented_prompt)),
    accept="application/json",
    contentType="application/json",
)

parts = []
for event in response["body"]:
    chunk = event.get("chunk")
    if not chunk:
        continue

    message = json.loads(chunk["bytes"].decode())
    delta = message.get("contentBlockDelta", {}).get("delta", {})
    text = delta.get("text", "")
    parts.append(text)
    update_display(Markdown("".join(parts)), display_id=display_id)
STREAM EVENTS
### Krabby Patty IngredientsSeaweed bun…Veggie patty…Cook it with love.

Streaming improves perceived responsiveness because the reader sees useful text as soon as it is available. It does not make the model more accurate; grounding still comes from the augmented prompt and the quality of its context.

06

THE PATTERN

Separate the three decisions in your own application

  • Zero-shot prompting defines the task with no demonstrations. Use it to establish a baseline and expose what the model assumes.
  • Context augmentation supplies application-owned evidence at request time. Delimit the context and tell the model how it may use it.
  • Streaming output changes delivery, not reasoning. Accumulate deltas for the final answer while rendering them incrementally for the user.
Baseline the behavior. Add the evidence. Then improve the experience.
07

SOURCE MATERIAL

Continue with the code and AWS documentation