* fix(bedrock-runtime): cancel abandoned calls and omit error-body logs
Closes#5522. Tie upstream transport lifetime to the Bedrock caller, clean up interrupted streaming bodies, and retain HTTP-error status diagnostics without backend response content.
* fix(bedrock-runtime): bound stalled upstream error-body reads
Enforce a one-second diagnostic-read deadline with the existing disconnect monitor. Close short stalled error bodies and retain the known ModelErrorException. Regressions cover empty bodies and one or 50 short lines, caller latency, upstream closure, and payload-free warnings.
* fix(bedrock-runtime): share cancellation monitoring and split error-read deadline
Use one monitor accepting a cancellation condition and action for both Converse paths. Move error-read deadline implementation, regressions, and documentation to a separate follow-up at the maintainer request.
ConverseStream previously buffered the whole proxied response, translated it in
one shot, and returned it as a single byte[]. Both backends now write frames
through a JAX-RS StreamingOutput as they're known, and the proxy backend reads
the upstream SSE response via HttpResponse.BodyHandlers.ofLines() instead of
ofString() - text deltas reach SDK clients as the model generates them instead
of landing all at once when the response finishes.
Once the StreamingOutput starts writing, JAX-RS has already committed the 200
response, so a failure discovered only after streaming begins - a stream that
never reaches a finish_reason or "[DONE]" (upstream connection dropped
mid-generation) - can no longer become an HTTP error status. It's now reported
as a modelStreamErrorException event, the same wire shape (:message-type:
exception, :exception-type: <name>) and modeled exception real Bedrock uses
for a mid-stream failure, verified to decode correctly through
BedrockRuntimeAsyncClient's generated ConverseStreamResponseHandler. A stream
that completes normally (finish_reason or "[DONE]" seen) with no content is
now treated as a legitimate empty completion rather than an error, matching
real Bedrock.
Added a compatibility-tests/sdk-test-java case exercising
BedrockRuntimeAsyncClient.converseStream end to end, proving the emitted
event-stream frames decode correctly through the real AWS SDK rather than
only Floci's own byte-level assertions.
Both backends now emit the real application/vnd.amazon.eventstream framing
Bedrock SDK clients expect: a messageStart/contentBlockDelta/contentBlockStop/
messageStop/metadata event sequence, framed with the same AwsEventStreamEncoder
helper already used by S3 Select and Kinesis SubscribeToShard.
The proxy backend posts to /chat/completions with stream:true (matching
Converse) and translates the OpenAI SSE response into Bedrock stream events,
including basic tool-call accumulation. A response - streaming or not - that
never produces real completion content surfaces as a ModelErrorException
instead of a fabricated empty success:
- ConverseStream: no usable SSE chunks, chunks that only carry role/usage/
finish_reason with no text or tool_calls, a stream that ends without a
finish_reason or "[DONE]" (truncated mid-generation), or a tool_calls
fragment missing its id/name or with arguments that never form valid JSON.
- Converse: a 2xx response with no choices at all.
* feat(bedrock): add proxy backend for real LLM responses via OpenAI-compatible API
* fix(bedrock): preserve leading text when a tool call response also has content
OpenAI-compatible backends can return assistant text alongside tool_calls in
the same response (e.g. a preamble before invoking a tool). The Converse
translation only emitted the toolUse block in that case, silently dropping
the text.
* fix(bedrock): use InternalServerException for proxy serialization failures
InternalFailure isn't a bedrock-runtime error shape in botocore/the Java
SDK, so clients couldn't map it; InternalServerException is the declared
500 for this API.
* fix(bedrock): map proxy backend timeouts to ModelTimeoutException (408)
HttpTimeoutException (connect or request timeout) was falling into the
generic catch and surfacing as ModelErrorException/424, which the AWS
SDKs treat as terminal. Bedrock's dedicated 408 shape is retryable under
the default SDK retry strategy, so this distinction is load-bearing, not
cosmetic.
Also makes the request timeout configurable
(proxy.request-timeout-seconds, default 60s) since larger models on
CPU-backed backends may need more headroom than the default.
* fix(bedrock): fail fast on InvokeModel under the proxy backend
Falling back to StubBackend's canned response meant a caller who
configured a real proxy backend and called InvokeModel got a
plausible-looking, entirely fabricated completion with no signal beyond
a server-side log line. That's inconsistent with Converse, which already
fails loudly on misconfiguration, and worse: InvokeModel is still the
default entry point for many SDK wrappers, so this could silently mask
a broken integration.
Also fixes the streaming-endpoint error messages, which blamed "the
Floci stub" for a limitation that's actually unconditional (streaming
isn't implemented for any backend).
Adds a bedrock-runtime service stub so AWS SDK and CLI clients can target
Floci for local development of Bedrock Runtime callers. Dummy responses
only: no real model inference.
- Register bedrock-runtime in ResolvedServiceCatalog under both "bedrock"
and "bedrock-runtime" credential scopes (boto3 signs with signingName
"bedrock" while some clients use the endpoint id)
- POST /model/{modelId}/converse returns a fixed assistant message plus
synthetic usage and latency metrics matching the AWS Converse contract
- POST /model/{modelId}/invoke returns an Anthropic-shaped body for
anthropic.* and *.anthropic.* model ids, generic {"outputs": [...]}
otherwise. Request body is passed through as opaque bytes
- {modelId:.+} path regex accepts full ARNs (inference profiles,
provisioned throughput) in addition to plain ids
- converse-stream and invoke-with-response-stream return 501 so SDKs
get a clear error instead of 404
- Response building uses JsonNode rather than typed POJOs, avoiding
native-image reflection registration
13 new integration tests (Converse + InvokeModel happy paths, validation,
inference-profile ids and ARNs, 501 streaming responses). Full suite
remains green: 2263 tests, 0 failures.