retryMultipleModelCalls
CORE · function · Runtime value
Retry once when the failure is a rejected multi-call proposal.
Only the MODEL_MULTIPLE_CALLS code is retried; every other failure is rethrown unchanged. The caller owns the fallback prompt and the budget it consumes.
Import
ts
import { retryMultipleModelCalls } from '@jangts/agent-core/support';js
import { retryMultipleModelCalls } from '@jangts/agent-core/support';Other public entry points:@jangts/agent-core/support.
Definition
Type parameters
| Type parameter | Constraint | Default type |
|---|---|---|
Value | — | — |
Call
ts
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>Retry once when the failure is a rejected multi-call proposal.
Only the MODEL_MULTIPLE_CALLS code is retried; every other failure is rethrown unchanged. The caller owns the fallback prompt and the budget it consumes.
| Type parameter | Constraint | Default type |
|---|---|---|
Value | — | — |
| Parameter | Type | Passing | Description |
|---|---|---|---|
request | { readonly logger?: import("../structs/debug.js").SubFlowLogger; readonly signal?: AbortSignal; readonly invoke: () => Promise<Value>; readonly retry: (error: unknown) => Promise<Value>; } | Required | — |
Fields of request
| Field | Type | Required | Description |
|---|---|---|---|
logger | SubFlowLogger | undefined | Optional | Read-only. See the type definition and usage context. |
signal | AbortSignal | undefined | Optional | Read-only. See the type definition and usage context. |
invoke | () => Promise<Value> | Required | Read-only. See the type definition and usage context. |
retry | (error: unknown) => Promise<Value> | Required | Read-only. See the type definition and usage context. |
Returns: Promise<Value>.
Awaited value: Awaited<Value>.
Examples
- Explicit fallback only when a specific model protocol fails: Handle unsupported parallel proposals without taking over all of the App's retries and business errors.
A normal call keeps the same return contract
Beginner · Node.js
ts
import { ModelRunner, Support } from '@jangts/agent-core';
const runner = new ModelRunner({ provider: { async *stream() { yield '服务正常'; } }, maxCalls: 2 });
const result = await Support.retryMultipleModelCalls({
invoke: () => runner.invoke('查询服务状态'),
retry: () => runner.invoke('只选择一个服务状态结论'),
});
console.log(result.value);js
import { ModelRunner, Support } from '@jangts/agent-core';
const runner = new ModelRunner({ provider: { async *stream() { yield '服务正常'; } }, maxCalls: 2 });
const result = await Support.retryMultipleModelCalls({
invoke: () => runner.invoke('查询服务状态'),
retry: () => runner.invoke('只选择一个服务状态结论'),
});
console.log(result.value);Business rejections are not treated as automatic retry conditions
Configuration · Node.js
ts
import { Support } from '@jangts/agent-core';
try {
await Support.retryMultipleModelCalls({
invoke: async () => { throw new Error('当前请求没有权限'); },
retry: async () => '此回退不会被执行',
});
} catch (error) { console.log((error as Error).message); }js
import { Support } from '@jangts/agent-core';
try {
await Support.retryMultipleModelCalls({
invoke: async () => { throw new Error('当前请求没有权限'); },
retry: async () => '此回退不会被执行',
});
}
catch (error) {
console.log(error.message);
}