#2650·instructor

context= templating is a silent no-op on the Bedrock provider

Author: jorgeecardonaCreated Sep 15, 2026Updated Sep 15, 2026

context= templating is a silent no-op on the Bedrock provider

What happens

With instructor.from_bedrock(...), create(..., context={...}) sends the Jinja templates to the model unrendered: the request carries {{ name }} literally. No error, no warning.

Why

create() runs two steps in this order (instructor/v2/core/patch.py, same in 1.15.1's instructor/core/patch.py):

  1. the Bedrock request handler converts the messages to Converse shape: the system prompt moves to a top-level system=[{"text": ...}], every content part becomes {"text": ...} with no "type";
  2. handle_templating renders messages[*].content only when it is a string, or a list part with type == "text", and never looks at system.

After step 1 nothing matches step 2, so nothing is rendered. OpenAI and Anthropic are unaffected because their handlers leave the message shape alone.

Reproduce offline (no credentials)

python
from instructor import Mode
from instructor.v2.core.templating import handle_templating
from instructor.v2.providers.bedrock.handlers import _prepare_bedrock_converse_kwargs_internal

prepared = _prepare_bedrock_converse_kwargs_internal({
    "model": "anthropic.claude-3-5-sonnet",
    "messages": [
        {"role": "system", "content": "You classify {{ topic }} reports."},
        {"role": "user", "content": [{"type": "text", "text": "Report: {{ text }}"}]},
    ],
})
result = handle_templating(prepared, Mode.BEDROCK_JSON, context={"topic": "airport", "text": "Runway closed."})

print(result["system"])                    # [{'text': 'You classify {{ topic }} reports.'}]
print(result["messages"][0]["content"])    # [{'text': 'Report: {{ text }}'}]

Live: client.create(model=..., response_model=..., messages=[{"role": "user", "content": "Hello {{ name }}"}], context={"name": "Ada"}) on a Bedrock client: the model receives Hello {{ name }}.

Expected

Same as every other provider: [{'text': 'You classify airport reports.'}] and [{'text': 'Report: Runway closed.'}].

Impact

Anyone relying on context= with Bedrock gets prompts with the variables missing. With prompt templates whose only content is variables ({{ text }}), the model receives an empty task and answers accordingly; this is easy to miss because nothing fails.

Versions

instructor 1.15.1 (pip) and main at e12f8b49; Python 3.13; boto3/botocore current.

Fix

PR #2651: template Converse text blocks and the system list for the Bedrock provider, with tests including the order-of-operations regression above.