Repository navigation
feat(upstream)!: read Bedrock's stream, and drop the provider layer - #144
Merged
Merged
Conversation
fylorn
force-pushed
the
chore/drop-tw-provider
branch
from
September 23, 2026 15:40
ac1f940 to
02b5097
Compare
The server edition now forwards bytes and converts through tw-dialect, so tw-provider has no users left, and tw-protocol was only there for it. Both go. Going through what tw-provider did for Bedrock turned up two things nothing else does yet: - ConverseStream is AWS eventstream, not SSE. tw-dialect reads Bedrock frames as `event: <:event-type>` / `data: <payload>` and leaves the unframing to the transport. `tw_upstream::eventstream::Transcoder` is that transport step: binary frames in, SSE out, CRC checked by aws-smithy-eventstream, a frame cut on any byte held until it is whole, an in-stream exception surfaced as an error. - The usage sniffer did not know Converse's camelCase names, so every Bedrock call was billed on an estimate. It reads inputTokens, outputTokens, cacheReadInputTokens and cacheWriteInputTokens now, with inputTokens excluding cache as tw-dialect already assumes. The `sigv4` feature becomes `bedrock`, covering both signing and unframing. Nothing in this workspace turns it on, so CI never compiled it; a step now runs clippy and the tests with it on. A test takes a Converse stream as bytes on the wire, seven at a time, through the transcoder, the Chat converter and the sniffer, and checks the text, the finish reason and the usage that come out. BREAKING: tw-provider and tw-protocol are gone; tw-upstream's `sigv4` feature is now `bedrock`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn
force-pushed
the
chore/drop-tw-provider
branch
from
September 23, 2026 16:19
02b5097 to
ccca498
Compare
This was referenced Sep 23, 2026
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.
The server edition now forwards bytes and converts through tw-dialect (ThinkWatch
refactor/dialect-passthrough), so tw-provider has no users left, and tw-protocol was only there for it. Both are deleted.Going through what tw-provider did for Bedrock turned up two things nothing else does yet:
event: <:event-type>/data: <payload>and leaves the unframing to the transport.tw_upstream::eventstream::Transcoderis that step: binary frames in, SSE out. aws-smithy-eventstream checks the CRC, a frame cut on any byte is held until it is whole, and an in-stream exception (e.g.throttlingException) comes out as an error, not an event.inputTokens/outputTokens/cacheReadInputTokens/cacheWriteInputTokens, withinputTokensexcluding cache, astw_dialect::bedrock::usagealready assumes.The
sigv4feature is renamed tobedrockand covers both signing and unframing. Nothing in this workspace turns it on, so CI never compiled the SigV4 module. A new CI step runs clippy and the tests with it on.Tests
tests/bedrock_stream.rs: a Converse stream as wire bytes, seven at a time, goes through the transcoder, the Chat converter and the sniffer. It checks the text (天气晴),finish_reason: stopand usage (60 / 40 cached / 20).metadataevent.Breaking
tw-providerandtw-protocolare removed.sigv4feature is nowbedrock.🤖 Generated with Claude Code