Repository navigation
Bedrock Converse as the fifth dialect - #131
Merged
Merged
Conversation
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>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for retiring the enterprise gateway's own provider adapters. Its
BedrockNativeroutes 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": "..."}: notoolUse, notoolResult, no images, notoolConfig, and aninferenceConfigwith 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:
reasoningContenttoolResult.contentimageinferenceConfigtop_kgoes toadditionalModelRequestFields, the pocket Converse passes through uninterpreted.seed, penalties and parallel tool calls have nowhere to go and are reportedtoolChoiceauto/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 allstopReasonmalformed_model_output,malformed_tool_use,guardrail_intervened). They stayOtherwith the original text — calling a malformed tool callend_turntells the client the answer was completeFraming 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-typeintoevent, payload intodata— and this side only decides what a frame contains. tw-dialect still depends on serde alone.One asymmetry worth knowing about: Converse sends no
contentBlockStartfor 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