LibreChat/api/server/controllers/agents
Danny Avila 6adce5a12a refactor: make escalation one atomic server-side arm, in place
Codex round 4: four P2s, every one an interleaving of the same window —
escalation as reclaim-then-repost is a compound, non-atomic operation
whose continuation must revalidate the world (FIFO position lost, ref
assigned too late, no run fence, competing bubble actions). Rounds 1-3
patched that window with a lock and rechecks; round 4 shows the window
itself is the defect, so this removes it instead of guarding it again.

Escalation is now POST /chat/steer/arm: the server flips preempt on the
EXISTING queued item in one atomic store op (new IJobStore.armSteer; a
decode-patch-encode LSET Lua on Redis, an in-place mutation in memory),
fenced to the validated generation and refused once the queue closes.
The handler mirrors the steer POST's preempt contract exactly: durable
flag gated on the owner's recorded capability, volatile requestPreempt
fire-and-forget because the durable flag is the truth resume/handover
re-arm from.

By construction this resolves all four findings: FIFO survives (the
item never moves; the whole queue still drains in instruction order at
the seal), there is no continuation to hold stale controls, the store
op is fenced to the original run, and a competing Edit/Queue/Cancel
either beats the arm (armed:false, chip untouched) or operates on the
armed item, whose cancel already disarms.

The client escalation entry becomes one mutation: armed:true relabels
the chip in place (same steerId, same position), PREEMPT_UNSUPPORTED
and lost races toast honestly, and the round 1-3 machinery — the
escalating lock atom, the latest-ref, the post-reclaim rechecks and
their two toast strings — is deleted rather than extended.

Verified: 7 new handler tests on the real in-memory manager (including
FIFO preservation and the stale-generation fence), 2 Redis integration
tests against real Redis (in-place arm keeps order and every field;
missing/stale/closed all refuse), client suites 396 green.
2026-07-30 17:54:07 -04:00
..
__tests__ 🛑 feat: Preemptive Steer - Backend Interrupt & Steer (#14518) 2026-07-30 12:36:13 -04:00
callbacks.background.spec.js 🧵 feat: Native Background Execution for Code Interpreter Tools (#14386) 2026-07-22 22:13:15 -04:00
callbacks.js 🛂 test: Cover Tool Approval Workflows End to End (#14427) 2026-07-26 21:58:25 -04:00
client.js 🛑 feat: Preemptive Steer - Backend Interrupt & Steer (#14518) 2026-07-30 12:36:13 -04:00
client.test.js 🛂 test: Cover Tool Approval Workflows End to End (#14427) 2026-07-26 21:58:25 -04:00
errors.js 📦 refactor: Consolidate DB models, encapsulating Mongoose usage in data-schemas (#11830) 2026-03-21 14:28:53 -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: Tool Intent Label Capability (tool_intents) (#14499) 2026-07-29 15:40:52 -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 🛑 feat: Preemptive Steer - Backend Interrupt & Steer (#14518) 2026-07-30 12:36:13 -04:00
responses.js 🎯 feat: Tool Intent Label Capability (tool_intents) (#14499) 2026-07-29 15:40:52 -04:00
resume.js 🛑 feat: Preemptive Steer - Backend Interrupt & Steer (#14518) 2026-07-30 12:36:13 -04:00
steer.js refactor: make escalation one atomic server-side arm, in place 2026-07-30 17:54:07 -04:00
v1.js 🔗 fix: Resolve MCP Tool-Key Boundary Against Configured Server Names (#14448) 2026-07-27 14:45:38 -04:00
v1.spec.js 🧭 test: Cover Agent Handoffs End to End (#14428) 2026-07-27 08:47:15 -04:00