[BUG] BedrockStreamingChatModel cuts off streams that run longer than 60 seconds by default (seen with GPT-6 Sol/Luna/Astra)
Thanks for the Bedrock module and for keeping it current as new Bedrock models arrive. I ran into this with the OpenAI GPT-6 models: GPT-6 Astra streams more slowly than Sol, so a long answer takes over a minute, and with reasoning.effort: max Sol, Luna and Astra can take over a minute before the first text token.
Describe the bug
With default settings, BedrockStreamingChatModel ends the stream with a TimeoutException once 60 seconds have passed, even while text is still arriving. The builder's timeout defaults to 1 minute (AbstractBedrockChatModel constructor), and BedrockStreamingChatModel.createClient applies it as the AWS SDK apiCallTimeout, which covers the whole event stream.
us-east-1, the prompt below, nothing else set unless noted:
| Client | Result |
|---|---|
BedrockStreamingChatModel, GPT-6 Astra, 1.20.0 |
❌ TimeoutException after 60.3 s, 3,503 partial responses already delivered |
BedrockStreamingChatModel, GPT-6 Astra, main |
❌ TimeoutException after 60.1 s, 3,178 partial responses |
BedrockStreamingChatModel, GPT-6 Sol / Luna / Astra, reasoning.effort: max (see details), main |
❌ TimeoutException after 60.3 / 60.3 / 60.2 s, before any partial response |
BedrockStreamingChatModel, GPT-6 Sol, main |
✅ 38.4 s, 4,762 output tokens |
BedrockStreamingChatModel + .timeout(Duration.ofMinutes(5)), Astra |
✅ 80.5 s, 5,833 output tokens |
boto3 converse_stream, default client config, Astra |
✅ 83.9 s, 5,560 output tokens |
OpenAiStreamingChatModel, default timeout, Bedrock /openai/v1 endpoint, Astra |
✅ 90.5 s, 5,930 output tokens |
Log and Stack trace From 1.20.0:
dev.langchain4j.exception.TimeoutException: Client execution did not complete before the specified timeout configuration: 60000 millis
at dev.langchain4j.model.bedrock.BedrockExceptionMapper.mapException(BedrockExceptionMapper.java:26)
at dev.langchain4j.model.bedrock.BedrockStreamingChatModel.lambda$streamTo$1(BedrockStreamingChatModel.java:225)
...
at software.amazon.awssdk.core.internal.http.timers.AsyncTimeoutTask.run(AsyncTimeoutTask.java:50)To Reproduce
StreamingChatModel model = BedrockStreamingChatModel.builder()
.region(Region.US_EAST_1)
.modelId("us.openai.gpt-6-astra")
.build();
model.chat("Write a detailed technical guide of about 3000 words on how hash maps work: hashing, collision handling, "
+ "load factor and resizing, and a complete commented Java implementation.", handler);
// handler.onError(TimeoutException) after ~60 s, onPartialResponse was already called ~3,000 timesExpected behavior
A stream that is still running completes, as with the AWS SDK defaults. An explicit .timeout(...) keeps limiting the call.
Please complete the following information:
- LangChain4j version: 1.20.0, and main @ efd1aa3
- LLM(s) used: OpenAI GPT-6 Astra, Sol and Luna on Amazon Bedrock (
us.openai.gpt-6-astra,-sol,-luna) - Java version: 21
- Spring Boot version (if applicable): not used
Additional context
This is separate from #3652 / #2737, which are about the sync BedrockChatModel and the HTTP client's socket timeout. The open PR #4029 keeps apiCallTimeout on the streaming client, so it would not change this. #1726 added this default for both the sync and streaming models; the Converse classes kept it. I have a small fix with tests and can open a PR.
I used Claude Code to trace the code path and run the checks. All runs: us-east-1, Bedrock API key auth, Java 21, the prompt above and no inference parameters unless noted. "partial responses" counts onPartialResponse calls.
- The
reasoning.effort: maxrow addsadditionalModelRequestField("reasoning", Map.of("effort", "max"))to the default request parameters and asks "Find all integer solutions (x, y) of x^3 - y^3 = 2023 + x*y and prove that your list is complete." global.openai.gpt-6-astrafails the same way on main:TimeoutExceptionafter 60.2 s.- A stalled stream is still ended by the AWS SDK's own read timeout: against a local HTTP/2 endpoint that sends response headers and then nothing,
BedrockStreamingChatModelreportedio.netty.handler.timeout.ReadTimeoutExceptionafter 30.1 s. - The same
reasoning.effort: maxrequest for Astra through boto3 ran for 283.3 s (16,815 output tokens); the longest gap between two stream events was 16.1 s.
Source: langchain4j/langchain4j