LibreChat/packages/chat
Danny Avila 60a74e6cd4
🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End (#18028)
* 🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End

A steer the server accepted (202) but the run never applied was handed back
in FINAL as `pendingSteers` and re-owned by the browser as a tab-local queued
message. A reload, closed tab, or a predecessor race before the drain lost it.

At terminal publication, a normally completed run now promotes such steers
into server-owned agent queued turns (parent: the ended response, epoch: the
ended generation's createdAt, chained behind any turn already queued against
that epoch). The job store hands the parked copy over atomically
(`promoteSteerLeftover`: parked item removed, receipt settled `recovered`), so
status recovery, lost-ACK retries and legacy recovery starts cannot queue the
same words again. FINAL reports the receipts in `promotedSteers`; the client
adopts them as server rows instead of converting the steer locally.

Promotion is opt-in per steer (`promoteLeftover`, sent only by clients that
adopt receipts and only for steers with no tab-only context), so older
clients keep the legacy path unchanged, and older servers simply never
report `promotedSteers`.

* 🔒 fix: Settle a Promoted Steer's Hand-Off at Admission, Not Only at FINAL

The job-store hand-off of a promoted steer now returns an outcome and stamps
the receipt with the owning queued turn, so it is idempotent for that turn.
The queued-turn resolver repeats it before admitting a promoted turn: it
completes a hand-off a crash interrupted, and cancels the turn when the
parked copy was discarded or recovered elsewhere, so the words never run
twice. At FINAL, a row whose hand-off was refused and whose retirement cannot
be confirmed is withheld from `pendingSteers` and left for that admission
check. The conservative reconcile frame keeps `promotedSteers`, and the
client adopts it there before sweeping local chips.

* 🔏 fix: Give Promoted Steers Durable Ownership, Their Run's Queue Lineage and Approval Mode

A turn promoted from an unapplied steer now records its source on its own
row: the steer's ids, the generation that accepted it, and a mark set only
once the job store handed the parked copy to that row. Admission runs a
promoted turn on that mark or on a hand-off the job store confirms now;
without proof (the store's evidence expired, or the host cannot ask) the
turn is held for review instead of running.

- Hand-off replies that are lost no longer cancel the row. The row stays as
  the client's handle and its admission settles ownership, so a committed
  hand-off can no longer leave the steer with no runnable copy.
- A replayed promotion never hands the parked copy to a row that was
  cancelled or failed.
- Promoted turns join the queue lineage of the generation that accepted
  the steer, so a sibling still queued behind that run no longer strands
  them with a predecessor mismatch.
- The steer request carries the sender's code approval mode onto the
  promoted turn; an unreadable mode keeps the steer on the client path.
- A steer whose quotes its owner stripped stays on the client path.
- The queued-turn receipt names the promoted steer by both ids, and the
  receipt list retires a pane's local copies even when it missed FINAL.

* 🚧 fix: Fence Promoted Turns to Workers That Prove Steer Ownership

A promoted row without an approval mode was published under the v1 queued
turn capability, so during a rolling deploy a worker that predates the
ownership check could claim it and run an unsettled row while the parked
steer was still recoverable elsewhere.

Promoted rows now publish under a new agent_queued_turn_v3 capability and a
v3 delivery identity, always reserved before insertion. A replica that
projects an older version can neither publish the reserved delivery nor
claim it, and enqueue refuses a promoted row without a reservation.

* 🪦 fix: Keep a Dead Promoted Turn Answering for Words It Held

A pane that learns of a promoted steer from the receipt list dropped the
mapping for every dead row. A row quarantined as ADMISSION_INDETERMINATE can
still settle as admitted, and a row that died after it was proven the sole
owner of the words is their only surface, so in both cases the pane kept a
chip whose recovery could never run.

The receipt now says whether the turn owned its steer's words, and a dead
receipt keeps answering for them when it did or when its admission is
indeterminate. A replayed promotion applies the same rule to a settled row.

* 🧾 fix: Find Promoted Turns by the Steer a Pane Holds, Join Root Lineages, Redact Hand-off Errors

- A promoted turn's request id is now derived from the client steer id, and a
  pane asks for the receipts of the steers it still holds a local copy of
  (recovery rows and failed chips). A promoted turn that already ran is only
  listed when asked for by name, so a pane that missed FINAL now finds it
  and retires its copy. A client steer id too long to key a queued turn is
  not promoted.
- The lineage lookup includes a generation admitted from a root queued turn,
  which has a parent and no epoch. The promoted turn joins that lineage
  without an epoch instead of opening a second one.
- A failed hand-off at admission reports a fixed message. The job store's
  own error text stays out of the dead-letter record a client can read, and
  promotion logs carry safe error metadata instead of error text.

* 🔢 fix: Ask for Held Steers First Under the Receipt Lookup Limit

The receipt list answers for at most 100 request ids, and a pane's server
rows were listed ahead of the steers it still holds, so a full server queue
could push every held steer out of the request. A promoted turn that had
already run was then never found.

Held steers now come first. An active server row is listed whether or not
it is asked for, while a settled promoted turn is found only by name.
2026-11-10 22:43:32 -05:00
..
src 🧷 fix: Promote Unapplied Steers to Durable Queued Turns at Run End (#18028) 2026-11-10 22:43:32 -05:00
test 🪟 feat: Add Welcome Footer and Response Author Options and Tidy the Chat Chrome (#17879) 2026-11-08 14:57:59 +01:00
babel.config.js
components.json 🎛️ refactor: Move Composer Leaf Controls and Steering Into the Chat Package (#17521) 2026-10-28 13:27:38 +01:00
jest.config.js 🚦 refactor: Move the Composer Queue Rail Into the Chat Package (#17685) 2026-11-01 01:25:34 +01:00
jest.polyfills.js 🧵 refactor: Render the Package Message List by Default in ChatScreen (#17753) 2026-11-05 22:35:15 +01:00
package.json 🚦 refactor: Move the Composer Queue Rail Into the Chat Package (#17685) 2026-11-01 01:25:34 +01:00
tsconfig.json 📝 refactor: Move Text-Like Message Parts Into @librechat/chat (#17087) 2026-10-14 18:05:48 +02:00
tsdown.config.mjs