LibreChat/api/server/controllers/agents
Danny Avila b34bbd83ef fix: lease-token lifecycle fences — same-generation isolation, admission fence, undelivered-Stop retention, legacy abort enrollment
Fifth external review round; four P1s, handled as the requested consolidated
lifecycle-fence pass.

- Lease tokens. Marker fields were (streamId, createdAt), shared by every
  contender on the same generation — completion and Stop, or two racing Stops —
  so a losing contender's cleanup erased the winner's still-live marker. Every
  registrant now carries a unique lease token in the field and may only ever
  clear its own lease; unqualified legacy clears cannot touch qualified entries.

- Admission fence. Authentication can pass before the deletion barrier goes up,
  and the durable createJob is several async steps later — a deletion quiesce in
  that window saw neither an active job nor a marker and could cascade before
  the admitted request created its job. The controller now registers an
  admission lease and THEN rereads the deletion barrier: the ordering guarantees
  either this request observes the barrier (403, lease released, slot/claim
  cleanup) or the quiesce observes the lease and defers. Held until createJob is
  durable; released on every refusal and initialization-error path. Fail closed
  when the lease itself cannot be registered (503 retryable).

- Undelivered-Stop retention. abortJob released its lease in a finally even when
  delivery AND publication had provably failed — the job reads terminal
  (invisible to active-set scans), a user Stop writes no durable abort fence,
  and the remote owner keeps generating and will persist its abort-catch writes
  whenever the signal finally lands. The lease is now retained in exactly that
  case, and each resignal attempt heartbeats a fresh lease so the fence outlives
  the TTL for as long as delivery is still being driven. The abort-winning
  turn's own loser-side pending saves are additionally fenced in the controller
  catch (best-effort — those writes are already in flight).

- Legacy abort enrollment. abortMiddleware (assistants abort route fallback for
  non-assistants endpoints) awaited abortJob and then spent usage and saved the
  stopped response AFTER the abort's lease was released. Both writes now run
  inside `beforePublish`, between the abort CAS and publication, covered by the
  same lease as every other abort.

Barrier tests, each verified to fail without its fix: same-generation lease
isolation (store), racing two-Stop loser cleanup (manager, stale-read forced
CAS race), undelivered-Stop lease retention, resignal heartbeat, admission
refusal with lease-before-reread ordering plus release-on-durable-create, and
legacy-abort persistence inside beforePublish.
2026-08-18 07:46:18 -04:00
..
__tests__ fix: lease-token lifecycle fences — same-generation isolation, admission fence, undelivered-Stop retention, legacy abort enrollment 2026-08-18 07:46:18 -04:00
callbacks.background.spec.js ⏱️ feat: Show Run-Step Durations On Tool Cards (#14892) 2026-08-16 16:17:02 -04:00
callbacks.js ⏱️ feat: Show Run-Step Durations On Tool Cards (#14892) 2026-08-16 16:17:02 -04:00
client.js feat: Scheduled Chats — agent-centric scheduled runs creating real conversations 2026-08-18 07:46:18 -04:00
client.test.js 🧵 feat: Persist View-Only Subagent Threads (#14957) 2026-08-18 07:41:42 -04:00
errors.js feat: Scheduled Chats — agent-centric scheduled runs creating real conversations 2026-08-18 07:46:18 -04:00
errors.spec.js feat: Scheduled Chats — agent-centric scheduled runs creating real conversations 2026-08-18 07:46:18 -04:00
filterAuthorizedTools.spec.js 🔗 fix: Resolve MCP Tool-Key Boundary Against Configured Server Names (#14448) 2026-07-27 14:45:38 -04:00
openai.js 🕸️ feat: Run Saved Agent Teams as Subagents (#14944) 2026-08-17 18:02:52 -04:00
protocol.js ⚡ feat: Reliable Interrupt & Steer Escalation and Recovery (#14558) 2026-07-31 20:07:56 -04:00
recordCollectedUsage.spec.js 🪢 chore: Consolidate Pricing and Tx Imports After tx.js Module Removal (#12086) 2026-03-21 14:28:53 -04:00
request.js fix: lease-token lifecycle fences — same-generation isolation, admission fence, undelivered-Stop retention, legacy abort enrollment 2026-08-18 07:46:18 -04:00
responses.js 🧵 feat: Persist View-Only Subagent Threads (#14957) 2026-08-18 07:41:42 -04:00
resume.js fix: lease-token lifecycle fences — same-generation isolation, admission fence, undelivered-Stop retention, legacy abort enrollment 2026-08-18 07:46:18 -04:00
steer.js 🛰️ feat: Execute Generic Agent Trigger Deliveries (#14921) 2026-08-17 08:45:49 -04:00
v1.js 🕸️ feat: Run Saved Agent Teams as Subagents (#14944) 2026-08-17 18:02:52 -04:00
v1.spec.js 🕸️ feat: Run Saved Agent Teams as Subagents (#14944) 2026-08-17 18:02:52 -04:00