qwen-code/packages/sdk-java
Shaojin Wen 17132f7a74
fix(sdk-java): let a terminal continuation start the next prompt (#7615)
A prompt reserves both a prompt slot and a stream-cleanup slot in
DaemonClient.submit, but releases them at different times: the prompt slot is
released synchronously in FutureTask.done(), immediately before the terminal
publication gate opens, while the stream-cleanup slot is only released once the
SSE stream has finished closing on the stream-close executor. The terminal path
in observe() closes that stream asynchronously and does not wait for it.

Both semaphores were sized to maximumConcurrentPrompts, so a caller chaining
prompts off completionFuture() at full capacity races the previous prompt's
close: when the close had not finished by the time the terminal was published,
startPrompt failed with DaemonClientCapacityException("Stream cleanup capacity
is exhausted"). This is how the documented chaining pattern behaves under load,
and it made terminalContinuationCanStartNextPromptAtClientCapacity flaky in CI.

Size the stream-cleanup semaphore to allow one draining cleanup per prompt
slot, which is exactly the overlap the release ordering can produce. Admission
backpressure is unchanged in kind: cleanups that stay stalled beyond that
headroom still fail fast, now after two generations instead of one.

The stream-close executor queue is derived from the same capacity, so it still
absorbs every reservation without rejecting work.
2026-07-23 16:37:52 +00:00
..
client fix(sdk-java): correct TIMEOUT_30_MINUTES to 30 minutes (#7188) 2026-07-18 22:36:22 +00:00
qwencode fix(sdk-java): let a terminal continuation start the next prompt (#7615) 2026-07-23 16:37:52 +00:00