fix(agent): 媒体准入参数结构化纠错

This commit is contained in:
ddcat666 committed 2026-10-13 20:54:44 +08:00
1 parent 7466119867
commit fb03cfca1e
9 files changed
+157 -117

No files matched your search

+4 -3
View File
@@ -26,7 +26,8 @@ func cloudAgentCanonicalFor(system string, history []providerTextMessage, prompt
const (
cloudAgentPromptCacheSchemaVersion = "cloud-agent-prompt-cache/v2"
cloudAgentToolSchemaVersion = "cloud-agent-tools/v4"
cloudAgentToolSchemaVersion = "cloud-agent-tools/v5"
cloudAgentMediaSizeDescription = "按本回合 model_list 返回的 imageSize/image.size.parameter 传值:parameter=size 时使用支持值,只有 allowCustom=true 才能使用宽x高;parameter=aspect_ratio 时使用 W:H;不要把冒号或比例值传给像素尺寸模型"
)
// cloudAgentPromptCacheIdentity deliberately excludes the canvas payload and its
@@ -209,7 +210,7 @@ func compileCloudAgentTools(req CloudAgentRequest, includeProfileTool bool) []ma
if req.PermissionMode != "read_only" && len(req.ContextScope) > 0 {
add("image_layer_split", "将图片按用户指定对象拆分为独立透明图层。参数与 generate_media 的图片生成参数一致,但 mode 固定为 image;所有权限模式都会先创建草稿并进入界面独立审批,用户批准后才提交生成任务。", map[string]any{
"prompt": str("需要拆分的对象与透明背景要求"), "logicalModelId": str("selection.logicalModelId"), "channelId": str("selection.channelId"), "channelModelKey": str("selection.channelModelKey"),
"quality": str("模型支持的质量档位"), "snapshotHash": str("最近画布读取返回的 mediaSnapshotHash,可省略"), "nodeId": str("新的结果节点ID"), "title": str("结果节点名称"), "referenceNodeIds": map[string]any{"type": "array", "maxItems": 16, "items": str("源图片节点ID")},
"size": str(cloudAgentMediaSizeDescription), "quality": str("模型支持的质量档位"), "snapshotHash": str("最近画布读取返回的 mediaSnapshotHash,可省略"), "nodeId": str("新的结果节点ID"), "title": str("结果节点名称"), "referenceNodeIds": map[string]any{"type": "array", "maxItems": 16, "items": str("源图片节点ID")},
}, "prompt", "nodeId", "title", "referenceNodeIds")
cloudAgentRequireExplicitMediaModelSelection(tools[len(tools)-1])
add("model_list", "读取当前生效的生成模型目录、能力与价格档。生成前传 mode 和本次实际 referenceNodeIds,服务端按真实素材类型、数量和生成操作筛选匹配模型;空列表表示无匹配项,不得退回不匹配模型。相同条件直接复用,变化后再查。复制 selection 到 generate_media,不猜ID或混用模型选择;再按返回的能力配置核对时长、画幅、音频和价格。", map[string]any{"mode": map[string]any{"type": "string", "enum": cloudAgentGenerationModeNames()}, "referenceNodeIds": map[string]any{"type": "array", "maxItems": 16, "items": str("本次实际使用的画布媒体参考节点ID;文生媒体传空数组")}})
@@ -287,7 +288,7 @@ func compileCloudAgentTools(req CloudAgentRequest, includeProfileTool bool) []ma
add("generate_media", "提交媒体生成:先准备草稿和引用;所有权限模式均经模型/能力/价格/预算/资源校验和界面独立审批,用户批准后才提交。编辑节点或连线用 canvas_apply_ops;先读画布与模型。已有任务或产物不可覆盖,状态用 generation/task_get。sourceNodeId 为文本,referenceNodeIds 为媒体;角色卡作为参考同时采用设定与三视图,仅取设定则用 sourceNodeId,不要重复指定。临时引用只接受标注工具ID,不接受URL。参数取本回合 model_list;失败先改参数,勿重提或重读。失败须告知用户,重试需明确要求并重新审批。", map[string]any{
"mode": map[string]any{"type": "string", "enum": cloudAgentGenerationModeNames()}, "prompt": str("完整生成提示词;引用素材时在对应描述中使用 @图片1、@视频1、@音频1,各类型按 referenceNodeIds 中出现顺序独立编号,文本来源不占媒体编号。服务端会为遗漏的已选素材补齐引用标签,不推断素材用途"),
"logicalModelId": str("selection.logicalModelId;与channelId/channelModelKey互斥"), "channelId": str("selection.channelId"), "channelModelKey": str("selection.channelModelKey"),
"durationSeconds": map[string]any{"type": "integer", "minimum": 0}, "size": str("模型支持的画幅,例如9:16"), "quality": str("目录支持的分辨率或质量"), "videoGenerateAudio": map[string]any{"type": "boolean", "description": "是否生成音频,仅视频可用"},
"durationSeconds": map[string]any{"type": "integer", "minimum": 0}, "size": str(cloudAgentMediaSizeDescription), "quality": str("按本回合 model_list 返回的 image.quality 或 video.resolutions 取值;视频输出分辨率保持目录返回的大小写"), "videoGenerateAudio": map[string]any{"type": "boolean", "description": "是否生成音频,仅视频可用"},
"videoStartFrameNodeId": str("视频首帧图片ID,须在 referenceNodeIds 中"),
"videoEndFrameNodeId": str("视频尾帧图片ID,须在 referenceNodeIds 中"),
"snapshotHash": str("可省略:省略时用当前画布内容快照"), "nodeId": str("可续用的未提交媒体草稿ID;无草稿时才使用新唯一ID"), "title": str("媒体节点名称"), "sourceNodeId": str("仅文本/镜头提示词节点ID;不要填媒体节点"), "referenceNodeIds": map[string]any{"type": "array", "maxItems": 16, "items": str("画布媒体参考节点ID,按引用顺序")}, "referenceTransientIds": map[string]any{"type": "array", "maxItems": 4, "items": str("由 image_annotation_render 返回的临时参考图ID")},