Skip to content

Bedrock Converse as the fifth dialect - #131

Merged
fylorn merged 1 commit into
mainfrom
feat/bedrock-dialect
Sep 23, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/bedrock-dialect

Conversation

@fylorn

@fylorn fylorn commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Groundwork for retiring the enterprise gateway's own provider adapters. Its BedrockNative routes go through one of those adapters, so Bedrock needs a dialect before that path can be removed — otherwise "remove the old path" turns into "keep the old path for Bedrock".

Where the shapes came from

The adapter being replaced only ever spoke {"text": "..."}: no toolUse, no toolResult, no images, no toolConfig, and an inferenceConfig with two fields. It could not serve as a reference for what Converse accepts, so these come from the service model.

What Converse can and cannot say

Decided per field rather than assumed:

reasoningContent carries a signature, so thinking survives a round trip. A signature from another vendor is reported rather than sent — it will not verify, and the whole request gets refused
toolResult.content takes an image, so tool results keep theirs
image bytes or S3, never a URL; format is a short name, not a MIME type. An unrecognised one is reported rather than guessed — a guessed format arrives at the model as an image it cannot open
inferenceConfig exactly four knobs. top_k goes to additionalModelRequestFields, the pocket Converse passes through uninterpreted. seed, penalties and parallel tool calls have nowhere to go and are reported
toolChoice auto / any / tool, with no way to say "use none". The choice is reported and the tools are still sent: a model that sees a tool it should not call beats a model that cannot see its tools at all
stopReason three of its nine values are failure states no other format has (malformed_model_output, malformed_tool_use, guardrail_intervened). They stay Other with the original text — calling a malformed tool call end_turn tells the client the answer was complete

Framing stays out of this crate

Converse streams AWS eventstream binary frames, not SSE. Decoding them here would mean a CRC implementation and a dependency; instead the transport hands each event over as a Frame — :event-type into event, payload into data — and this side only decides what a frame contains. tw-dialect still depends on serde alone.

One asymmetry worth knowing about: Converse sends no contentBlockStart for text or reasoning blocks, only for tool blocks. The parser supplies the block start the IR requires.

Tests

The matrix test goes from 4×4 to 5×5 — tools, usage and stop reasons are asserted to survive all twenty-five client→upstream directions. Plus 22 Bedrock-specific tests covering the decisions above.

cargo fmt --check, clippy --workspace --all-targets -- -D warnings, 85 test binaries green.

🤖 Generated with Claude Code

The enterprise gateway routes `BedrockNative` through its own adapter,
and that adapter is one of the ones being retired. Leaving Bedrock on
the old path would mean keeping the old path, so it gets a dialect like
everyone else.

The shapes come from the service model, not from the adapter being
replaced — that one only ever spoke `{text}`, with no toolUse, no
toolResult, no images and no toolConfig, so it could not serve as a
reference for what Converse actually accepts.

What Converse can and cannot say, decided per field rather than assumed:

  reasoningContent carries a signature, so thinking survives a round
  trip; a signature from another vendor is reported instead of sent,
  because it will not verify and the whole request is refused.

  toolResult content takes an image, so tool results keep theirs.

  Images take bytes or S3, never a URL, and the format is a short name
  rather than a MIME type — an unrecognised one is reported rather than
  guessed, since a guessed format reaches the model as an image it
  cannot open.

  inferenceConfig has exactly four knobs. top_k goes in
  additionalModelRequestFields, the pocket Converse passes through
  without interpreting. seed, penalties and parallel tool calls have
  nowhere to go and are reported.

  toolChoice has auto / any / tool, and no way to say "use none". The
  choice is reported and the tools are still sent: a model that sees a
  tool it was not meant to call beats a model that cannot see its tools
  at all.

  Three of the nine stopReason values are failure states no other format
  has. They stay as Other with the original text — calling a malformed
  tool call `end_turn` tells the client the answer was complete.

The stream is AWS eventstream binary frames, not SSE, and framing stays
out of this crate: the transport hands each event over as a Frame with
`:event-type` in `event` and the payload in `data`, and this side only
decides what a frame contains. The crate still depends on serde alone.
One asymmetry worth knowing: Converse sends no contentBlockStart for
text or reasoning blocks, so the parser supplies the block start the IR
requires.

The matrix test now runs five dialects against five, so tools, usage and
stop reasons are asserted to survive all twenty-five directions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 4397263 into main Sep 23, 2026
2 checks passed
@fylorn
fylorn deleted the feat/bedrock-dialect branch September 23, 2026 09:18
@fylorn fylorn mentioned this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant