* 🧷 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.
* 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.
* 🦊 feat: Add Claude Fable 5.2 Support
* fix: Preserve Snapshot Version Boundaries in Model Matching
* test: Measure the Snapshot-Safe Token Matcher Search
---------
Co-authored-by: Lia <lia@librechat.ai>
* 🔂 fix: Preserve Subagent Checkpoints Across Tool Approvals
* fix: Type Mongo Checkpoint Test Collections
* fix: Reclaim Child Checkpoints With Their Parent Conversation
* test: Seed Legacy Terminal Replay Without Publishing a Stub
---------
Co-authored-by: Lia <lia@librechat.ai>
* perf: Validate Agent Models Against Their Own Endpoint Catalog
* perf: Share In-Flight Model List Fetches
* test: Cover Agent Model Validation Across Endpoints
* test: Check Agent Model Catalog Parity With the Real Loaders
* perf: Look Up MCP Server Catalogs Concurrently for Tool Definitions
* test: Cover MCP Sign-In Order for Concurrent Catalog Lookups
* docs: Widen the mcpCatalogLookups Comment in the Example Config
* test: Cover the Catalog Lookup Bound Passed to the Definitions Loader
* perf: Read Only the Active Branch for Turn History
* perf: Narrow the History Read Only When It Skips a Tenth of the Rows
* test: Cover Follow-Up Turns After a Regenerated Answer
- fix: Add Context Windows for Unmapped Bedrock Models
- fix: Price Newly Mapped Bedrock Models
- fix: Bill GPT-6.1 Terra Regional Profiles at the Regional Rate
- Map the four NVIDIA Nemotron models on Bedrock to their AWS-documented context windows (256K for Nemotron 3 Super and Nano, 128K for the Nano v2 pair), so agents stop falling back to the 32K default that MCP tool schemas exhaust once a tool result arrives.
- Price the same models at their Bedrock on-demand rates so the context and pricing maps stay in parity.
Bound model-facing Flux images to the 5 MiB base64 budget for standard and finetuned generation. Preserve original image data for attachment storage under the existing resolution policy.
Fixes#6954.
* fix: Read the Account and Session Together and Test Cancel on a Real Database
- Start the setup user and refresh session lookups together in the cancel controller instead of one after the other, as the opt-in confirmation already does
- Run the cancel controller spec on mongodb-memory-server with the real data-schemas methods, so the session and compare-and-swap predicates under test are the production ones, and add a negative case for each
- Keep only a module wiring test in the CJS controller spec, since the database behavior is now covered where it can run for real
* test: Pin the Cancel Response When the Session Lookup Fails
Both lookups now run before any cookie or write, so a failed session lookup answers 500 with the browser and the stored state untouched. Cover that on the real database.
* fix: Keep the Saved Files Draft Until the File List Loads
After a reload the live file map is empty until the server's file list arrives, and the restore that rebuilds it needs that list. The save effect rewrote the stored draft from the empty map in between, so a pasted-text chip or any other attachment was gone before it could be restored. It now waits for the list. This is what turned the composer-attachments restore scenario red on dev.
* fix: Keep the Provider Message on Classified Rate Limit Errors
* fix: Honor maxProviderErrorChars for Classified Generation Errors
* test: Cover Classified Gateway Errors in the Mock Harness
* test: Cover a Zero Provider Detail Limit on Generation Errors
* refactor: Resolve Classified Provider Errors in the TypeScript Backend
* fix: Redact Provider Details Before Truncating Them
* 📏 fix: Measure Usage Percent Against the Allowance Each Period Granted
Store the credits granted at the start of each balance period on the record and measure the usage percent against it, so changing refillAmount or startBalance no longer moves a user's percent until their next grant. Legacy records fall back to the configured amount.
* 🕰️ fix: Ignore a Stored Allotment a Later Refill Has Replaced
Stamp each stored allotment with the time of its grant and measure against it only while no refill is more recent, so a refill by a replica that predates the field falls back to the configured amount instead of reporting usage against the prior period's allowance.
* 🔒 fix: Write the Allotment Grant Atomically and Return Its Period Start
Insert lastRefill with the credit, allotment and grant time when a balance record is created, so a racing creator never moves another's period start past its grant. Return lastRefill even without auto-refill so the client can place a stored allotment in its period, and fall back when it cannot.
* 🔐 fix: Authorize Restored MCP Tools Before Agent Revert Writes Them
Reverting wrote the version snapshot, including its mcpServerNames, before
filterAuthorizedTools ran. Agent-scoped MCP access is granted from that index,
so a restored server vouched for itself and an editor without access to it
could re-attach it. A snapshot without mcpServerNames also left the current
index in place, keeping agent-scoped access to servers no tool used.
The handler now authorizes the restored tools against the agent as it stands,
treating only its current tools as existing, and passes the authorized tools
and rebuilt index to revertAgentVersion so the restore is one write pinned to
the revision it was checked against. revertAgentVersion always rewrites the
index for the restored tools.
* 🔐 fix: Exclude the Target Agent's Own Grant When Authorizing a Revert
Moves the restore authorization into authorizeAgentRestore in packages/api,
leaving the revert controller as wiring.
A newly restored MCP tool whose server the user reaches only through agents
must now be reachable through an agent other than the one being reverted,
checked fresh against the database. The target's current or cached index
(including one left stale by an earlier revert) no longer vouches for it.
Prior server names are matched through their normalized aliases, and only for
tools the agent already had. When nothing resolves, the pre-restore index is
kept instead of deriving names from tool keys.
A revision-filtered restore that misses is reported as a 409 conflict.
The route spec restores the real ~/config so the MCP registry is consulted
rather than reported unavailable.
* 🔐 fix: Check Newly Restored MCP Servers Against Live Grants
The restore gate now runs for every approved MCP tool, not only consumeOnly
ones. A tool the agent doesn't already have, on a DB-backed server, is
admitted when a current tool still uses that server, or on a live direct
server grant, or through another viewable agent. A grant the registry still
caches after revocation no longer becomes durable through the restored index.
Admission is memoized per server. A snapshot tools array that sanitizes to
nothing restores an explicit empty set. Active-server matching no longer
reuses the index fallback, so a stale entry is never read as in use.
* 🔐 fix: Treat Legacy Cached DB Configs as User-Sourced in the Restore Gate
A config cached before an upgrade may carry a dbId without source. The
restore gate now uses isUserSourced, so such configs get the live access
check instead of passing as operator-managed.
* 🔐 fix: Recheck Unindexed Existing MCP Tools in the Restore Gate
Holding a tool no longer exempts it from the live check. Only a current tool
whose server the agent's index already lists skips it. Otherwise an unindexed
tool on a legacy agent could pass on a revoked grant the registry still
caches, and the restore would add its server to the index.
* ⚡ perf: Run Restore Admission Checks for Distinct Servers Concurrently
filterAuthorizedTools now starts every admission check during its single pass
and awaits them together, so each distinct DB-backed server no longer adds a
serial lookup wave to the revert. Tool order is preserved and server names
are recorded only for admitted tools.
* fix: Only Hand Out OpenID Access Tokens the Bearer Verifier Accepts
The OpenID reuse path in refreshController and the post-refresh fallback in
getOpenIDAppAuthToken returned the cached access token as the app auth token
whenever its exp was in the future. Entra issues Microsoft Graph access tokens
to sign-in clients by default; their aud names Graph, so the bearer verifier
rejects them and every protected request answers 401 until the client loops.
Both paths now require the access token's aud to name the client id or an
OPENID_AUDIENCE entry, the same audiences the verifier accepts. The reuse path
refreshes with the IdP instead, and the post-refresh fallback keeps opaque
tokens as before. Audience parsing is shared with openIdJwtStrategy.
Related to #17791
* test: Exercise Real OpenID Audience Helpers in AuthService Spec
The AuthService spec stubbed the audience helpers as pass-throughs, so it
could not catch a foreign-audience access token escaping the post-refresh
fallback. Use the real exports and cover Graph-audience, configured-audience
and opaque access tokens through setOpenIDAuthTokens.
* fix: Skip Attachments Deleted by Storage Retention Instead of Failing the Turn
A file that storage retention removed from an earlier message made every
later turn of the conversation fail, because the encoders rethrew the
storage miss and the user has no way to remove an attachment from history.
History replay now passes a handler to the encoders, which leave missing
files out of the request and report them; the message's file context tells
the model which files were deleted and were not read. Current-turn
attachments keep the strict error, since the user can remove and re-upload
them. Code Interpreter priming names files missing from storage in the
tool context and only requires resource recovery for other failures.
* refactor: Keep Code Reupload Failure Policy in packages/api
Tally priming reupload failures in createCodeReuploadFailures so the
decision that a file deleted from storage is named instead of requiring
resource recovery lives in TypeScript, and add mock e2e scenarios for a
follow-up after an attachment is deleted from storage.
* fix: Classify Code Files as Deleted Only at the Storage Read
A 404 from the Code API upload was counted as a source file deleted from
storage, which skipped resource recovery. openCodeFileSource marks a miss
where the stored object is read, and only that error counts as deleted.
Move the history replay of attachments with tolerated misses into
replayMessageAttachments so BaseClient only calls it.
* fix: Name Local Code Files Whose Stream Reports a Missing Object
Local storage returns a read stream that raises ENOENT only once read, so
openCodeFileSource now holds a stream until its first chunk or error and
names a miss there. The missing-files context assignment moves into
setMissingCodeFilesContext so both tool loaders only call it.
* fix: Close a Held Code File Stream When Priming Is Cancelled
openCodeFileSource waits for a source stream's first chunk; when that
wait fails, as on cancellation, the caller never receives the stream, so
destroy it before rethrowing instead of leaking its file descriptor.
* fix: Treat Empty Sandpack Bundler URLs as Unset
An empty SANDPACK_BUNDLER_URL or SANDPACK_STATIC_BUNDLER_URL (common with
${VAR:-} passthrough in Docker Compose) was handed to Sandpack as the
bundler URL, leaving artifact panels blank. buildSandpackOptions now falls
back to the default bundler for an empty value, and the shared-link startup
payload omits empty bundler URLs.
Related to #17790
* test: Cover Empty Sandpack Bundler URLs in Artifact Previews