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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -10,6 +10,7 @@ import { isAmbiguousPostDispatchPromptFailure } from "../../../shared/prompt-fai
|
|||||||
import { applyMemberSessionRouting, buildMemberPromptBody } from "../member-session-routing"
|
import { applyMemberSessionRouting, buildMemberPromptBody } from "../member-session-routing"
|
||||||
import { buildEnvelope } from "../team-mailbox/poll"
|
import { buildEnvelope } from "../team-mailbox/poll"
|
||||||
import {
|
import {
|
||||||
|
commitDeliveryReservation,
|
||||||
releaseDeliveryReservation,
|
releaseDeliveryReservation,
|
||||||
reserveMessageForDelivery,
|
reserveMessageForDelivery,
|
||||||
} from "../team-mailbox/reservation"
|
} from "../team-mailbox/reservation"
|
||||||
@@ -275,19 +276,12 @@ async function deliverLive(
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (promptResult.status === "failed" && isAmbiguousPostDispatchPromptFailure(promptResult)) {
|
if (promptResult.status === "failed" && isAmbiguousPostDispatchPromptFailure(promptResult)) {
|
||||||
try {
|
await releaseReservationSafely(reservation, {
|
||||||
await markLiveDeliveryPending(teamRunId, recipientName, message.messageId, config)
|
teamRunId,
|
||||||
} catch (markError) {
|
recipient: recipientName,
|
||||||
log("[team-mailbox] live delivery prompt may be accepted but pending mark failed, keeping reservation hidden", {
|
messageId: message.messageId,
|
||||||
teamRunId,
|
})
|
||||||
recipient: recipientName,
|
log("[team-mailbox] live delivery prompt failed ambiguously, released reservation to inbox", {
|
||||||
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", {
|
|
||||||
teamRunId,
|
teamRunId,
|
||||||
recipient: recipientName,
|
recipient: recipientName,
|
||||||
recipientSessionId,
|
recipientSessionId,
|
||||||
@@ -314,7 +308,18 @@ async function deliverLive(
|
|||||||
try {
|
try {
|
||||||
await markLiveDeliveryPending(teamRunId, recipientName, message.messageId, config)
|
await markLiveDeliveryPending(teamRunId, recipientName, message.messageId, config)
|
||||||
} catch (markError) {
|
} 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,
|
teamRunId,
|
||||||
recipient: recipientName,
|
recipient: recipientName,
|
||||||
recipientSessionId,
|
recipientSessionId,
|
||||||
|
|||||||
Reference in New Issue
Block a user