From 32731bbd2e36de539959d6669b5f7eca9d871bbb Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <1paneldev@sina.com> Date: Thu, 26 Mar 2026 13:09:01 +0800 Subject: [PATCH] fix: Fixed issue with agent acount model name is empty --- agent/app/api/v2/agents.go | 28 ++++++++-------- agent/app/dto/agents.go | 32 +++---------------- agent/app/service/agents.go | 18 +++++------ agent/app/service/agents_channels.go | 8 ++--- agent/app/service/agents_skills.go | 2 +- agent/init/migration/migrations/init.go | 2 +- .../utils/agent_account_model_pool.go | 23 +++++++++++++ frontend/src/components/log/task/index.vue | 2 +- .../ai/agents/agent/components/overview.vue | 1 + .../ai/agents/agent/config/tabs/skills.vue | 8 +++-- frontend/src/views/ai/agents/agent/index.vue | 2 +- 11 files changed, 65 insertions(+), 61 deletions(-) diff --git a/agent/app/api/v2/agents.go b/agent/app/api/v2/agents.go index 25a9745887cc..a06e849223af 100644 --- a/agent/app/api/v2/agents.go +++ b/agent/app/api/v2/agents.go @@ -417,13 +417,13 @@ func (b *BaseApi) UpdateAgentTelegramConfig(c *gin.Context) { // @Tags AI // @Summary Get Agent Discord channel config // @Accept json -// @Param request body dto.AgentDiscordConfigReq true "request" +// @Param request body dto.AgentIDReq true "request" // @Success 200 {object} dto.AgentDiscordConfig // @Security ApiKeyAuth // @Security Timestamp // @Router /ai/agents/channel/discord/get [post] func (b *BaseApi) GetAgentDiscordConfig(c *gin.Context) { - var req dto.AgentDiscordConfigReq + var req dto.AgentIDReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } @@ -458,13 +458,13 @@ func (b *BaseApi) UpdateAgentDiscordConfig(c *gin.Context) { // @Tags AI // @Summary Get Agent QQ Bot channel config // @Accept json -// @Param request body dto.AgentWecomConfigReq true "request" +// @Param request body dto.AgentIDReq true "request" // @Success 200 {object} dto.AgentWecomConfig // @Security ApiKeyAuth // @Security Timestamp // @Router /ai/agents/channel/wecom/get [post] func (b *BaseApi) GetAgentWecomConfig(c *gin.Context) { - var req dto.AgentWecomConfigReq + var req dto.AgentIDReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } @@ -499,13 +499,13 @@ func (b *BaseApi) UpdateAgentWecomConfig(c *gin.Context) { // @Tags AI // @Summary Get Agent DingTalk channel config // @Accept json -// @Param request body dto.AgentDingTalkConfigReq true "request" +// @Param request body dto.AgentIDReq true "request" // @Success 200 {object} dto.AgentDingTalkConfig // @Security ApiKeyAuth // @Security Timestamp // @Router /ai/agents/channel/dingtalk/get [post] func (b *BaseApi) GetAgentDingTalkConfig(c *gin.Context) { - var req dto.AgentDingTalkConfigReq + var req dto.AgentIDReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } @@ -540,13 +540,13 @@ func (b *BaseApi) UpdateAgentDingTalkConfig(c *gin.Context) { // @Tags AI // @Summary Get Agent QQ Bot channel config // @Accept json -// @Param request body dto.AgentQQBotConfigReq true "request" +// @Param request body dto.AgentIDReq true "request" // @Success 200 {object} dto.AgentQQBotConfig // @Security ApiKeyAuth // @Security Timestamp // @Router /ai/agents/channel/qqbot/get [post] func (b *BaseApi) GetAgentQQBotConfig(c *gin.Context) { - var req dto.AgentQQBotConfigReq + var req dto.AgentIDReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } @@ -622,13 +622,13 @@ func (b *BaseApi) CheckAgentPlugin(c *gin.Context) { // @Tags AI // @Summary Get Agent Security config // @Accept json -// @Param request body dto.AgentSecurityConfigReq true "request" +// @Param request body dto.AgentIDReq true "request" // @Success 200 {object} dto.AgentSecurityConfig // @Security ApiKeyAuth // @Security Timestamp // @Router /ai/agents/security/get [post] func (b *BaseApi) GetAgentSecurityConfig(c *gin.Context) { - var req dto.AgentSecurityConfigReq + var req dto.AgentIDReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } @@ -663,13 +663,13 @@ func (b *BaseApi) UpdateAgentSecurityConfig(c *gin.Context) { // @Tags AI // @Summary Get Agent Other config // @Accept json -// @Param request body dto.AgentOtherConfigReq true "request" +// @Param request body dto.AgentIDReq true "request" // @Success 200 {object} dto.AgentOtherConfig // @Security ApiKeyAuth // @Security Timestamp // @Router /ai/agents/other/get [post] func (b *BaseApi) GetAgentOtherConfig(c *gin.Context) { - var req dto.AgentOtherConfigReq + var req dto.AgentIDReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } @@ -745,13 +745,13 @@ func (b *BaseApi) UpdateAgentConfigFile(c *gin.Context) { // @Tags AI // @Summary List Agent skills // @Accept json -// @Param request body dto.AgentSkillsReq true "request" +// @Param request body dto.AgentIDReq true "request" // @Success 200 {array} dto.AgentSkillItem // @Security ApiKeyAuth // @Security Timestamp // @Router /ai/agents/skills/list [post] func (b *BaseApi) ListAgentSkills(c *gin.Context) { - var req dto.AgentSkillsReq + var req dto.AgentIDReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } diff --git a/agent/app/dto/agents.go b/agent/app/dto/agents.go index c382b7abb646..4a6b3bb4835f 100644 --- a/agent/app/dto/agents.go +++ b/agent/app/dto/agents.go @@ -73,6 +73,10 @@ type AgentOverviewReq struct { AgentID uint `json:"agentId" validate:"required"` } +type AgentIDReq struct { + AgentID uint `json:"agentId" validate:"required"` +} + type AgentOverview struct { Snapshot AgentOverviewSnapshot `json:"snapshot"` } @@ -237,10 +241,6 @@ type AgentChannelPairingApproveReq struct { PairingCode string `json:"pairingCode" validate:"required"` } -type AgentWecomConfigReq struct { - AgentID uint `json:"agentId" validate:"required"` -} - type AgentWecomConfigUpdateReq struct { AgentID uint `json:"agentId" validate:"required"` Enabled bool `json:"enabled"` @@ -257,10 +257,6 @@ type AgentWecomConfig struct { Installed bool `json:"installed"` } -type AgentDingTalkConfigReq struct { - AgentID uint `json:"agentId" validate:"required"` -} - type AgentDingTalkConfigUpdateReq struct { AgentID uint `json:"agentId" validate:"required"` Enabled bool `json:"enabled"` @@ -288,10 +284,6 @@ type AgentWeixinLoginReq struct { TaskID string `json:"taskID" validate:"required"` } -type AgentQQBotConfigReq struct { - AgentID uint `json:"agentId" validate:"required"` -} - type AgentQQBotConfigUpdateReq struct { AgentID uint `json:"agentId" validate:"required"` Enabled bool `json:"enabled"` @@ -321,10 +313,6 @@ type AgentPluginStatus struct { Installed bool `json:"installed"` } -type AgentDiscordConfigReq struct { - AgentID uint `json:"agentId" validate:"required"` -} - type AgentDiscordConfigUpdateReq struct { AgentID uint `json:"agentId" validate:"required"` Enabled bool `json:"enabled"` @@ -342,10 +330,6 @@ type AgentDiscordConfig struct { Proxy string `json:"proxy"` } -type AgentSecurityConfigReq struct { - AgentID uint `json:"agentId" validate:"required"` -} - type AgentSecurityConfigUpdateReq struct { AgentID uint `json:"agentId" validate:"required"` AllowedOrigins []string `json:"allowedOrigins"` @@ -355,10 +339,6 @@ type AgentSecurityConfig struct { AllowedOrigins []string `json:"allowedOrigins"` } -type AgentOtherConfigReq struct { - AgentID uint `json:"agentId" validate:"required"` -} - type AgentOtherConfigUpdateReq struct { AgentID uint `json:"agentId" validate:"required"` UserTimezone string `json:"userTimezone" validate:"required"` @@ -385,10 +365,6 @@ type AgentConfigFile struct { Content string `json:"content"` } -type AgentSkillsReq struct { - AgentID uint `json:"agentId" validate:"required"` -} - type AgentSkillSearchReq struct { AgentID uint `json:"agentId" validate:"required"` Source string `json:"source" validate:"required,oneof=clawhub skillhub"` diff --git a/agent/app/service/agents.go b/agent/app/service/agents.go index ca7014ece734..2aa2273258f1 100644 --- a/agent/app/service/agents.go +++ b/agent/app/service/agents.go @@ -32,13 +32,13 @@ type IAgentService interface { UpdateModelConfig(req dto.AgentModelConfigUpdateReq) error GetOverview(req dto.AgentOverviewReq) (*dto.AgentOverview, error) GetProviders() ([]dto.ProviderInfo, error) - GetSecurityConfig(req dto.AgentSecurityConfigReq) (*dto.AgentSecurityConfig, error) + GetSecurityConfig(req dto.AgentIDReq) (*dto.AgentSecurityConfig, error) UpdateSecurityConfig(req dto.AgentSecurityConfigUpdateReq) error - GetOtherConfig(req dto.AgentOtherConfigReq) (*dto.AgentOtherConfig, error) + GetOtherConfig(req dto.AgentIDReq) (*dto.AgentOtherConfig, error) UpdateOtherConfig(req dto.AgentOtherConfigUpdateReq) error GetConfigFile(req dto.AgentConfigFileReq) (*dto.AgentConfigFile, error) UpdateConfigFile(req dto.AgentConfigFileUpdateReq) error - ListSkills(req dto.AgentSkillsReq) ([]dto.AgentSkillItem, error) + ListSkills(req dto.AgentIDReq) ([]dto.AgentSkillItem, error) SearchSkills(req dto.AgentSkillSearchReq) ([]dto.AgentSkillSearchItem, error) UpdateSkill(req dto.AgentSkillUpdateReq) error InstallSkill(req dto.AgentSkillInstallReq) error @@ -58,14 +58,14 @@ type IAgentService interface { UpdateFeishuConfig(req dto.AgentFeishuConfigUpdateReq) error GetTelegramConfig(req dto.AgentTelegramConfigReq) (*dto.AgentTelegramConfig, error) UpdateTelegramConfig(req dto.AgentTelegramConfigUpdateReq) error - GetDiscordConfig(req dto.AgentDiscordConfigReq) (*dto.AgentDiscordConfig, error) + GetDiscordConfig(req dto.AgentIDReq) (*dto.AgentDiscordConfig, error) UpdateDiscordConfig(req dto.AgentDiscordConfigUpdateReq) error - GetWecomConfig(req dto.AgentWecomConfigReq) (*dto.AgentWecomConfig, error) + GetWecomConfig(req dto.AgentIDReq) (*dto.AgentWecomConfig, error) UpdateWecomConfig(req dto.AgentWecomConfigUpdateReq) error - GetDingTalkConfig(req dto.AgentDingTalkConfigReq) (*dto.AgentDingTalkConfig, error) + GetDingTalkConfig(req dto.AgentIDReq) (*dto.AgentDingTalkConfig, error) UpdateDingTalkConfig(req dto.AgentDingTalkConfigUpdateReq) error LoginWeixinChannel(req dto.AgentWeixinLoginReq) error - GetQQBotConfig(req dto.AgentQQBotConfigReq) (*dto.AgentQQBotConfig, error) + GetQQBotConfig(req dto.AgentIDReq) (*dto.AgentQQBotConfig, error) UpdateQQBotConfig(req dto.AgentQQBotConfigUpdateReq) error InstallPlugin(req dto.AgentPluginInstallReq) error CheckPlugin(req dto.AgentPluginCheckReq) (*dto.AgentPluginStatus, error) @@ -640,7 +640,7 @@ func (a AgentService) DeleteAccount(req dto.AgentAccountDeleteReq) error { return agentAccountRepo.DeleteByID(req.ID) } -func (a AgentService) GetSecurityConfig(req dto.AgentSecurityConfigReq) (*dto.AgentSecurityConfig, error) { +func (a AgentService) GetSecurityConfig(req dto.AgentIDReq) (*dto.AgentSecurityConfig, error) { agent, _, err := a.loadOpenclawAgentAndInstall(req.AgentID) if err != nil { return nil, err @@ -679,7 +679,7 @@ func (a AgentService) UpdateSecurityConfig(req dto.AgentSecurityConfigUpdateReq) return appInstallRepo.Save(context.Background(), install) } -func (a AgentService) GetOtherConfig(req dto.AgentOtherConfigReq) (*dto.AgentOtherConfig, error) { +func (a AgentService) GetOtherConfig(req dto.AgentIDReq) (*dto.AgentOtherConfig, error) { agent, install, err := a.loadAgentAndInstall(req.AgentID) if err != nil { return nil, err diff --git a/agent/app/service/agents_channels.go b/agent/app/service/agents_channels.go index c237b4986470..1b2f15ffa66f 100644 --- a/agent/app/service/agents_channels.go +++ b/agent/app/service/agents_channels.go @@ -58,7 +58,7 @@ func (a AgentService) UpdateTelegramConfig(req dto.AgentTelegramConfigUpdateReq) }) } -func (a AgentService) GetDiscordConfig(req dto.AgentDiscordConfigReq) (*dto.AgentDiscordConfig, error) { +func (a AgentService) GetDiscordConfig(req dto.AgentIDReq) (*dto.AgentDiscordConfig, error) { _, _, conf, err := a.loadAgentConfig(req.AgentID) if err != nil { return nil, err @@ -80,7 +80,7 @@ func (a AgentService) UpdateDiscordConfig(req dto.AgentDiscordConfigUpdateReq) e }) } -func (a AgentService) GetQQBotConfig(req dto.AgentQQBotConfigReq) (*dto.AgentQQBotConfig, error) { +func (a AgentService) GetQQBotConfig(req dto.AgentIDReq) (*dto.AgentQQBotConfig, error) { _, install, conf, err := a.loadAgentConfig(req.AgentID) if err != nil { return nil, err @@ -102,7 +102,7 @@ func (a AgentService) UpdateQQBotConfig(req dto.AgentQQBotConfigUpdateReq) error }) } -func (a AgentService) GetWecomConfig(req dto.AgentWecomConfigReq) (*dto.AgentWecomConfig, error) { +func (a AgentService) GetWecomConfig(req dto.AgentIDReq) (*dto.AgentWecomConfig, error) { _, install, conf, err := a.loadAgentConfig(req.AgentID) if err != nil { return nil, err @@ -125,7 +125,7 @@ func (a AgentService) UpdateWecomConfig(req dto.AgentWecomConfigUpdateReq) error }) } -func (a AgentService) GetDingTalkConfig(req dto.AgentDingTalkConfigReq) (*dto.AgentDingTalkConfig, error) { +func (a AgentService) GetDingTalkConfig(req dto.AgentIDReq) (*dto.AgentDingTalkConfig, error) { _, install, conf, err := a.loadAgentConfig(req.AgentID) if err != nil { return nil, err diff --git a/agent/app/service/agents_skills.go b/agent/app/service/agents_skills.go index 4bb9b0db343b..410cece83812 100644 --- a/agent/app/service/agents_skills.go +++ b/agent/app/service/agents_skills.go @@ -36,7 +36,7 @@ type skillhubSearchPayload struct { var clawhubSearchLinePattern = regexp.MustCompile(`^(\S+)\s+(.+?)\s+\(([\d.]+)\)$`) -func (a AgentService) ListSkills(req dto.AgentSkillsReq) ([]dto.AgentSkillItem, error) { +func (a AgentService) ListSkills(req dto.AgentIDReq) ([]dto.AgentSkillItem, error) { _, install, err := a.loadOpenclawAgentAndInstall(req.AgentID) if err != nil { return nil, err diff --git a/agent/init/migration/migrations/init.go b/agent/init/migration/migrations/init.go index 87575528f128..0cbfed26faba 100644 --- a/agent/init/migration/migrations/init.go +++ b/agent/init/migration/migrations/init.go @@ -1146,7 +1146,7 @@ SET http_port = https_port, WHERE version = ? AND https_port > 0 AND app_id IN (SELECT id FROM apps WHERE key = ?)`, - "2026.3.23", + "2026.3.24", constant.AppOpenclaw, ).Error }, diff --git a/agent/init/migration/migrations/utils/agent_account_model_pool.go b/agent/init/migration/migrations/utils/agent_account_model_pool.go index a5f88f93fb41..9c752c5c0590 100644 --- a/agent/init/migration/migrations/utils/agent_account_model_pool.go +++ b/agent/init/migration/migrations/utils/agent_account_model_pool.go @@ -6,6 +6,7 @@ import ( "github.com/1Panel-dev/1Panel/agent/app/dto" "github.com/1Panel-dev/1Panel/agent/app/model" + providercatalog "github.com/1Panel-dev/1Panel/agent/app/provider" "github.com/1Panel-dev/1Panel/agent/app/service" "gorm.io/gorm" @@ -107,5 +108,27 @@ func buildMigratedAgentAccountModels(tx *gorm.DB, account *legacyAgentAccountMod } return nil, err } + applyLegacyAgentAccountModelDefaults(account.Provider, models) return models, nil } + +func applyLegacyAgentAccountModelDefaults(provider string, models []dto.AgentAccountModel) { + if provider != "custom" && provider != "ollama" && provider != "vllm" { + return + } + meta, ok := providercatalog.Get(provider) + if !ok { + return + } + for i := range models { + if strings.TrimSpace(models[i].Name) == "" { + models[i].Name = strings.TrimSpace(models[i].ID) + } + if models[i].ContextWindow <= 0 { + models[i].ContextWindow = meta.Default.ContextWindow + } + if models[i].MaxTokens <= 0 { + models[i].MaxTokens = meta.Default.MaxTokens + } + } +} diff --git a/frontend/src/components/log/task/index.vue b/frontend/src/components/log/task/index.vue index 1d661187c408..7dc084f80974 100644 --- a/frontend/src/components/log/task/index.vue +++ b/frontend/src/components/log/task/index.vue @@ -44,7 +44,7 @@ const config = reactive({ const open = ref(false); const showTail = ref(true); -const openWithTaskID = (id: string, tail: boolean, operateNode?: string) => { +const openWithTaskID = (id: string, tail?: boolean, operateNode?: string) => { config.taskID = id; if (tail === undefined) { config.tail = true; diff --git a/frontend/src/views/ai/agents/agent/components/overview.vue b/frontend/src/views/ai/agents/agent/components/overview.vue index 1ddd7e2e0e0b..80e0476b59a8 100644 --- a/frontend/src/views/ai/agents/agent/components/overview.vue +++ b/frontend/src/views/ai/agents/agent/components/overview.vue @@ -111,6 +111,7 @@ defineExpose({ color: var(--el-text-color-primary); } :deep(.status-count) { + font-size: 18px; color: var(--el-text-color-primary); } :deep(.status-label) { diff --git a/frontend/src/views/ai/agents/agent/config/tabs/skills.vue b/frontend/src/views/ai/agents/agent/config/tabs/skills.vue index 50d2f107f2d7..0fe037325c21 100644 --- a/frontend/src/views/ai/agents/agent/config/tabs/skills.vue +++ b/frontend/src/views/ai/agents/agent/config/tabs/skills.vue @@ -62,7 +62,11 @@ @change="(value) => toggleSkill(skill, Boolean(value))" /> - + @@ -101,7 +105,7 @@ diff --git a/frontend/src/views/ai/agents/agent/index.vue b/frontend/src/views/ai/agents/agent/index.vue index 166208180a4b..0ebceb5bdfdb 100644 --- a/frontend/src/views/ai/agents/agent/index.vue +++ b/frontend/src/views/ai/agents/agent/index.vue @@ -133,7 +133,7 @@ min-width="200" :label="$t('commons.table.operate')" fixed="right" - :ellipsis="4" + :ellipsis="3" />