Skip to content

Any attempt to use AWSSDK.Extensions.Bedrock.MEAI 4.0.3 results in type load failures #4014

@stephentoub

Description

@stephentoub

Describe the bug

Trying to use AWSSDK.Extensions.Bedrock.MEAI 4.0.3 fails with exceptions like:

Unhandled exception. System.TypeLoadException: Could not load type 'Amazon.BedrockRuntime.Model.CitationsDelta' from assembly 'AWSSDK.BedrockRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604'.
   at Amazon.BedrockRuntime.BedrockChatClient.GetStreamingResponseAsync(IEnumerable`1 messages, ChatOptions options, CancellationToken cancellationToken)+MoveNext()
   at Amazon.BedrockRuntime.BedrockChatClient.GetStreamingResponseAsync(IEnumerable`1 messages, ChatOptions options, CancellationToken cancellationToken)+MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Amazon.BedrockRuntime.BedrockChatClient.GetStreamingResponseAsync(IEnumerable`1 messages, ChatOptions options, CancellationToken cancellationToken)+System.IAsyncDisposable.DisposeAsync()

4.0.2 works fine.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Applications using the library should be able to run.

Current Behavior

Applications crash with a type load exception.

Reproduction Steps

  1. Add a reference to AWSSDK.Extensions.Bedrock.MEAI v4.0.3.
  2. Try to run code like this:
using Amazon.BedrockRuntime;
using Microsoft.Extensions.AI;

IChatClient chatClient = new AmazonBedrockRuntimeClient(
    Environment.GetEnvironmentVariable("AI:Bedrock:AccessKey"!),
    Environment.GetEnvironmentVariable("AI:Bedrock:SecretAccessKey")!,
    Amazon.RegionEndpoint.USEast1).AsIChatClient("anthropic.claude-3-sonnet-20240229-v1:0");

await foreach (var update in chatClient.GetStreamingResponseAsync("Hello"))
{
    Console.Write(update);
}

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.Extensions.Bedrock.MEAI 4.0.3

Targeted .NET Platform

.NET 9

Operating System and version

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions