node:setConfig 工具传 duration 字段始终报错"expected number, received string",无法动态控制视频时长

Author: Oliver-Smith-2048Created Sep 27, 2026Updated Sep 27, 2026

标题:node:setConfig 工具传 duration 字段始终报错"expected number, received string",无法动态控制视频时长

环境:

  • Toonflow (commit 不详)
  • 本地 ComfyUI v0.37.2 (RTX PRO 5000)
  • Provider: comfyuiMiniMaxH3 / minimaxH3Ref2Video
  • 节点类型:remote-videoGenerationNode

复现步骤:

  1. 创建 remote-videoGenerationNode,配置 provider comfyuiMiniMaxH3、model minimaxH3Ref2Video
  2. 节点连线图片(reference 模式)
  3. 通过任何调用方(AI Agent / API / CLI)调用 node:setConfig 工具
  4. 在 args 中传 duration: 6(number 类型)
  5. 同样测试以下写法均失败:
    • {"duration": 6} → "received string"
    • {"duration": 6.0} → "received string"
    • {"duration": "6"} → "received string"(违反 schema 类型)
    • 只传 {"duration": 6} → "received string"

期望行为: duration 字段为 number 类型(schema: {type: "number", exclusiveMinimum: 0}),应能正常接收 number 6 并保存到节点 data.duration。

实际行为: 工具返回 Zod schema 校验错误:

{
  "expected": "number",
  "code": "invalid_type",
  "path": ["duration"],
  "message": "expected number, received string"
}

无论 number 怎么传,工具都把它转成 string 再校验,导致永远无法设置 duration。手动在 Toonflow UI 上设置 duration 是有效的(节点 data 会写入新值),说明后端/工作流支持,问题仅出在工具入参处理层。

绕过方案: 只能让用户在 UI 上手动改 duration,无法通过任何调用方(含 AI Agent)动态控制视频时长,限制了"按分镜动态规划时长"等合理用例。

附加上下文:

  • 同样的字符串化问题也影响 generateAudio 字段(boolean)
  • 之前工作流 ComfyUI 端数学计算确认 length = max(5, round(duration * 24)),duration 真的会影响最终视频时长
  • AI Agent 排查确认是工具层 Zod schema 缺 .coerce.number() / .coerce.boolean()