fix(agent): 云端 Agent - 媒体失败可续跑并补齐快照哈希
生成任务失败不再把整轮判死,漏传画布快照由服务端补当前内容哈希,没有偏好层时不暴露空的 profile 读取。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e345a1b3b3
commit
e5a5f0ccc8
13 files changed
+201
-41
No files matched your search
@@ -448,6 +448,22 @@ func cloudAgentMediaOperation(mode string, refs map[string]any) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (s *Service) fillCloudAgentMediaSnapshotHash(userID, canvasID string, a *cloudAgentMediaArgs) error {
|
||||
if a == nil || strings.TrimSpace(a.SnapshotHash) != "" {
|
||||
return nil
|
||||
}
|
||||
canvas, err := s.repo.CanvasProjectForUser(userID, canvasID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
doc, err := creationDocument(canvas.PayloadJSON)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.SnapshotHash = cloudAgentMediaContentHash(doc)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) prepareCloudAgentMedia(run *model.CloudAgentExecution, state *cloudAgentRuntime, call cloudAgentCall) (CreateTaskRequest, *cloudAgentMediaPlan, error) {
|
||||
var a cloudAgentMediaArgs
|
||||
if err := decodeCloudAgentJSONObject(call.Function.Arguments, &a); err != nil {
|
||||
@@ -455,6 +471,9 @@ func (s *Service) prepareCloudAgentMedia(run *model.CloudAgentExecution, state *
|
||||
}
|
||||
a.Mode = strings.ToLower(strings.TrimSpace(a.Mode))
|
||||
a.DraftRunID = run.ID
|
||||
if err := s.fillCloudAgentMediaSnapshotHash(run.UserID, state.Request.CanvasID, &a); err != nil {
|
||||
return CreateTaskRequest{}, nil, err
|
||||
}
|
||||
if err := validateCloudAgentMediaArgs(a, state); err != nil {
|
||||
return CreateTaskRequest{}, nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user