Skip to content

port @effect/ai-amazon-bedrock from v3#2032

Open
loklaan wants to merge 5 commits intoEffect-TS:mainfrom
loklaan:lochlan-ai-amazon-bedrock-package-port-from-v3
Open

port @effect/ai-amazon-bedrock from v3#2032
loklaan wants to merge 5 commits intoEffect-TS:mainfrom
loklaan:lochlan-ai-amazon-bedrock-package-port-from-v3

Conversation

@loklaan
Copy link
Copy Markdown

@loklaan loklaan commented Apr 13, 2026

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Straight port of @effect/ai-amazon-bedrock (v0.15.0) from Effect-TS/effect, adapted to the v4 AI and HTTP APIs.

Changes from the v3 source:

Related


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:

Date Feature
2025-06-30 Citations (CitationsContentBlock, CitationsDelta)
2025-10-29 System tools (SystemTool in Tool union)
2025-11-18 Service tier (request/response/stream)
2025-11-19 Search results in tool results (SearchResultBlock)
2025-12-02 Audio blocks, image streaming, new stop reasons
2026-01-20 Extended prompt caching (TTL on CachePointBlock)
2026-02-04 Structured output (OutputConfig with json_schema)

Some strict enums and required-vs-optional mismatches could cause runtime decode failures as AWS adds new values.

Bedrock APIs at a glance

  • Converse — best fit for LanguageModel today, model-agnostic, broadest coverage
  • Responses — newer, built for agentic workflows with stateful conversations and server-side tool execution
  • Chat Completions — literal OpenAI spec, likely already usable via @effect/ai-openai-compat

Widen 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 is inlined in the language model file — Anthropic and OpenAI have dedicated *Telemetry.ts modules
  • AmazonBedrockLanguageModel.ts handles raw JSON payloads but is missing the @effect-diagnostics preferSchemaOverJson:skip-file directive that Anthropic uses

Schema maintenance strategy

The Anthropic and OpenAI packages use codegen.yml to auto-generate Generated.ts from 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-written AmazonBedrockSchema.ts will drift as AWS extends the Converse API (see feature table above).

Expand test coverage

Unit and smoke tests cover the happy paths. Untested areas:

  • JSON response format and reasoning/extended thinking content
  • prepareMessages pipeline (images, documents, cache points, role grouping)
  • HTTP error mapping and EventStreamEncoding edge cases
  • Provider-defined tool betas and toolChoice variants
  • ...probably more — coverage surface is pretty wide for a package like this

Clean up as any casts

Most 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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: 59cc4e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@effect/ai-amazon-bedrock Major
effect Major
@effect/opentelemetry Major
@effect/platform-browser Major
@effect/platform-bun Major
@effect/platform-node-shared Major
@effect/platform-node Major
@effect/vitest Major
@effect/ai-anthropic Major
@effect/ai-openai-compat Major
@effect/ai-openai Major
@effect/ai-openrouter Major
@effect/atom-react Major
@effect/atom-solid Major
@effect/atom-vue Major
@effect/sql-clickhouse Major
@effect/sql-d1 Major
@effect/sql-libsql Major
@effect/sql-mssql Major
@effect/sql-mysql2 Major
@effect/sql-pg Major
@effect/sql-sqlite-bun Major
@effect/sql-sqlite-do Major
@effect/sql-sqlite-node Major
@effect/sql-sqlite-react-native Major
@effect/sql-sqlite-wasm Major
@effect/openapi-generator Major

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

@jamesone
Copy link
Copy Markdown

@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)

loklaan and others added 2 commits April 13, 2026 18:55
Co-authored-by: James Wainwright <jameswain10@gmail.com>
@loklaan loklaan force-pushed the lochlan-ai-amazon-bedrock-package-port-from-v3 branch from 28d4e03 to 0e2378d Compare April 13, 2026 08:56
@loklaan loklaan force-pushed the lochlan-ai-amazon-bedrock-package-port-from-v3 branch from a81d248 to 0469c93 Compare April 13, 2026 10:31
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.

2 participants