In this article
Measure last-event-to-close separately from deferred logging, and test queue backpressure; successful stream closure now precedes some observability work.
The November 15 LiteLLM v1.111.0-dev.4 prerelease moves served-text reconstruction after clean stream closure. Agent clients waiting for the stream iterator to finish can proceed before that logging work completes. The change preserves logging while bounding pending rebuilds; it does not remove the work, promise lower provider latency or make a closed connection proof that the final accounting row is already durable.
Timestamp the client’s actual continuation boundary
Use an owned provider fixture emitting a final event and an inert tool request. Record final-event receipt, iterator completion and the application’s next action. The fix targets the interval after the last event; time to first token answers another question. Compare equivalent payload lengths and client APIs, since a user interface that renders deltas immediately may notice little while a sequential agent loop waits for the iterator to return.
Deferred logging must still describe served content
Hold reconstruction at a controlled barrier, drain the successful stream and inspect the client’s complete content. Release the barrier and await the corresponding log before comparing it with what was served. Include an existing output-masking fixture where applicable. A test that expects logging to finish synchronously at connection close now checks the old timing contract. A test that never waits for logging can miss lost or incorrectly reconstructed final content.
The queue cap restores backpressure under load
The implementation caps pending background rebuilds at 64; beyond that, a stream waits for its rebuild as before. Block the rebuild workers in a synthetic test and cross the cap, then release them and confirm all logs arrive. This establishes bounded behavior without asserting that every overloaded request closes immediately. Memory use should be observed with the held chunk sets, because moving work behind response completion otherwise risks hiding accumulation from ordinary request-concurrency metrics.
Shutdown is a separate acceptance case
Trigger a graceful shutdown with reconstruction pending and verify the application’s own drain and log-delivery behavior. The PR review discusses deferred-accounting shutdown concerns, so clean-request timing does not settle that question. Error and client-disconnect paths retain their earlier reconstruction order. A useful adoption report distinguishes clean close, queue saturation, cancellation and shutdown, reporting any local latency result with its fixture rather than extending maintainers’ measurements to an untested deployment.
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.