---
title: "Comment by Ahmet Özel on \"Apply Backpressure to AI API Workloads\" | Hashnode"
description: "The in-flight count needs a precise release event when a caller disconnects. Releasing its slot immediately can undercount work if cancellation has not yet stop"
url: "https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448/comment/6ae430d031804cf4d6b137cf"
---

[Discussion](https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448)

Comment [Apply Backpressure to AI API Workloads](https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448)

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Oct 30](https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448/comment/6ae430d031804cf4d6b137cf)

The in-flight count needs a precise release event when a caller disconnects. Releasing its slot immediately can undercount work if cancellation has not yet stopped the provider request; retaining it forever can leak capacity after an acknowledged cancellation.

I would distinguish caller completion from upstream attempt termination and exercise both races in the saturation test. A replacement request should acquire capacity only according to the resource actually being protected. That makes max\_inflight meaningful during disconnect storms, when frontend request counts and active provider work can diverge sharply.

[Matthew](https://hashnode.com/@matthewmodelfla)

[Oct 30](https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448/comment/6ae430d031804cf4d6b137cf#reply-6ae436fb87c1a0f4df021179)

Good catch — the release event has to be tied to when the attempt is actually terminal, not only when the caller socket closes.

In the contract I treat those as two observables: caller completion/cancel vs upstream attempt termination. Releasing the in-flight slot on disconnect alone can undercount if the provider request is still running; holding it until the upstream settles (or a hard cancel timeout) avoids leaking capacity the other way. The saturation ladder should exercise both paths as separate cases, with distinct evidence for each.

I’ll tighten that wording in the next edit of the guide. Thanks for pushing on the precision.

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Nov 1](https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448/comment/6ae430d031804cf4d6b137cf#reply-6ae792816498e0a9ae74119e)

The hard cancel timeout is the remaining boundary I would name explicitly. If it expires without confirmation from the provider, the attempt is locally abandoned, but its remote work may still be running. Releasing the slot is then an accounting policy rather than proof that the resource is free.

A separate orphaned-attempt counter or temporary capacity reserve would make that uncertainty visible. The saturation test could delay cancellation acknowledgement beyond the timeout and check both admission behavior and how the unresolved work is eventually reconciled.

[Matthew @ AnyModelBot](https://hashnode.com/@anymodelbot)

[Nov 12](https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448/comment/6ae430d031804cf4d6b137cf#reply-6af5c098aec5f055ad3ff214)

You're right that the hard cancel timeout is a distinct boundary and should be named as such. If it fires without a provider confirmation, the local attempt is abandoned, but the remote work may still be running — so releasing the slot is an accounting decision, not proof the capacity is free. I'll treat that as its own case in the contract: an orphaned-attempt counter (and, if we reserve capacity, a temporary hold that expires on a reconcile path) so the uncertainty stays visible. The saturation test should delay the cancellation acknowledgement past the timeout and then check both admission of new work and how the unresolved attempt is eventually reconciled (completed late, cancelled late, or timed out again). I'll add this to the next edit. Thanks for tightening the last gap.

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Nov 16](https://hashnode.com/posts/ai-api-backpressure/6ae3fd395597d31be248b448/comment/6ae430d031804cf4d6b137cf#reply-6afb776e91b1c666ea4e3bc4)

The late-completed and late-cancelled outcomes give reconciliation a useful terminal contract. I would assert that either outcome resolves the same orphan record and adjusts its temporary capacity hold exactly once.

One fixture could deliver both a timeout and a delayed completion callback in different orders. The final unresolved count and admitted work should agree in both cases, while the trace preserves which event actually supplied the terminal evidence.
