Repository navigation
converseStream fails when an LLM tool call has empty input (AWS SDK instrumentation) #18704
Description
Describe the bug
When using the OpenTelemetry Java agent together with the AWS SDK v2 Bedrock Runtime, every BedrockRuntimeAsyncClient.converseStream(...) call that produces a tool use with empty input fails: the streaming subscription is cancelled and the returned CompletableFuture completes exceptionally.
This happens consistently whenever the LLM decides to invoke a tool that has no required parameters (or whose only parameters are optional and the model chooses not to pass them). Tool calls that include at least one argument work fine, and the rest of the conversation works fine until such a parameterless tool call is produced.
Workarounds that point at the AWS SDK instrumentation as the cause:
- Removing the
-javaagent:opentelemetry-javaagent.jarflag entirely → issue gone. - Setting
OTEL_INSTRUMENTATION_AWS_SDK_ENABLED=false→ issue gone. - Adding a
required = trueparameter to the affected tool so the model always emits a non-empty input → issue gone.
We need the AWS SDK instrumentation enabled, so the last two options are not viable workarounds for us in production.
Steps to reproduce
- Spring Boot application running on Eclipse Temurin 17 with the OpenTelemetry Java agent attached via
JAVA_TOOL_OPTIONS="-javaagent:/otel/opentelemetry-javaagent.jar". - Use Spring AI's
BedrockProxyChatModel(which under the hood callsBedrockRuntimeAsyncClient.converseStream) against a Bedrock model that supports tool use (reproduced with Anthropic Claude 3.5 Sonnet and Amazon Nova Pro). - Register at least one tool with no required parameters, for example:
@Tool(description = "Get the current date and time in ISO-8601 format") public String currentDateTimeIso() { return OffsetDateTime.now().toString(); }
- Send a prompt that makes the model want to call that tool (e.g. "What time is it now?").
- The streaming call fails. With the javaagent disabled, or with OTEL_INSTRUMENTATION_AWS_SDK_ENABLED=false, the very same prompt completes successfully and the tool result is returned.
Reproduces on every javaagent version we tested, from v2.15.0 up to and including v2.27.0.
Expected behavior
A converseStream call where the model emits a tool use content block with empty or missing input should complete normally, exactly as it does when the javaagent is not attached.
Actual behavior
The converseStream call fails: the Reactive Streams subscription is cancelled and the returned CompletableFuture completes exceptionally. The caller sees the whole assistant turn fail; subsequent retries with the same prompt fail in the same way.
Javaagent or library instrumentation version
v2.27.0 (also reproduced on every release we tested down to v2.15.0)
Environment
JDK: Eclipse Temurin 17 (eclipse-temurin:17-jre-jammy)
OS: Ubuntu 22.04 (container)
- Spring Boot 3.x
- Spring AI 2.0.0-M4 (
spring-ai-bedrock-converse,BedrockProxyChatModel) - AWS SDK for Java v2, BOM 2.41.22, using
BedrockRuntimeAsyncClientwith the Netty NIO async HTTP client - OpenTelemetry Java agent attached via
JAVA_TOOL_OPTIONS="-javaagent:/otel/opentelemetry-javaagent.jar", otherwise default configuration - Models used on Bedrock: Anthropic Claude 3.5 Sonnet and Amazon Nova Pro
Additional context
- Possibly related: BedrockRuntimeAsyncClient streaming wrappers close Scope too early (can break/cancel stream) #16197 (similar symptom —
converseStreamsubscription gets cancelled when the AWS SDK instrumentation is active). - Disclosure: this issue was drafted with the assistance of an AI coding assistant; the behavior and the workarounds above were verified by the reporter.
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Activity
laurit commentedon May 12, 2026
A minimal sample that reproduces the issue could help. If you are interested in getting this fixed in the next release (due this week) then your best bet would be to help out with the debugging and tell us why it fails (are there any exceptions?). It might be that debugging the standalone library instrumentation is easier than debugging the the agent, see https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/aws-sdk/aws-sdk-2.2/library and
opentelemetry-java-instrumentation/instrumentation/aws-sdk/aws-sdk-2.2/library/src/testBedrockRuntime/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Aws2BedrockRuntimeTest.java
Line 104 in b950aef
stefanopace commentedon May 18, 2026
This pull request contains a test to reproduce this problem: #18783
It also contains what i think could be a fix
laurit commentedon Jun 17, 2026
Resolved with #18783