Skip to content
中文

Explicit retry scope ​

The policy implementation follows.

ts
export async function retryMultipleModelCalls<Value>(request: {
  readonly logger?: import('../structs/debug.js').SubFlowLogger;
  readonly signal?: AbortSignal;
  readonly invoke: () => Promise<Value>;
  readonly retry: (error: unknown) => Promise<Value>;
}): Promise<Value> {
  try {
    return await request.invoke();
  } catch (error) {
    if (!getErrorInfo(error).codes.includes('MODEL_MULTIPLE_CALLS')) throw error;
    return nativeSubFlowAsync(request, 'retry', 'MODEL_MULTIPLE_CALLS', () => request.retry(error));
  }
}

API reference, usage examples and developer guides.