LibreChat/packages
Danny Avila 6e00a9743a
⏭️ fix: Let Queued User Turns Go Before Completion Wake-ups at Run End (#18027)
* fix: Let Queued User Turns Go Before Completion Wake-ups at Run End

When a run ends with both a server-owned queued user turn and a background
or subagent completion wake-up waiting on it, the wake-up was expedited at
generation settlement while the queued turn sat out its five-second
readiness re-check, so the wake-up claimed the predecessor fence first and
the user's turn waited behind a whole automated turn.

- Generation settlement now also expedites the conversation's queued-turn
  deliveries.
- Background and subagent wake-ups defer without consuming an attempt while
  a queued turn holds an unexpired claim or is the due lane head, then run
  after it, chained to its response.
- hasPendingAgentQueuedTurn answers false for rows that need recovery or a
  user decision (reservations, expired claims, indeterminate admissions,
  dead heads awaiting dismissal), so a stuck queued turn never holds a
  wake-up. The read runs in parallel with the existing conversation read
  and fails open.
- Readiness deferral logs now carry the execution error code.

* fix: Read Queued-Turn Precedence in Claim Order and Defer on Unknown State

- Read the live claim after the head read settles, so a queued -> claimed
  transition between the two reads cannot answer false.
- Take plain identifiers in hasPendingAgentQueuedTurn and convert the user
  id inside data-schemas, keeping Mongoose types out of packages/api.
- A failed precedence read now defers the wake-up without consuming an
  attempt (QUEUED_TURN_STATE_UNAVAILABLE) instead of proceeding.

* fix: Read the Active Queued-Turn Lane in One Query

A claim released back to `queued` between the head read and the live-claim
read could still answer false. Read the reserving, queued and claimed rows
in one query over the capacity index, whose `activeSlot` key holds steady
from reservation until a terminal state, so each row is seen exactly once
in one state. Dead heads and indeterminate quarantines stay separate
indexed reads in parallel. Falls back to a planner-chosen read when the
capacity index has not been built yet.

* fix: Fall Back to a Planner Read Whenever the Lane Hint Is Refused

A hint can be refused for reasons other than a missing index on some engines. The hinted read only pins the stable key, so any refusal now retries unhinted; a genuine outage fails that read too and defers the wake-up.

* fix: Read Queued-Turn Blockers After the Turn They Block

The precedence read gathered the active lane, the dead lane head and the
indeterminate quarantine in parallel, so a blocker could be older than the
queued turn it blocked. A dead head dismissed while the reads were in flight
still answered false and let a completion wake-up race the successor it had
just unblocked.

Read the active lane first, and the blockers (a reservation, an expired
claim, an indeterminate admission, a dead row ahead of the head) only
afterwards and only for a due head, in one existence query. A blocker that
has already cleared no longer answers false, and a conversation with no due
queued turn now costs one read instead of three.
2026-11-10 14:56:41 -05:00
..
api ⏭️ fix: Let Queued User Turns Go Before Completion Wake-ups at Run End (#18027) 2026-11-10 14:56:41 -05:00
chat ⏱️ fix: Preserve Running Tool Timers Across Disclosure Remounts (#17997) 2026-11-10 15:56:09 +01:00
client 🎩 fix: Dismiss Only the Topmost Dialog on Escape (#17977) 2026-11-10 09:46:16 -05:00
data-provider 🦪 fix: Preserve Generated File Byte Snapshots (#18009) 2026-11-10 13:45:15 -05:00
data-schemas ⏭️ fix: Let Queued User Turns Go Before Completion Wake-ups at Run End (#18027) 2026-11-10 14:56:41 -05:00