--- title: "1.42.1 — Streamed answers and tool use on Bedrock" description: "The guarded LLM helper can now stream a Bedrock answer as it is written (`llm.stream`), and can let a Bedrock model ask for tools the caller declares, in both plain and streamed calls. Every streamed and tool call goes through the same safety policy, budgets, circuit breaker and ledger as `llm.call`…" date: "2026-11-09" tags: ["release"] canonical: "https://django-mojo.sitesmojo.com/changelog/1-42-1/" --- The guarded LLM helper can now stream a Bedrock answer as it is written (`llm.stream`), and can let a Bedrock model ask for tools the caller declares, in both plain and streamed calls. Every streamed and tool call goes through the same safety policy, budgets, circuit breaker and ledger as `llm.call`. Existing callers see no change until a route opts in. ### Added - `llm.stream()` streams a Bedrock route's answer: `text_delta` events as it is written, then one `final` event. Its `response` is exactly what `llm.call()` returns, and it is sent only after usage has been settled. - A refused stream raises `LLMExecutionError` from `llm.stream()` itself, before anything is sent. A failure partway through raises from iteration. - `LLMStream.close()` cancels a stream. Called from an event loop, or while another thread is reading, it only shuts the connection, and the iterating thread records the cancel. - Bedrock routes may declare `"tools"` alongside `"text"`. Callers declare tools with `name`, `description` and `input_schema`, receive `tool_use` blocks, and answer with `tool_result` blocks. The helper never runs a tool itself. - `llm.call()` and `llm.stream()` accept `max_tool_rounds` (1–32). It defaults to 8 on Bedrock; Anthropic callers are unaffected unless they pass it. - A cancelled stream's ledger row finishes as `failed` with the code `cancelled`. ### Changed - A Bedrock request is now checked for a valid shape before any budget is reserved. A malformed request is refused with `provider_rejected` and leaves no ledger row. - Bedrock responses no longer include text blocks that are only whitespace in `content`. - A Bedrock conversation that contains `tool_use` or `tool_result` blocks without `tools=` is refused with `capability_unsupported`. ### Upgrade notes - Adding `"tools"` to a route changes the policy hash: deploy, then activate the deployed policy again. - Bedrock tool calls must pass `context["operation_id"]` and reuse it for every call in one loop. A loop of N tool rounds makes N+1 calls, so the feature's `max_loop_calls` must be at least N+1. - Streaming needs the IAM action `bedrock:InvokeModelWithResponseStream` on the same inference profile and model resources as `bedrock:InvokeModel`. - A stream's deadline is the route's `timeout_seconds`, and it includes time the caller spends between reads. - `llm.stream()` is Bedrock-only; on an Anthropic route it is refused with `capability_unsupported`.