fix(agent): 视频生成 - 支持 Agent 设置首尾帧 (#696)

* fix(agent): 视频生成 - 支持 Agent 设置首尾帧

* fix(agent): 工具参数 - 精简首尾帧说明并保持体积预算

---------

Co-authored-by: tanzui <305375675@.com>
This commit is contained in:
tanzuiandtanzui authored and GitHub committed 2026-10-06 09:28:22 +08:00
1 parent fb101b76d0
commit 3750fada7a
10 files changed
+342 -8

No files matched your search

@@ -5,8 +5,8 @@ import (
"strings"
)
// Agent arguments and the canvas editor enter the same public generation codec.
// Resource materialization and provider credentials remain outside this object.
// cloudAgentGenerationSpec 将 Agent 参数和已解析素材转换为画布生成合同。
// refs 提供真实素材类型,resolvedConfig 提供准入后的模型默认值;返回可保存的规格或参数错误。
func cloudAgentGenerationSpec(a cloudAgentMediaArgs, refs map[string]any, resolvedConfig map[string]any) (contract.GenerationSpec, error) {
selection := &contract.ModelSelection{Kind: "channel", ChannelID: a.ChannelID, ModelKey: a.ChannelModelKey}
if a.LogicalModelID != "" {
@@ -59,6 +59,19 @@ func cloudAgentGenerationSpec(a cloudAgentMediaArgs, refs map[string]any, resolv
}
}
bindings := []contract.ReferenceBinding{}
// 帧选择沿用视频编辑器的 metadata 字段;这里只校验真实引用,不从提示词或图片顺序猜用途。
for _, frame := range []struct{ field, id string }{
{"videoStartFrameNodeId", a.VideoStartFrameNodeID},
{"videoEndFrameNodeId", a.VideoEndFrameNodeID},
} {
if frame.id == "" {
continue
}
binding, exists := byID[frame.id]
if a.Mode != "video" || !exists || binding.MediaType != "image" || !containsString(a.ReferenceNodeIDs, frame.id) {
return contract.GenerationSpec{}, cloudAgentFieldError(frame.field, "invalid_value", "首尾帧仅用于视频,必须选择 referenceNodeIds 中的真实图片节点")
}
}
for _, id := range a.ReferenceNodeIDs {
binding, exists := byID[id]
if !exists {