📮 fix: Count Undelivered Background Results as Outstanding (#16343)

* 📮 fix: Count Undelivered Background Results as Outstanding

* fix: Reconcile delivered tasks, discard exactly, and count pending subagent results

* fix: Settle manually claimed remote deliveries and keep pending controls while wake-ups drain

* fix: Report dead-lettered deliveries as failed and read subagent wake-ups from the durable store

* fix: List restored dead letters and retire deliveries on local durable claims
This commit is contained in:
Danny Avila 2026-09-24 23:16:17 -04:00 • committed by GitHub
parent c6282fa888
commit 34938ebcba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1527 additions and 19 deletions

View file

@ -1,9 +1,14 @@
const {
createBackgroundToolCompletionWakeupHandler,
createBackgroundToolDeadClaimRecovery,
createPendingBackgroundCompletions,
createBackgroundToolResultHandler,
claimBackgroundToolResult: claimResult,
} = require('@librechat/api');
const {
listPendingAgentBackgroundToolCompletions,
listUndeliveredAgentTriggerTaskIds,
} = require('~/models');
const {
enqueueAgentTrigger,
persistAgentBackgroundToolResult,
@ -23,6 +28,12 @@ const preregisterBackgroundToolCompletion = createBackgroundToolCompletionWakeup
(deliveryKey) => expediteCompletionWakeups({ deliveryKeys: [deliveryKey] }),
);
const pendingBackgroundToolCompletions = createPendingBackgroundCompletions({
list: listPendingAgentBackgroundToolCompletions,
listTaskIds: listUndeliveredAgentTriggerTaskIds,
retire: retireAgentTrigger,
});
function createBackgroundToolResultPersistence({ req, updateToolCallResult }) {
return createBackgroundToolResultHandler({ req, updateToolCallResult });
}
@ -46,6 +57,7 @@ function createDeadBackgroundToolClaimRecovery(
module.exports = {
preregisterBackgroundToolCompletion,
pendingBackgroundToolCompletions,
createBackgroundToolResultPersistence,
claimBackgroundToolResult,
createDeadBackgroundToolClaimRecovery,

View file

@ -94,6 +94,7 @@ const { processAddedConvo } = require('./addedConvo');
const subagentThreadTaskStore = require('./subagentThreadStore');
const {
preregisterBackgroundToolCompletion,
pendingBackgroundToolCompletions,
createBackgroundToolResultPersistence,
claimBackgroundToolResult,
createDeadBackgroundToolClaimRecovery,
@ -517,6 +518,8 @@ const initializeClientWithProvider = async ({
}),
backgroundToolCompletion: {
...(completionWakeupsEnabled ? { preregister: preregisterBackgroundToolCompletion } : {}),
/** Deliveries admitted before wake-ups were disabled still drain and still count. */
pending: pendingBackgroundToolCompletions,
persist: createBackgroundToolResultPersistence({
req,
updateToolCallResult: db.updateToolCallResult,