feat(agent): 云端 Agent - 加固运行时并新增导演工具

This commit is contained in:
ddcat666 committed 2026-09-27 09:45:43 +08:00
1 parent 1080b22196
commit 1a4598e496
16 files changed
+815 -195

No files matched your search

+15 -11
View File
@@ -51,6 +51,7 @@ type CloudAgentRequest struct {
}
const cloudAgentMaxStepsLimit = 9999
const cloudAgentMaxConfirmationRounds = 2
func cloudAgentStepLimit(req CloudAgentRequest) int {
if req.Budget.MaxSteps > 0 {
@@ -60,15 +61,16 @@ func cloudAgentStepLimit(req CloudAgentRequest) int {
}
type cloudAgentState struct {
Version int `json:"version"`
Request CloudAgentRequest `json:"request"`
ParentID string `json:"parentId"`
Fingerprint string `json:"fingerprint"`
CreativeAnchor cloudAgentCreativeAnchor `json:"creativeAnchor,omitempty"`
Plan []cloudAgentPlanItem `json:"plan,omitempty"`
Skills []cloudAgentSkill `json:"skills,omitempty"`
Profile cloudAgentProfileSnapshot `json:"profile"`
Policy cloudAgentPolicySnapshot `json:"policy"`
Version int `json:"version"`
Request CloudAgentRequest `json:"request"`
ParentID string `json:"parentId"`
Fingerprint string `json:"fingerprint"`
CreativeAnchor cloudAgentCreativeAnchor `json:"creativeAnchor,omitempty"`
Plan []cloudAgentPlanItem `json:"plan,omitempty"`
ConfirmationRounds int `json:"confirmationRounds,omitempty"`
Skills []cloudAgentSkill `json:"skills,omitempty"`
Profile cloudAgentProfileSnapshot `json:"profile"`
Policy cloudAgentPolicySnapshot `json:"policy"`
}
type CloudAgentRun struct {
@@ -283,7 +285,7 @@ func (s *Service) cloudAgentTask(userID, id string) (*model.Task, cloudAgentStat
if task.ID != cloudAgentID(userID, state.Request.IdempotencyKey) || task.ProjectID != state.Request.CanvasID {
return nil, input.Agent, kernel.NotFound("Agent 运行不存在")
}
input.Agent = cloudAgentState{Version: 1, Request: state.Request, ParentID: state.ParentID, Fingerprint: state.Fingerprint, CreativeAnchor: state.CreativeAnchor, Skills: state.Skills, Profile: state.Profile, Policy: state.Policy}
input.Agent = cloudAgentState{Version: 1, Request: state.Request, ParentID: state.ParentID, Fingerprint: state.Fingerprint, CreativeAnchor: state.CreativeAnchor, ConfirmationRounds: state.ConfirmationRounds, Skills: state.Skills, Profile: state.Profile, Policy: state.Policy}
return task, input.Agent, nil
}
@@ -377,6 +379,7 @@ func (s *Service) CreateCloudAgentRun(userID string, req CloudAgentRequest, pare
var history []providerTextMessage
var creativeAnchor cloudAgentCreativeAnchor
var inheritedPlan []cloudAgentPlanItem
inheritedConfirmationRounds := 0
if parentID != "" {
parent, _, parentErr := s.cloudAgentTask(userID, parentID)
if parentErr != nil {
@@ -412,6 +415,7 @@ func (s *Service) CreateCloudAgentRun(userID string, req CloudAgentRequest, pare
return nil, WrapAppError(409, "上一轮 Agent 历史记录不完整,无法继续对话;请新建对话", err)
}
inheritedPlan = parentState.Plan
inheritedConfirmationRounds = parentState.ConfirmationRounds
// 视觉事实跨轮继承:这一轮已经看过的画面与模型自己写下的观察随锚点带过来,
// 否则新轮会把看过的图重新标成"没有视觉识别证据"并再花一次视觉 token。
creativeAnchor = parentState.CreativeAnchor
@@ -468,7 +472,7 @@ func (s *Service) CreateCloudAgentRun(userID string, req CloudAgentRequest, pare
if err != nil {
return nil, err
}
state := cloudAgentState{Version: 1, Request: req, ParentID: parentID, Fingerprint: fingerprint, CreativeAnchor: creativeAnchor, Plan: inheritedPlan, Skills: skillSnapshots, Profile: profile, Policy: policy}
state := cloudAgentState{Version: 1, Request: req, ParentID: parentID, Fingerprint: fingerprint, CreativeAnchor: creativeAnchor, Plan: inheritedPlan, ConfirmationRounds: inheritedConfirmationRounds, Skills: skillSnapshots, Profile: profile, Policy: policy}
canonical := cloudAgentCanonicalFor(system, history, req.Prompt, req, len(profile.Layers) > 0)
// Keep the catalog out of TextHistory (which defines conversation turns),
// while exposing it as a fresh data message for this run immediately before