fix: 支持模型异常后继续文档对话
- 将本轮文档上下文纳入可持久化的 Agent 用户消息 =- 在异常提示中提供请重试动作并自动发送继续
This commit is contained in:
@@ -181,6 +181,57 @@ describe('agentChatRuntimeManager', () => {
|
||||
expect(agentChatRuntimeManager.getSnapshot('101')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('输入已确认后将模型错误转换为可重试的用户提示', async () => {
|
||||
let resolveRun: (() => void) | undefined;
|
||||
let runOptions: EasyFlowAguiRunOptions | undefined;
|
||||
aguiMocks.run.mockImplementation((options: EasyFlowAguiRunOptions) => {
|
||||
runOptions = options;
|
||||
return new Promise<void>((resolve) => {
|
||||
resolveRun = resolve;
|
||||
});
|
||||
});
|
||||
useUserStore().setUserInfo({
|
||||
avatar: '',
|
||||
id: 'retry-user',
|
||||
loginName: 'retry-user',
|
||||
nickname: '重试用户',
|
||||
tenantId: 'tenant-1',
|
||||
});
|
||||
|
||||
await agentChatRuntimeManager.start({
|
||||
agentId: 'agent-1',
|
||||
prompt: '介绍文档',
|
||||
sessionId: 'retry-session',
|
||||
});
|
||||
runOptions?.onEvent({
|
||||
name: easyFlowAguiCustomEvent.inputAccepted,
|
||||
type: EventType.CUSTOM,
|
||||
value: {},
|
||||
});
|
||||
runOptions?.onEvent({
|
||||
code: 'MODEL_ERROR',
|
||||
message: 'Retries exhausted: 2/2',
|
||||
runId: 'run-test',
|
||||
threadId: 'retry-session',
|
||||
type: EventType.RUN_ERROR,
|
||||
});
|
||||
resolveRun?.();
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
|
||||
const snapshot = agentChatRuntimeManager.getSnapshot('retry-session');
|
||||
expect(snapshot).toEqual(
|
||||
expect.objectContaining({
|
||||
error: '模型连接异常',
|
||||
retryContextReady: true,
|
||||
terminalOutcome: 'failed',
|
||||
}),
|
||||
);
|
||||
expect(snapshot?.items.find((item) => item.type === 'error')).toEqual(
|
||||
expect.objectContaining({ message: '模型连接异常' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('刷新恢复已确认输入时重新触发草稿清理回调', async () => {
|
||||
const account = {
|
||||
avatar: '',
|
||||
|
||||
Reference in New Issue
Block a user