port @effect/ai-amazon-bedrock from v3#2032
Open
loklaan wants to merge 5 commits intoEffect-TS:mainfrom
Open
Conversation
🦋 Changeset detectedLatest commit: 59cc4e4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@loklaan nice work! It looks like you need to generate the changes (check the guidelines). Also if you haven't already, I recommend ensuring lint is passing too (will lead to faster merge) |
Co-authored-by: James Wainwright <jameswain10@gmail.com>
28d4e03 to
0e2378d
Compare
a81d248 to
0469c93
Compare
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.
Type
Description
Straight port of
@effect/ai-amazon-bedrock(v0.15.0) fromEffect-TS/effect, adapted to the v4 AI and HTTP APIs.Changes from the v3 source:
tryEmitFinishdefers until bothmessageStopandmetadataarrive, preventing lost token usage in streaming responsesBedrockFoundationModelIdlist via AWSListFoundationModels(the v3 list was over a year stale)transformClientbearer token auth test covering the realistic scenario of using a bearer token in place of SigV4 signingRelated
Follow-up scope
The schema baseline is the March 31, 2025 point-in-time of the Converse API (
2023-09-30). Prompt caching (CachePointBlock) is the newest feature present. AWS extends this API in-place — no v2, just additive changes. Features added since:CitationsContentBlock,CitationsDelta)SystemToolin Tool union)SearchResultBlock)CachePointBlock)OutputConfigwithjson_schema)Some strict enums and required-vs-optional mismatches could cause runtime decode failures as AWS adds new values.
Bedrock APIs at a glance
LanguageModeltoday, model-agnostic, broadest coverage@effect/ai-openai-compatWiden auth support beyond static credentials
I hit this immediately — my org uses assumed roles, and I use bearer tokens for local tooling. Currently credentials are captured once at layer creation with no refresh or provider chain. Bearer token auth works today via
transformClient. I'm not super across deploying AWS stuff nowadays ironically, but as far as I know most folks are using rotating credentials and assumed roles.Align with Anthropic/OpenAI package structure
*Telemetry.tsmodulesAmazonBedrockLanguageModel.tshandles raw JSON payloads but is missing the@effect-diagnostics preferSchemaOverJson:skip-filedirective that Anthropic usesSchema maintenance strategy
The Anthropic and OpenAI packages use
codegen.ymlto auto-generateGenerated.tsfrom Stainless-hosted API specs — keeping type definitions in sync with upstream is essentially free. AWS doesn't have an equivalent lightweight spec source. The closest thing is@aws-sdk/client-bedrock-runtime, but it's a heavy dependency and the v3 package chose to hand-write schemas rather than pull it in. I don't have enough context on this trade-off to suggest a specific approach, but flagging it as a consideration — the hand-writtenAmazonBedrockSchema.tswill drift as AWS extends the Converse API (see feature table above).Expand test coverage
Unit and smoke tests cover the happy paths. Untested areas:
prepareMessagespipeline (images, documents, cache points, role grouping)EventStreamEncodingedge casestoolChoicevariantsClean up
as anycastsMost match identical casts in the Anthropic provider's Tool API, so not unique to this port. The remainder are
ProviderMetadata/trace type mismatches that could be addressed upstream.