fix(team-mode): preserve live delivery holds after ambiguous prompt failure

This commit is contained in:
YeonGyu-Kim
2026-05-19 13:49:01 +09:00
parent bb75751410
commit 7db3a7f933
2 changed files with 70 additions and 0 deletions
+31
View File
@@ -68,6 +68,26 @@ const TeamSendMessageArgsSchema = z.object({
type DeliveryReservation = Awaited<ReturnType<typeof reserveMessageForDelivery>>
function extractPromptFailureMessage(error: unknown): string {
if (typeof error === "string") return error
if (error instanceof Error) return error.message
if (typeof error === "object" && error !== null) {
const record = error as Record<string, unknown>
if (typeof record.message === "string") return record.message
try {
return JSON.stringify(error)
} catch {
return ""
}
}
return String(error)
}
function shouldKeepReservationAfterFailedLivePrompt(error: unknown): boolean {
const message = extractPromptFailureMessage(error)
return message.includes("Unexpected EOF") || message.includes("timed out")
}
async function resolveTeamRuntimeDetails(
teamRunId: string,
sessionID: string,
@@ -210,6 +230,17 @@ async function deliverLive(
query: { directory: recipientMember.worktreePath ?? directory },
},
})
if (promptResult.status === "failed" && shouldKeepReservationAfterFailedLivePrompt(promptResult.error)) {
await markLiveDeliveryPending(teamRunId, recipientName, message.messageId, config)
log("[team-mailbox] live delivery prompt failed after dispatch attempt, keeping reservation pending", {
teamRunId,
recipient: recipientName,
recipientSessionId,
messageId: message.messageId,
error: promptResult.error instanceof Error ? promptResult.error.message : String(promptResult.error),
})
continue
}
if (promptResult.status !== "dispatched") {
log("[team-mailbox] live delivery skipped by promptAsync gate, falling back to inbox injection", {
status: promptResult.status,