Skip to content

Commit 61ed709

Browse files
authored
Add sandbox limit and fix some issue (#6550)
* sandbox in plan * fix: some issue * fix: test
1 parent fdb256a commit 61ed709

File tree

29 files changed

+347
-100
lines changed

29 files changed

+347
-100
lines changed

document/content/docs/self-host/upgrading/4-14/4149.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ AGENT_SANDBOX_SEALOS_TOKEN=
2525

2626
1. 新增 AI 虚拟机功能,可以给 AI 挂载一个虚拟机工具进行更丰富的操作。
2727
2. 封装 logger sdk。
28+
3. 更新知识库数据时候,同步更新 collection 更新时间。
2829

2930
## ⚙️ 优化
3031

@@ -36,4 +37,5 @@ AGENT_SANDBOX_SEALOS_TOKEN=
3637
1. 工作流变量值,包含特殊值($.)的时候,导致值替换异常。
3738
2. 工作流引用 agent 工具时,获取版本异常。
3839
3. 工作流嵌套插件时,未成功保留插件运行详情。同时整理所有 tool 类型前缀。
39-
4. 更新 MCP toolset 后可能无法正常调用。
40+
4. 更新 MCP toolset 后可能无法正常调用。
41+
5. 不支持某些属性的参数的模型,从支持该参数的模型切换过来时,该模型未被去掉,导致模型调用失败。

document/data/doc-last-modified.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@
7979
"document/content/docs/introduction/guide/dashboard/workflow/question_classify.mdx": "2025-07-23T21:35:03+08:00",
8080
"document/content/docs/introduction/guide/dashboard/workflow/reply.en.mdx": "2026-02-26T22:14:30+08:00",
8181
"document/content/docs/introduction/guide/dashboard/workflow/reply.mdx": "2025-07-23T21:35:03+08:00",
82-
"document/content/docs/introduction/guide/dashboard/workflow/sandbox-v2.en.mdx": "2026-03-10T16:00:22+08:00",
83-
"document/content/docs/introduction/guide/dashboard/workflow/sandbox-v2.mdx": "2026-03-10T16:00:22+08:00",
84-
"document/content/docs/introduction/guide/dashboard/workflow/sandbox.en.mdx": "2026-03-10T16:00:22+08:00",
85-
"document/content/docs/introduction/guide/dashboard/workflow/sandbox.mdx": "2026-03-10T16:00:22+08:00",
82+
"document/content/docs/introduction/guide/dashboard/workflow/sandbox-v2.en.mdx": "2026-03-11T15:10:01+08:00",
83+
"document/content/docs/introduction/guide/dashboard/workflow/sandbox-v2.mdx": "2026-03-11T15:10:01+08:00",
84+
"document/content/docs/introduction/guide/dashboard/workflow/sandbox.en.mdx": "2026-03-11T15:10:01+08:00",
85+
"document/content/docs/introduction/guide/dashboard/workflow/sandbox.mdx": "2026-03-11T15:10:01+08:00",
8686
"document/content/docs/introduction/guide/dashboard/workflow/text_editor.en.mdx": "2026-02-26T22:14:30+08:00",
8787
"document/content/docs/introduction/guide/dashboard/workflow/text_editor.mdx": "2025-07-23T21:35:03+08:00",
8888
"document/content/docs/introduction/guide/dashboard/workflow/tfswitch.en.mdx": "2026-02-26T22:14:30+08:00",
@@ -137,8 +137,8 @@
137137
"document/content/docs/introduction/opensource/license.mdx": "2026-03-03T17:39:47+08:00",
138138
"document/content/docs/openapi/app.en.mdx": "2026-02-26T22:14:30+08:00",
139139
"document/content/docs/openapi/app.mdx": "2026-02-12T18:45:30+08:00",
140-
"document/content/docs/openapi/chat.en.mdx": "2026-03-05T15:30:51+08:00",
141-
"document/content/docs/openapi/chat.mdx": "2026-03-05T15:30:51+08:00",
140+
"document/content/docs/openapi/chat.en.mdx": "2026-03-11T15:10:01+08:00",
141+
"document/content/docs/openapi/chat.mdx": "2026-03-11T15:10:01+08:00",
142142
"document/content/docs/openapi/dataset.en.mdx": "2026-02-26T22:14:30+08:00",
143143
"document/content/docs/openapi/dataset.mdx": "2026-02-12T18:45:30+08:00",
144144
"document/content/docs/openapi/index.en.mdx": "2026-02-26T22:14:30+08:00",
@@ -235,7 +235,7 @@
235235
"document/content/docs/self-host/upgrading/4-14/4148.mdx": "2026-03-09T17:39:53+08:00",
236236
"document/content/docs/self-host/upgrading/4-14/41481.en.mdx": "2026-03-09T12:02:02+08:00",
237237
"document/content/docs/self-host/upgrading/4-14/41481.mdx": "2026-03-09T17:39:53+08:00",
238-
"document/content/docs/self-host/upgrading/4-14/4149.mdx": "2026-03-11T23:15:17+08:00",
238+
"document/content/docs/self-host/upgrading/4-14/4149.mdx": "2026-03-11T15:10:01+08:00",
239239
"document/content/docs/self-host/upgrading/outdated/40.en.mdx": "2026-03-03T17:39:47+08:00",
240240
"document/content/docs/self-host/upgrading/outdated/40.mdx": "2026-03-03T17:39:47+08:00",
241241
"document/content/docs/self-host/upgrading/outdated/41.en.mdx": "2026-03-03T17:39:47+08:00",
@@ -300,8 +300,8 @@
300300
"document/content/docs/self-host/upgrading/outdated/48.mdx": "2026-03-03T17:39:47+08:00",
301301
"document/content/docs/self-host/upgrading/outdated/481.en.mdx": "2026-03-03T17:39:47+08:00",
302302
"document/content/docs/self-host/upgrading/outdated/481.mdx": "2026-03-03T17:39:47+08:00",
303-
"document/content/docs/self-host/upgrading/outdated/4810.en.mdx": "2026-03-10T16:00:22+08:00",
304-
"document/content/docs/self-host/upgrading/outdated/4810.mdx": "2026-03-10T16:00:22+08:00",
303+
"document/content/docs/self-host/upgrading/outdated/4810.en.mdx": "2026-03-11T15:10:01+08:00",
304+
"document/content/docs/self-host/upgrading/outdated/4810.mdx": "2026-03-11T15:10:01+08:00",
305305
"document/content/docs/self-host/upgrading/outdated/4811.en.mdx": "2026-03-03T17:39:47+08:00",
306306
"document/content/docs/self-host/upgrading/outdated/4811.mdx": "2026-03-03T17:39:47+08:00",
307307
"document/content/docs/self-host/upgrading/outdated/4812.en.mdx": "2026-03-03T17:39:47+08:00",
@@ -320,8 +320,8 @@
320320
"document/content/docs/self-host/upgrading/outdated/4818.mdx": "2026-03-03T17:39:47+08:00",
321321
"document/content/docs/self-host/upgrading/outdated/4819.en.mdx": "2026-03-03T17:39:47+08:00",
322322
"document/content/docs/self-host/upgrading/outdated/4819.mdx": "2026-03-03T17:39:47+08:00",
323-
"document/content/docs/self-host/upgrading/outdated/482.en.mdx": "2026-03-10T16:00:22+08:00",
324-
"document/content/docs/self-host/upgrading/outdated/482.mdx": "2026-03-10T16:00:22+08:00",
323+
"document/content/docs/self-host/upgrading/outdated/482.en.mdx": "2026-03-11T15:10:01+08:00",
324+
"document/content/docs/self-host/upgrading/outdated/482.mdx": "2026-03-11T15:10:01+08:00",
325325
"document/content/docs/self-host/upgrading/outdated/4820.en.mdx": "2026-03-03T17:39:47+08:00",
326326
"document/content/docs/self-host/upgrading/outdated/4820.mdx": "2026-03-03T17:39:47+08:00",
327327
"document/content/docs/self-host/upgrading/outdated/4821.en.mdx": "2026-03-03T17:39:47+08:00",
@@ -408,4 +408,4 @@
408408
"document/content/docs/use-cases/external-integration/wecom.mdx": "2025-12-10T20:07:05+08:00",
409409
"document/content/docs/use-cases/index.en.mdx": "2026-02-26T22:14:30+08:00",
410410
"document/content/docs/use-cases/index.mdx": "2025-07-24T14:23:04+08:00"
411-
}
411+
}

