例行检查
[//]: # '方框内填 x 表示打钩'
你的版本
问题描述, 日志截图,配置文件等
环境:Kubernetes 部署
- Opensandbox‑server:官方 helm chart,tag
sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/server:v0.2.2
- Volume‑manager image:
ghcr.io/labring/fastgpt-agent-volume-manager:v0.3.1
FastGPT Pod 内环境变量(exec 进 pod 执行 env 已确认变量真实存在):
AGENT_SANDBOX_PROVIDER=opensandbox
AGENT_SANDBOX_ENABLE_VOLUME=false
AGENT_SANDBOX_OPENSANDBOX_BASEURL=http://opensandbox-server.opensandbox-system.svc.cluster.local
AGENT_SANDBOX_OPENSANDBOX_VOLUME_MANAGER_URL=http://fastgpt-agent-volume-manager
AGENT_SANDBOX_OPENSANDBOX_VOLUME_MANAGER_TOKEN=xxxxxxxxxxxxxx
AGENT_SANDBOX_OPENSANDBOX_VOLUME_NAME_PREFIX=fastgpt-session
创建 skill‑sandbox 时,FastGPT 本地抛出 Zod 校验错误:claimName expected string, got undefined。日志可见 rawBody: undefined。
完全没有向 volume‑manager 发出网络请求,失败发生在 FastGPT 后端进程内部。
实际报错堆栈:
2026-09-04 14:51:19 ERR ai:agent [Sandbox] Failed to create sandbox: {
error: Error: volume-manager error: 400 {"error":"Invalid request body","details":[{"expected":"string","code":"invalid_type","path":["claimName"],"message":"Invalid input: expected string, received undefined"}]}
at o (.next/server/chunks/[root-of-the-server]__12009f0._.js:2:63565)
at async d (.next/server/chunks/[root-of-the-server]__12009f0._.js:2:64143)
at async b (.next/server/chunks/[root-of-the-server]__041p67q._.js:1:3192)
at async F (.next/server/chunks/packages_service_core_ai_sandbox_0cv544u._.js:1:10003)
at async h (.next/server/chunks/[root-of-the-server]__06xco2v._.js:1:17429)
at async Module.m [as handler] (.next/server/chunks/[root-of-the-server]__06xco2v._.js:1:19836),
rawBody: undefined
}
根因分析:
packages/service/common/config/sandbox.ts 使用 IIFE,模块加载时一次性读取 process.env。K8s 存在启动时序问题:Node 模块初始化瞬间,环境变量还未就绪,agentSandboxConfig.openSandbox.volumeNamePrefix 被捕获为 undefined。后续容器 env 已经就绪,但模块缓存的 config 对象不会刷新,永久为 undefined。
packages/service/core/ai/sandbox/skillSandbox.ts skill‑sandbox 创建逻辑缺失 enableVolume 判断守卫。即使关闭 volume,依然无条件调用 createVolume()。Agent‑sandbox 有该守卫,行为正常。
createVolume() 将缓存 config 中原始 undefined 值直接传给 Zod schema 的 claimName 字段,Zod 本地校验失败,没有执行字符串模板拼接、uuid 生成,也无网络请求。
JS 模板字符串 ${undefined}-uuid 会生成字符串 "undefined‑uuid",可以通过 z.string()。报错说明传入 Zod 的是 JS 原生 undefined,没有做插值。
复现步骤
- K8s 部署 FastGPT v4.15.7,provider=opensandbox,设置
AGENT_SANDBOX_ENABLE_VOLUME=false,配置好 AGENT_SANDBOX_OPENSANDBOX_VOLUME_NAME_PREFIX。
- 尝试创建 skill‑sandbox。
- 直接触发 Zod
claimName expected string, got undefined 错误,无请求到 volume‑manager。
预期结果
- skill‑sandbox 应当和 agent‑sandbox 保持一致:当
enableVolume=false,直接跳过 volume‑manager 客户端全部逻辑,不执行 Zod 校验。
- 配置不应该只在模块加载瞬间读取 env,应运行时读取,规避 K8s 环境变量注入时序竞态。
相关截图
请求:希望可以在 v4.15.x 分支做向后移植修复:
- 在
skillSandbox.ts 添加 enableVolume 判断守卫,volume 关闭时跳过 volume‑manager 调用。
- 优化 sandbox config 读取逻辑,避免模块加载时一次性捕获 env,缓解 K8s 时序问题。
例行检查
[//]: # '方框内填 x 表示打钩'
你的版本
问题描述, 日志截图,配置文件等
环境:Kubernetes 部署
sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/server:v0.2.2ghcr.io/labring/fastgpt-agent-volume-manager:v0.3.1FastGPT Pod 内环境变量(exec 进 pod 执行 env 已确认变量真实存在):
AGENT_SANDBOX_PROVIDER=opensandbox
AGENT_SANDBOX_ENABLE_VOLUME=false
AGENT_SANDBOX_OPENSANDBOX_BASEURL=http://opensandbox-server.opensandbox-system.svc.cluster.local
AGENT_SANDBOX_OPENSANDBOX_VOLUME_MANAGER_URL=http://fastgpt-agent-volume-manager
AGENT_SANDBOX_OPENSANDBOX_VOLUME_MANAGER_TOKEN=xxxxxxxxxxxxxx
AGENT_SANDBOX_OPENSANDBOX_VOLUME_NAME_PREFIX=fastgpt-session
创建 skill‑sandbox 时,FastGPT 本地抛出 Zod 校验错误:
claimName expected string, got undefined。日志可见rawBody: undefined。完全没有向 volume‑manager 发出网络请求,失败发生在 FastGPT 后端进程内部。
实际报错堆栈:
根因分析:
packages/service/common/config/sandbox.ts使用 IIFE,模块加载时一次性读取 process.env。K8s 存在启动时序问题:Node 模块初始化瞬间,环境变量还未就绪,agentSandboxConfig.openSandbox.volumeNamePrefix被捕获为undefined。后续容器 env 已经就绪,但模块缓存的 config 对象不会刷新,永久为 undefined。packages/service/core/ai/sandbox/skillSandbox.tsskill‑sandbox 创建逻辑缺失enableVolume判断守卫。即使关闭 volume,依然无条件调用createVolume()。Agent‑sandbox 有该守卫,行为正常。createVolume()将缓存 config 中原始undefined值直接传给 Zod schema 的 claimName 字段,Zod 本地校验失败,没有执行字符串模板拼接、uuid 生成,也无网络请求。复现步骤
AGENT_SANDBOX_ENABLE_VOLUME=false,配置好AGENT_SANDBOX_OPENSANDBOX_VOLUME_NAME_PREFIX。claimName expected string, got undefined错误,无请求到 volume‑manager。预期结果
enableVolume=false,直接跳过 volume‑manager 客户端全部逻辑,不执行 Zod 校验。相关截图
请求:希望可以在 v4.15.x 分支做向后移植修复:
skillSandbox.ts添加enableVolume判断守卫,volume 关闭时跳过 volume‑manager 调用。