fix(delegate-task): retry sync tasks after runtime session errors

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Choi Kijin / 최 기진 / チョイ キジン
2026-04-28 15:28:20 +09:00
parent a4968a3d1d
commit 613e4a6c12
6 changed files with 268 additions and 37 deletions
+13 -1
View File
@@ -22,13 +22,14 @@ export async function retrySyncPromptWithFallbacks(input: {
categoryModel: DelegatedModelConfig | undefined
fallbackChain: FallbackEntry[] | undefined
sendPrompt: (categoryModel: DelegatedModelConfig) => Promise<string | null>
}): Promise<{ promptError: string | null; categoryModel: DelegatedModelConfig | undefined }> {
}): Promise<{ promptError: string | null; categoryModel: DelegatedModelConfig | undefined; fallbackState?: ModelFallbackState }> {
const { sessionID, initialError, categoryModel, fallbackChain, sendPrompt } = input
if (!categoryModel || !fallbackChain || fallbackChain.length === 0) {
return {
promptError: initialError,
categoryModel,
fallbackState: undefined,
}
}
@@ -48,6 +49,7 @@ export async function retrySyncPromptWithFallbacks(input: {
return {
promptError: finalError,
categoryModel,
fallbackState,
}
}
@@ -57,6 +59,7 @@ export async function retrySyncPromptWithFallbacks(input: {
return {
promptError: null,
categoryModel: fallbackModel,
fallbackState,
}
}
@@ -66,3 +69,12 @@ export async function retrySyncPromptWithFallbacks(input: {
fallbackState.pending = true
}
}
export function getNextSyncFallbackModel(
sessionID: string,
fallbackState: ModelFallbackState | undefined,
): DelegatedModelConfig | null {
if (!fallbackState) return null
const nextFallback = getNextReachableFallback(sessionID, fallbackState)
return nextFallback ? toDelegatedModelConfig(nextFallback) : null
}