Skip to main content

Module bedrock

Module bedrock 

Source
Expand description

Amazon Bedrock Converse API adapter. Pure translation, no I/O; the SigV4 signing that authenticates the dial is a separate axis ([crate::auth::aws], applied by the transport in super::endpoints).

Converse is Bedrock’s provider-neutral chat surface, so agentd speaks ONE dialect to every Bedrock model (Anthropic, Llama, Titan, …). It differs from both in-binary dialects in ways the loop never sees:

  • the model id rides the URL path (/model/{modelId}/converse), not the body — so there is no model field here (see converse_path);
  • content is a list of blocks keyed by shape ({"text":…}, {"toolUse":…}, {"toolResult":…}) — no type tag;
  • system is a block list, inference knobs live under inferenceConfig, and tools under toolConfig.tools[].toolSpec with the JSON Schema nested one level as inputSchema.json;
  • Bedrock validates strict user/assistant alternation, so consecutive same-role turns (notably the N tool results of one assistant turn) are merged into a single message with N content blocks.

Auth is SigV4 only (no bearer/api-key), so token is ignored here.

Constants§

DEFAULT_PATH
A placeholder default path. Bedrock’s real path is computed per-request from the model id (converse_path); this is only the host-only resolve-time fallback and is always overridden before a dial.

Functions§

build_request
Build the Converse request body (JSON bytes) + headers. token is ignored — Bedrock authenticates by SigV4 (added by the transport), never a bearer.
converse_path
The Converse request path for model: /model/{modelId}/converse. The model id is a single opaque path parameter, so it is fully percent-encoded (unreserved A-Za-z0-9-._~ pass; everything else — notably the : of a versioned id like …-v2:0, and the :// of an inference-profile ARN — becomes %XX). This exact string is BOTH sent on the wire and fed to the SigV4 signer, so the canonical URI the signature covers matches the request-target byte-for-byte (the signer does not re-encode).
parse_response
Parse a Converse response body into the neutral Response. Tolerant: missing usage → zero; an unknown stop reason → StopReason::Other.