packages/global/common/error/code/team.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import type { ErrType } from '../errorCode';
33
/* team: 500000 */
44
export enum TeamErrEnum {
55
notUser = 'notUser',
6-
teamOverSize = 'teamOverSize',
76
unAuthTeam = 'unAuthTeam',
7+
8+
teamOverSize = 'teamOverSize',
89
teamMemberOverSize = 'teamMemberOverSize',
910
aiPointsNotEnough = 'aiPointsNotEnough',
1011
datasetSizeNotEnough = 'datasetSizeNotEnough',
@@ -15,6 +16,8 @@ export enum TeamErrEnum {
1516
websiteSyncNotEnough = 'websiteSyncNotEnough',
1617
reRankNotEnough = 'reRankNotEnough',
1718
ticketNotAvailable = 'ticketNotAvailable',
19+
sandboxNotSupport = 'sandboxNotSupport',
20+
1821
groupNameEmpty = 'groupNameEmpty',
1922
groupNameDuplicate = 'groupNameDuplicate',
2023
groupNotExist = 'groupNotExist',
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1+
import type { LLMModelItemType } from '../model.schema';
2+
13
export const removeDatasetCiteText = (text: string, retainDatasetCite: boolean) => {
24
return retainDatasetCite
35
? text.replace(/[\[]id[\]]\(CITE\)/g, '')
46
: text
57
.replace(/[\[]([a-f0-9]{24})[\]](?:\([^\)]*\)?)?/g, '')
68
.replace(/[\[]id[\]]\(CITE\)/g, '');
79
};
10+
11+
export const getLLMSupportParams = (llm?: LLMModelItemType) => {
12+
return {
13+
vision: !!llm?.vision,
14+
temperature: typeof llm?.maxTemperature === 'number',
15+
reasoning: !!llm?.reasoning,
16+
topP: !!llm?.showTopP,
17+
stop: !!llm?.showStopSign,
18+
responseFormat: !!(llm?.responseFormatList && llm?.responseFormatList.length > 0),
19+
supportToolCall: !!(llm?.toolChoice || llm?.functionCall)
20+
};
21+
};

packages/global/support/wallet/sub/type.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const TeamStandardSubPlanItemSchema = z.object({
2525
maxUploadFileSize: z.int().optional(), // 最大上传文件大小(MB)
2626
maxUploadFileCount: z.int().optional(), // 最大上传文件数量
2727

28+
enableSandbox: z.boolean().optional(), // 虚拟机
29+
2830
// 定制套餐
2931
priceDescription: z.string().optional(), // 价格描述
3032
customFormUrl: z.string().optional(), // 自定义表单 URL
@@ -101,7 +103,8 @@ export const TeamSubSchema = z.object({
101103
ticketResponseTime: z.int().optional(),
102104
customDomain: z.int().optional(),
103105
maxUploadFileSize: z.int().optional(),
104-
maxUploadFileCount: z.int().optional()
106+
maxUploadFileCount: z.int().optional(),
107+
enableSandbox: z.boolean().optional() // 虚拟机
105108
});
106109
export type TeamSubSchemaType = z.infer<typeof TeamSubSchema>;
107110

packages/service/common/bullmq/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export enum QueueNames {
2727
datasetSync = 'datasetSync',
2828
evaluation = 'evaluation',
2929
s3FileDelete = 's3FileDelete',
30+
collectionUpdate = 'collectionUpdate',
3031

3132
// Delete Queue
3233
datasetDelete = 'datasetDelete',

packages/service/core/ai/llm/agentCall/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export const runAgentCall = async ({
275275
throwError: false,
276276
body: {
277277
...body,
278+
max_tokens,
278279
model,
279280
messages: requestMessages,
280281
tool_choice: consecutiveRequestToolTimes > 5 ? 'none' : 'auto',

packages/service/core/ai/llm/compress/index.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,6 @@ export const compressToolResponse = async ({
442442
// 取静态阈值和动态可用空间的较小值
443443
const maxTokens = Math.min(staticMaxTokens, availableSpace);
444444

445-
logger.debug('Tool Response Compression', {
446-
responseTokens: await countGptMessagesTokens([{ role: 'user', content: response }]),
447-
currentMessagesTokens,
448-
maxContext: model.maxContext,
449-
reservedTokens,
450-
availableSpace,
451-
staticMaxTokens,
452-
finalMaxTokens: maxTokens
453-
});
454-
455445
// 调用通用压缩函数
456446
return compressLargeContent({
457447
content: response,

packages/service/core/ai/llm/request.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
parseLLMStreamResponse,
1717
parseReasoningContent
1818
} from '../utils';
19-
import { removeDatasetCiteText } from '@fastgpt/global/core/ai/llm/utils';
19+
import { getLLMSupportParams, removeDatasetCiteText } from '@fastgpt/global/core/ai/llm/utils';
2020
import { getAIApi } from '../config';
2121
import type { OpenaiAccountType } from '@fastgpt/global/support/user/team/type';
2222
import { customNanoid, getNanoid } from '@fastgpt/global/common/string/tools';
@@ -772,6 +772,21 @@ const llmCompletionsBodyFormat = async <T extends CompletionsBodyType>({
772772
Object.entries(requestBody).filter(([_, value]) => value !== null && value !== undefined)
773773
) as T;
774774

775+
const supportParams = getLLMSupportParams(modelData);
776+
777+
if (!supportParams.temperature) {
778+
delete requestBody.temperature;
779+
}
780+
if (!supportParams.topP) {
781+
delete requestBody.top_p;
782+
}
783+
if (!supportParams.stop) {
784+
delete requestBody.stop;
785+
}
786+
if (!supportParams.responseFormat) {
787+
delete requestBody.response_format;
788+
}
789+
775790
// field map
776791
if (modelData.fieldMap) {
777792
Object.entries(modelData.fieldMap).forEach(([sourceKey, targetKey]) => {

packages/service/core/ai/sandbox/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class SandboxClient {
101101
} catch (err) {
102102
return {
103103
stdout: '',
104-
stderr: 'Sandbox service is not available, please try again later',
104+
stderr: `Sandbox service is not available: ${getErrText(err)}`,
105105
exitCode: -1
106106
};
107107
}

0 commit comments

Comments
 (0)