fix(agent): 分镜绑定 - 明确连线方向与字段纠正提示

This commit is contained in:
ddcat666
2026-10-10 04:47:20 +08:00
7 changed files with 150 additions and 6 deletions

View File

@@ -86,7 +86,22 @@ func cloudAgentToolResult(runID string, state *cloudAgentRuntime, call cloudAgen
detail["exampleArguments"] = map[string]any{}
}
if call.Function.Name == "canvas_apply_ops" {
detail["exampleArguments"] = map[string]any{"snapshotHash": "<canvas_get_state.snapshotHash>", "ops": []any{map[string]any{"type": "add_node", "id": "<new-node-id>", "nodeType": "text", "content": "<content>"}}}
if fieldErr != nil && (strings.HasSuffix(fieldErr.Field, ".fromHandleId") || strings.HasSuffix(fieldErr.Field, ".toHandleId")) {
// 这里只提供纠正模板,不修改原调用。handle 放错节点时应换到分镜一端;
// 行 ID 或格式错误则保持原方向,要求重新读取真实 rowId。
sourceHandle := strings.HasSuffix(fieldErr.Field, ".fromHandleId")
if fieldErr.Issue == "invalid_node_handle" {
sourceHandle = !sourceHandle
}
op := map[string]any{"type": "connect_nodes", "id": "<new-edge-id>", "fromNodeId": "<asset-node-id>", "toNodeId": "<script-node-id>", "toHandleId": "row:<rowId-from-canvas_read_storyboard>"}
if sourceHandle {
op = map[string]any{"type": "connect_nodes", "id": "<new-edge-id>", "fromNodeId": "<script-node-id>", "toNodeId": "<output-image-or-video-node-id>", "fromHandleId": "row:<rowId-from-canvas_read_storyboard>"}
}
detail["guidance"] = message + ";本次连线未执行,示例仅是参数模板,节点 ID 和 rowId 必须来自最新读取结果"
detail["exampleArguments"] = map[string]any{"snapshotHash": "<canvas_get_state.snapshotHash>", "ops": []any{op}}
} else {
detail["exampleArguments"] = map[string]any{"snapshotHash": "<canvas_get_state.snapshotHash>", "ops": []any{map[string]any{"type": "add_node", "id": "<new-node-id>", "nodeType": "text", "content": "<content>"}}}
}
}
}
// 稳定归类 + 可行动字段:只加标注,不改任何放行/拒绝判定。