Refactor AIAgent runtime handling and remove unused fields

This commit is contained in:
mlogclub
2026-06-23 08:37:52 +08:00
parent e4cab3e12d
commit 560843686b
13 changed files with 65 additions and 76 deletions
-21
View File
@@ -229,7 +229,6 @@ func (s *aIAgentService) buildAIAgentModel(id int64, req request.CreateAIAgentRe
SkillIDs: utils.JoinInt64s(skillIDs),
AllowedMCPTools: directToolsJSON,
AllowedGraphTools: graphToolsJSON,
RuntimeMode: enums.AIAgentRuntimeModeBuiltinGraph,
WorkflowVersionID: 0,
}, nil
}
@@ -357,26 +356,6 @@ func (s *aIAgentService) normalizeGraphTools(input []string) ([]string, error) {
return ret, nil
}
func (s *aIAgentService) normalizeRuntimeMode(input enums.AIAgentRuntimeMode, workflowVersionID int64) (enums.AIAgentRuntimeMode, int64, error) {
if input == 0 {
input = enums.AIAgentRuntimeModeBuiltinGraph
}
if !slices.Contains(enums.AIAgentRuntimeModeValues, input) {
return 0, 0, errorsx.InvalidParam("invalid ai agent runtime mode")
}
if input != enums.AIAgentRuntimeModeWorkflow {
return input, 0, nil
}
if workflowVersionID <= 0 {
return 0, 0, errorsx.InvalidParam("workflow version is required")
}
version := AIWorkflowService.GetVersion(workflowVersionID)
if version == nil || version.Status != enums.StatusOk {
return 0, 0, errorsx.InvalidParam("workflow version does not exist")
}
return input, workflowVersionID, nil
}
func (s *aIAgentService) UpdateSort(ids []int64) error {
return sqls.WithTransaction(func(ctx *sqls.TxContext) error {
for i, id := range ids {
@@ -99,9 +99,6 @@ func TestAIWorkflowServicePublishAgentWorkflowBindsAgentVersion(t *testing.T) {
if storedAgent == nil {
t.Fatalf("expected stored agent")
}
if storedAgent.RuntimeMode != enums.AIAgentRuntimeModeWorkflow {
t.Fatalf("expected agent runtime workflow, got %d", storedAgent.RuntimeMode)
}
if storedAgent.WorkflowVersionID != version.ID {
t.Fatalf("expected agent workflow version %d, got %d", version.ID, storedAgent.WorkflowVersionID)
}
-1
View File
@@ -301,7 +301,6 @@ func (s *aiWorkflowService) PublishAgentWorkflow(req request.PublishAIWorkflowRe
return err
}
return repositories.AIAgentRepository.Updates(ctx.Tx, req.AgentID, map[string]any{
"runtime_mode": enums.AIAgentRuntimeModeWorkflow,
"workflow_version_id": version.ID,
"update_user_id": operator.UserID,
"update_user_name": operator.Username,