Repository navigation
V8: Return 409 with Retry-After from /chat when the session is busy - #684
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LinuxDevil
force-pushed
the
v8-chat-busy-409
branch
from
October 19, 2026 22:22
6fc0b98 to
012d7ed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes audit finding SWE-2 (Vercel competitor audit, 2026-10-19).
What was wrong
When another replica/process held a session's run lease,
POST /chatanswered200and streamed an in-banderrorevent (LOUSHO_SESSION_BUSY); channels (V7) already answered 409 + Retry-After. The in-process Idempotency-Key duplicate 409 had no Retry-After.What changed
turnResponse()insrc/server/fetchRoutes.ts: reads the turn's first event (or failure) before responding; aLOUSHO_SESSION_BUSYrefusal becomes409 {error, code}+Retry-After: 2. Anything else streams as before; later failures stay in-band coded events. Used for plain turns and Idempotency-Key turns (new and resumed).SESSION_BUSY_RETRY_AFTER_SfromchannelCore.ts(export only) so channels and/chatshare the value.Tests
New
src/server/chatBusy.test.ts(two file-store replicas, one holding the lease): 409 +Retry-After: 2+ coded JSON body; Idempotency-Key resend while the original runs elsewhere gets 409, then replays (Idempotent-Replayed) after it finishes; same-process duplicate has Retry-After. Fails without the fix (200 instead of 409). tsc, typecheck:tests, lint, api:check, docs:llms, fallow (exit 0) pass; src suite passes except packages/create-lousho-agent tests (need a packed SDK/install; environment-only on Windows).Behavior change: a busy session over
POST /chatis now an HTTP 409 rather than a 200 stream with an error event; the response starts after the turn's first event rather than immediately.Changelog:
POST /chatanswers 409 withRetry-Afterandcode: LOUSHO_SESSION_BUSYwhen another process or replica is running the session.🤖 Generated with Claude Code