Commit 83c02c97 by YeYuheng Committed by GitHub

fix: step-retry-error (#6829)

* step-retry-error

* error output

* doc

* lock

---------

Co-authored-by: archer <545436317@qq.com>
parent 423607ab
...@@ -15,9 +15,10 @@ description: 'FastGPT V4.15.0 更新说明' ...@@ -15,9 +15,10 @@ description: 'FastGPT V4.15.0 更新说明'
## 🐛 修复 ## 🐛 修复
1. 修复 Agent v2 模式下,模型响应报错会导致 step 重复执行
## 代码优化 ## 代码优化
1. 重新调整代码结构,升级 nextjs 最新版,切换至 turbopack 构建,提高构建速度;升级容器默认 node 至 24。 1. 重新调整代码结构,升级 nextjs 最新版,切换至 turbopack 构建,提高构建速度;升级容器默认 node 至 24。
2. 优化 Agent tool 声明和运行,统一所有 tool 的声明和运行方式。 2. 优化 Agent tool 声明和运行,统一所有 tool 的声明和运行方式。
3. 文件上传内容从 system prompt 中放到 user message 中,提高 cache 命中率 3. 文件上传内容从 system prompt 中放到 user message 中,提高 cache 命中率
\ No newline at end of file
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
"content/self-host/upgrading/4-14/41481.mdx": "2026-04-26T21:08:47+08:00", "content/self-host/upgrading/4-14/41481.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/4-14/4149.en.mdx": "2026-04-26T21:08:47+08:00", "content/self-host/upgrading/4-14/4149.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/4-14/4149.mdx": "2026-04-26T21:08:47+08:00", "content/self-host/upgrading/4-14/4149.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/4-15/4150.mdx": "2026-04-24T13:02:20+08:00", "content/self-host/upgrading/4-15/4150.mdx": "2026-04-28T13:31:00+08:00",
"content/self-host/upgrading/outdated/40.en.mdx": "2026-04-26T21:08:47+08:00", "content/self-host/upgrading/outdated/40.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/outdated/40.mdx": "2026-04-26T21:08:47+08:00", "content/self-host/upgrading/outdated/40.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/outdated/41.en.mdx": "2026-04-26T21:08:47+08:00", "content/self-host/upgrading/outdated/41.en.mdx": "2026-04-26T21:08:47+08:00",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
"postcss": "^8.5.10", "postcss": "^8.5.10",
"tailwindcss": "^4.1.11", "tailwindcss": "^4.1.11",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"zhlint": "^0.8.2",
"zod": "^4.0.5" "zod": "^4.0.5"
} }
} }
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
DispatchNodeResponseKeyEnum, DispatchNodeResponseKeyEnum,
SseResponseEventEnum SseResponseEventEnum
} from '@fastgpt/global/core/workflow/runtime/constants'; } from '@fastgpt/global/core/workflow/runtime/constants';
import { textAdaptGptResponse } from '@fastgpt/global/core/workflow/runtime/utils';
import type { import type {
DispatchNodeResultType, DispatchNodeResultType,
ModuleDispatchProps ModuleDispatchProps
...@@ -45,6 +46,7 @@ import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type ...@@ -45,6 +46,7 @@ import type { AppFormEditFormType } from '@fastgpt/global/core/app/formEdit/type
import { getLogger, LogCategories } from '../../../../../common/logger'; import { getLogger, LogCategories } from '../../../../../common/logger';
import { env } from '../../../../../env'; import { env } from '../../../../../env';
import { dispatchPiAgent } from './piAgent'; import { dispatchPiAgent } from './piAgent';
import { i18nT } from '../../../../../../web/i18n/utils';
export type DispatchAgentModuleProps = ModuleDispatchProps<{ export type DispatchAgentModuleProps = ModuleDispatchProps<{
[NodeInputKeyEnum.history]?: ChatItemMiniType[]; [NodeInputKeyEnum.history]?: ChatItemMiniType[];
...@@ -477,8 +479,50 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise ...@@ -477,8 +479,50 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise
filesMap, filesMap,
capabilityToolCallHandler capabilityToolCallHandler
}); });
const stepCallErrorText =
result.nodeResponse.errorText?.trim() ||
(result.nodeResponse.finishReason === 'error'
? i18nT('chat:completion_finish_error')
: '');
nodeResponses.push(result.nodeResponse); nodeResponses.push(result.nodeResponse);
if (stepCallErrorText) {
assistantResponses.push({
text: { content: stepCallErrorText },
planId: agentPlan.planId,
stepId: step.id
});
workflowStreamResponse?.({
stepId: step.id,
event: SseResponseEventEnum.answer,
data: textAdaptGptResponse({ text: stepCallErrorText })
});
const answerText = assistantResponses
.filter((item) => item.text?.content)
.map((item) => item.text!.content)
.join('');
return {
data: {
[NodeOutputKeyEnum.answerText]: answerText
},
error: {
[NodeOutputKeyEnum.errorText]: stepCallErrorText
},
[DispatchNodeResponseKeyEnum.memories]: {
[masterMessagesKey]: undefined,
[agentPlanKey]: undefined,
[planMessagesKey]: undefined,
[planBufferKey]: undefined
},
[DispatchNodeResponseKeyEnum.assistantResponses]: assistantResponses,
[DispatchNodeResponseKeyEnum.nodeResponses]: nodeResponses,
[DispatchNodeResponseKeyEnum.toolResponses]: stepCallErrorText
};
}
// Merge response // Merge response
const assistantResponse = GPTMessages2Chats({ const assistantResponse = GPTMessages2Chats({
messages: result.assistantMessages, messages: result.assistantMessages,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment