From 655dffbc2a12cc41dfd149f7fc7799362c35f228 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 20 May 2026 12:30:02 +0900 Subject: [PATCH] fix(team-mode): release reservation on ambiguous failure, commit on success-path mark failure Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/features/team-mode/tools/messaging.ts | 33 +++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/features/team-mode/tools/messaging.ts b/src/features/team-mode/tools/messaging.ts index 338c6713a..7f8a66367 100644 --- a/src/features/team-mode/tools/messaging.ts +++ b/src/features/team-mode/tools/messaging.ts @@ -10,6 +10,7 @@ import { isAmbiguousPostDispatchPromptFailure } from "../../../shared/prompt-fai import { applyMemberSessionRouting, buildMemberPromptBody } from "../member-session-routing" import { buildEnvelope } from "../team-mailbox/poll" import { + commitDeliveryReservation, releaseDeliveryReservation, reserveMessageForDelivery, } from "../team-mailbox/reservation" @@ -275,19 +276,12 @@ async function deliverLive( }, }) if (promptResult.status === "failed" && isAmbiguousPostDispatchPromptFailure(promptResult)) { - try { - await markLiveDeliveryPending(teamRunId, recipientName, message.messageId, config) - } catch (markError) { - log("[team-mailbox] live delivery prompt may be accepted but pending mark failed, keeping reservation hidden", { - teamRunId, - recipient: recipientName, - recipientSessionId, - messageId: message.messageId, - error: markError instanceof Error ? markError.message : String(markError), - }) - continue - } - log("[team-mailbox] live delivery prompt failed after dispatch attempt, keeping reservation pending", { + await releaseReservationSafely(reservation, { + teamRunId, + recipient: recipientName, + messageId: message.messageId, + }) + log("[team-mailbox] live delivery prompt failed ambiguously, released reservation to inbox", { teamRunId, recipient: recipientName, recipientSessionId, @@ -314,7 +308,18 @@ async function deliverLive( try { await markLiveDeliveryPending(teamRunId, recipientName, message.messageId, config) } catch (markError) { - log("[team-mailbox] live delivery prompt dispatched but pending mark failed, keeping reservation hidden", { + try { + await commitDeliveryReservation(reservation) + } catch (commitError) { + log("[team-mailbox] live delivery prompt dispatched but pending mark and reservation commit failed", { + teamRunId, + recipient: recipientName, + recipientSessionId, + messageId: message.messageId, + error: commitError instanceof Error ? commitError.message : String(commitError), + }) + } + log("[team-mailbox] live delivery prompt dispatched but pending mark failed, committed reservation directly", { teamRunId, recipient: recipientName, recipientSessionId,