In this article
Observe decoded iteration and HTTP response closure separately when aborting Bedrock Invoke; a stopped client stream does not prove upstream resources were released.
LiteLLM v1.111.0-dev.4, published on November 15 as a prerelease, fixes aborted Bedrock Invoke Messages streams that could continue reading upstream. The implementation connects iterator cleanup to the underlying HTTP response. Cancellation acceptance therefore needs observation below the decoded event stream, where a closed client view can still conceal an open provider connection.
Use a provider-shaped event stream
A harmless local fixture can emit the Bedrock event framing expected by the adapter and remain open after its first event. Start the real proxy route and disconnect its client. Observe the provider connection independently from gateway events. This exercises the actual ownership chain rather than testing only an iterator in isolation, where a mocked close method may report success without closing the transport it is meant to own.
Detached draining is part of the scenario
Record the configured detached-drain policy and the point at which the adapter chooses to abort upstream. A disconnect can precede that decision, so report both intervals. The fix does not imply every client hang-up immediately terminates provider work under every configuration. Use bounded synthetic data and explicit stop conditions so the acceptance run cannot turn an intentionally open stream into an uncontrolled resource leak.
Cleanup must include nested iterators
Instrument the byte iterator, decoded event iterator and HTTP response closure with safe counters. Assert each relevant cleanup path settles when iteration ends early or raises. A finally block can protect ordinary exceptions while another exit path still retains a reference. Repeat short cancelled requests and inspect connection count. This is resource-lifetime evidence, not a performance claim based on one response arriving quickly.
Separate connection release from external compute
Verify the application records cancelled partial output honestly and does not launch follow-up tools from late data. Closing the gateway’s HTTP response establishes local cleanup; it does not independently prove provider compute stopped or all charges disappeared. Report the tested route, drain configuration and observed transport lifecycle. The useful adoption result is a bounded, explainable cancellation path that leaves other requests serviceable without inventing stronger remote guarantees.
Sources
Related reading
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.