From 6687e81b967fc5f85b48f8d86a8400331a70c2d9 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Fri, 21 Nov 2025 14:28:43 +0800 Subject: [PATCH] refactor: Remove 'enabled' field from AgentConfig and related components - Removed the 'enabled' field from the AgentConfig interface and its usage in AgentSettings and tenant handler. - Updated related validation logic to ensure consistency without the 'enabled' parameter. - Streamlined agent configuration handling for improved clarity and maintainability. --- frontend/src/api/system/index.ts | 1 - frontend/src/views/settings/AgentSettings.vue | 1 - internal/handler/tenant.go | 23 ++++++------------- internal/types/agent.go | 1 - 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/frontend/src/api/system/index.ts b/frontend/src/api/system/index.ts index 8ec25f81..134d18e5 100644 --- a/frontend/src/api/system/index.ts +++ b/frontend/src/api/system/index.ts @@ -24,7 +24,6 @@ export interface PlaceholderDefinition { } export interface AgentConfig { - enabled: boolean max_iterations: number reflection_enabled: boolean allowed_tools: string[] diff --git a/frontend/src/views/settings/AgentSettings.vue b/frontend/src/views/settings/AgentSettings.vue index b80d1ae2..4a1d9a6f 100644 --- a/frontend/src/views/settings/AgentSettings.vue +++ b/frontend/src/views/settings/AgentSettings.vue @@ -821,7 +821,6 @@ const isAgentReady = computed(() => { }) const buildAgentConfigPayload = (overrides: Partial = {}): AgentConfig => ({ - enabled: isAgentReady.value, max_iterations: localMaxIterations.value, reflection_enabled: false, allowed_tools: localAllowedTools.value, diff --git a/internal/handler/tenant.go b/internal/handler/tenant.go index a938b09c..24921355 100644 --- a/internal/handler/tenant.go +++ b/internal/handler/tenant.go @@ -233,7 +233,6 @@ func (h *TenantHandler) ListTenants(c *gin.Context) { // AgentConfigRequest represents the request body for updating agent configuration type AgentConfigRequest struct { - Enabled bool `json:"enabled"` MaxIterations int `json:"max_iterations"` ReflectionEnabled bool `json:"reflection_enabled"` AllowedTools []string `json:"allowed_tools"` @@ -311,7 +310,6 @@ func (h *TenantHandler) GetTenantAgentConfig(c *gin.Context) { c.JSON(http.StatusOK, gin.H{ "success": true, "data": gin.H{ - "enabled": tenant.AgentConfig.Enabled, "max_iterations": tenant.AgentConfig.MaxIterations, "reflection_enabled": tenant.AgentConfig.ReflectionEnabled, "allowed_tools": tenant.AgentConfig.AllowedTools, @@ -338,19 +336,13 @@ func (h *TenantHandler) updateTenantAgentConfigInternal(c *gin.Context) { } // Validate configuration - if req.Enabled { - if req.MaxIterations <= 0 || req.MaxIterations > 30 { - c.Error(errors.NewAgentInvalidMaxIterationsError()) - return - } - if req.Temperature < 0 || req.Temperature > 2 { - c.Error(errors.NewAgentInvalidTemperatureError()) - return - } - if len(req.AllowedTools) == 0 { - c.Error(errors.NewAgentMissingAllowedToolsError()) - return - } + if req.MaxIterations <= 0 || req.MaxIterations > 30 { + c.Error(errors.NewAgentInvalidMaxIterationsError()) + return + } + if req.Temperature < 0 || req.Temperature > 2 { + c.Error(errors.NewAgentInvalidTemperatureError()) + return } // Get existing tenant @@ -365,7 +357,6 @@ func (h *TenantHandler) updateTenantAgentConfigInternal(c *gin.Context) { } tenant.AgentConfig = &types.AgentConfig{ - Enabled: req.Enabled, MaxIterations: req.MaxIterations, ReflectionEnabled: req.ReflectionEnabled, AllowedTools: req.AllowedTools, diff --git a/internal/types/agent.go b/internal/types/agent.go index 0b68fa27..fb2464d6 100644 --- a/internal/types/agent.go +++ b/internal/types/agent.go @@ -10,7 +10,6 @@ import ( // AgentConfig represents the full agent configuration (used at tenant level and runtime) // This includes all configuration parameters for agent execution type AgentConfig struct { - Enabled bool `json:"enabled"` // Whether agent mode is enabled MaxIterations int `json:"max_iterations"` // Maximum number of ReAct iterations ReflectionEnabled bool `json:"reflection_enabled"` // Whether to enable reflection AllowedTools []string `json:"allowed_tools"` // List of allowed tool names