Skip to content

fix(step): keep a queued call alive when queue status fails, release its place when a resend fails - #377

Merged
liuedcson merged 1 commit into
mainfrom
fix/model-queue-resilience
Nov 30, 2026
Merged

liuedcson merged 1 commit into
mainfrom
fix/model-queue-resilience

Conversation

@liuedcson

Copy link
Copy Markdown
Collaborator

Background

Two client-side gaps in the Step model request queue:

  1. A failing status endpoint ended the call. When GET /stepcode/v1/queue kept failing for 30s (for example, the queue's store is unavailable), the call ended with a synthesized, non-retryable 410. At that moment the generation route usually still works, because the server skips its queue when it cannot keep one. The turn failed even though a plain resend would have succeeded.
  2. A failed resend left its place at the front of the line. After ready, a resend that failed on the way (a network error, or the SDK attempt aborting) threw without cancelling. Since ready does not change the server-side record, the place stayed at the front and held a slot until its lease expired (about 30s), while the retry policy re-entered the line under a new id.

Fix

  1. Resend instead of giving up (packages/coding-agent/src/step/model-queue.ts): once poll failures outlast the 30s budget, the wrapper resends the original bytes under the same queue id, exactly as on ready. A queued answer resets the backoff and starts a fresh budget. A closed answer, an unexpected status answer, the 20-minute bound, and 401/403 behave as before.
    • Before: Queue status unavailable: ... as a 410, plus a cancel.
  2. Release the place when a resend fails: if the resend rejects and the caller did not stop, the wrapper sends the cancel (bounded by 1s, as before) and rethrows, so the retry policy still sees the original failure.
  3. Docs: packages/coding-agent/docs/step-integration.md updated to match.

The server side needs no new contract: it already answers a resend with a queued, closed, or normal response, and is being updated separately to seat again a request (same body digest) whose place expired, rather than closing it.

Validation

  • pnpm run check: passes.
  • pnpm exec vitest --run test/step-model-queue.test.ts test/step-model-queue-session.test.ts test/main-model-fetch.test.ts (in packages/coding-agent): 59 passed, 3 runs.
    • Added: resend after the failure budget (same id, same bytes, no cancel); a queued resend gets a fresh budget; a failed resend releases the place and surfaces the error.
    • Updated: a resend stopped by the request's own signal now releases the place.
  • ./test.sh: passes. Locally it needed PATH without a user-level git wrapper that depends on $HOME (which test.sh isolates), and a short TMPDIR, because macOS limits Unix socket path length for tsx IPC. One earlier run hit an ENOTEMPTY temp-dir cleanup race in test/main-model-fetch.test.ts; the file passes on its own repeatedly and in the final full run.

Boundaries

  • A resend that fails is still retried by the SDK or session under a new queue id, so it joins the tail. Keeping the original place across retries is out of scope.

…its place when a resend fails

- A status endpoint that keeps failing no longer ends the call with a 410.
  Once failures outlast the 30s budget, the original bytes go out again
  under the same queue id, as on `ready`: the server runs a request without
  its queue when it cannot keep one, and seats again a request whose place
  expired. A queued answer starts a fresh failure budget.
- A resend that fails on the way (not a caller stop) now releases the place
  before the failure reaches the retry policy, so the place does not sit at
  the front of the line holding a slot until its lease ends.
@liuedcson
liuedcson merged commit e921877 into main Nov 30, 2026
2 checks passed
@liuedcson
liuedcson deleted the fix/model-queue-resilience branch November 30, 2026 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant