Skip to content

Commit 2d78ca5

Browse files
fix: Fixed issue with agent acount model name is empty (#12343)
1 parent a9b65b7 commit 2d78ca5

File tree

11 files changed

+65
-61
lines changed

11 files changed

+65
-61
lines changed

agent/app/api/v2/agents.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ func (b *BaseApi) UpdateAgentTelegramConfig(c *gin.Context) {
417417
// @Tags AI
418418
// @Summary Get Agent Discord channel config
419419
// @Accept json
420-
// @Param request body dto.AgentDiscordConfigReq true "request"
420+
// @Param request body dto.AgentIDReq true "request"
421421
// @Success 200 {object} dto.AgentDiscordConfig
422422
// @Security ApiKeyAuth
423423
// @Security Timestamp
424424
// @Router /ai/agents/channel/discord/get [post]
425425
func (b *BaseApi) GetAgentDiscordConfig(c *gin.Context) {
426-
var req dto.AgentDiscordConfigReq
426+
var req dto.AgentIDReq
427427
if err := helper.CheckBindAndValidate(&req, c); err != nil {
428428
return
429429
}
@@ -458,13 +458,13 @@ func (b *BaseApi) UpdateAgentDiscordConfig(c *gin.Context) {
458458
// @Tags AI
459459
// @Summary Get Agent QQ Bot channel config
460460
// @Accept json
461-
// @Param request body dto.AgentWecomConfigReq true "request"
461+
// @Param request body dto.AgentIDReq true "request"
462462
// @Success 200 {object} dto.AgentWecomConfig
463463
// @Security ApiKeyAuth
464464
// @Security Timestamp
465465
// @Router /ai/agents/channel/wecom/get [post]
466466
func (b *BaseApi) GetAgentWecomConfig(c *gin.Context) {
467-
var req dto.AgentWecomConfigReq
467+
var req dto.AgentIDReq
468468
if err := helper.CheckBindAndValidate(&req, c); err != nil {
469469
return
470470
}
@@ -499,13 +499,13 @@ func (b *BaseApi) UpdateAgentWecomConfig(c *gin.Context) {
499499
// @Tags AI
500500
// @Summary Get Agent DingTalk channel config
501501
// @Accept json
502-
// @Param request body dto.AgentDingTalkConfigReq true "request"
502+
// @Param request body dto.AgentIDReq true "request"
503503
// @Success 200 {object} dto.AgentDingTalkConfig
504504
// @Security ApiKeyAuth
505505
// @Security Timestamp
506506
// @Router /ai/agents/channel/dingtalk/get [post]
507507
func (b *BaseApi) GetAgentDingTalkConfig(c *gin.Context) {
508-
var req dto.AgentDingTalkConfigReq
508+
var req dto.AgentIDReq
509509
if err := helper.CheckBindAndValidate(&req, c); err != nil {
510510
return
511511
}
@@ -540,13 +540,13 @@ func (b *BaseApi) UpdateAgentDingTalkConfig(c *gin.Context) {
540540
// @Tags AI
541541
// @Summary Get Agent QQ Bot channel config
542542
// @Accept json
543-
// @Param request body dto.AgentQQBotConfigReq true "request"
543+
// @Param request body dto.AgentIDReq true "request"
544544
// @Success 200 {object} dto.AgentQQBotConfig
545545
// @Security ApiKeyAuth
546546
// @Security Timestamp
547547
// @Router /ai/agents/channel/qqbot/get [post]
548548
func (b *BaseApi) GetAgentQQBotConfig(c *gin.Context) {
549-
var req dto.AgentQQBotConfigReq
549+
var req dto.AgentIDReq
550550
if err := helper.CheckBindAndValidate(&req, c); err != nil {
551551
return
552552
}
@@ -622,13 +622,13 @@ func (b *BaseApi) CheckAgentPlugin(c *gin.Context) {
622622
// @Tags AI
623623
// @Summary Get Agent Security config
624624
// @Accept json
625-
// @Param request body dto.AgentSecurityConfigReq true "request"
625+
// @Param request body dto.AgentIDReq true "request"
626626
// @Success 200 {object} dto.AgentSecurityConfig
627627
// @Security ApiKeyAuth
628628
// @Security Timestamp
629629
// @Router /ai/agents/security/get [post]
630630
func (b *BaseApi) GetAgentSecurityConfig(c *gin.Context) {
631-
var req dto.AgentSecurityConfigReq
631+
var req dto.AgentIDReq
632632
if err := helper.CheckBindAndValidate(&req, c); err != nil {
633633
return
634634
}
@@ -663,13 +663,13 @@ func (b *BaseApi) UpdateAgentSecurityConfig(c *gin.Context) {
663663
// @Tags AI
664664
// @Summary Get Agent Other config
665665
// @Accept json
666-
// @Param request body dto.AgentOtherConfigReq true "request"
666+
// @Param request body dto.AgentIDReq true "request"
667667
// @Success 200 {object} dto.AgentOtherConfig
668668
// @Security ApiKeyAuth
669669
// @Security Timestamp
670670
// @Router /ai/agents/other/get [post]
671671
func (b *BaseApi) GetAgentOtherConfig(c *gin.Context) {
672-
var req dto.AgentOtherConfigReq
672+
var req dto.AgentIDReq
673673
if err := helper.CheckBindAndValidate(&req, c); err != nil {
674674
return
675675
}
@@ -745,13 +745,13 @@ func (b *BaseApi) UpdateAgentConfigFile(c *gin.Context) {
745745
// @Tags AI
746746
// @Summary List Agent skills
747747
// @Accept json
748-
// @Param request body dto.AgentSkillsReq true "request"
748+
// @Param request body dto.AgentIDReq true "request"
749749
// @Success 200 {array} dto.AgentSkillItem
750750
// @Security ApiKeyAuth
751751
// @Security Timestamp
752752
// @Router /ai/agents/skills/list [post]
753753
func (b *BaseApi) ListAgentSkills(c *gin.Context) {
754-
var req dto.AgentSkillsReq
754+
var req dto.AgentIDReq
755755
if err := helper.CheckBindAndValidate(&req, c); err != nil {
756756
return
757757
}

agent/app/dto/agents.go

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ type AgentOverviewReq struct {
7373
AgentID uint `json:"agentId" validate:"required"`
7474
}
7575

76+
type AgentIDReq struct {
77+
AgentID uint `json:"agentId" validate:"required"`
78+
}
79+
7680
type AgentOverview struct {
7781
Snapshot AgentOverviewSnapshot `json:"snapshot"`
7882
}
@@ -237,10 +241,6 @@ type AgentChannelPairingApproveReq struct {
237241
PairingCode string `json:"pairingCode" validate:"required"`
238242
}
239243

240-
type AgentWecomConfigReq struct {
241-
AgentID uint `json:"agentId" validate:"required"`
242-
}
243-
244244
type AgentWecomConfigUpdateReq struct {
245245
AgentID uint `json:"agentId" validate:"required"`
246246
Enabled bool `json:"enabled"`
@@ -257,10 +257,6 @@ type AgentWecomConfig struct {
257257
Installed bool `json:"installed"`
258258
}
259259

260-
type AgentDingTalkConfigReq struct {
261-
AgentID uint `json:"agentId" validate:"required"`
262-
}
263-
264260
type AgentDingTalkConfigUpdateReq struct {
265261
AgentID uint `json:"agentId" validate:"required"`
266262
Enabled bool `json:"enabled"`
@@ -288,10 +284,6 @@ type AgentWeixinLoginReq struct {
288284
TaskID string `json:"taskID" validate:"required"`
289285
}
290286

291-
type AgentQQBotConfigReq struct {
292-
AgentID uint `json:"agentId" validate:"required"`
293-
}
294-
295287
type AgentQQBotConfigUpdateReq struct {
296288
AgentID uint `json:"agentId" validate:"required"`
297289
Enabled bool `json:"enabled"`
@@ -321,10 +313,6 @@ type AgentPluginStatus struct {
321313
Installed bool `json:"installed"`
322314
}
323315

324-
type AgentDiscordConfigReq struct {
325-
AgentID uint `json:"agentId" validate:"required"`
326-
}
327-
328316
type AgentDiscordConfigUpdateReq struct {
329317
AgentID uint `json:"agentId" validate:"required"`
330318
Enabled bool `json:"enabled"`
@@ -342,10 +330,6 @@ type AgentDiscordConfig struct {
342330
Proxy string `json:"proxy"`
343331
}
344332

345-
type AgentSecurityConfigReq struct {
346-
AgentID uint `json:"agentId" validate:"required"`
347-
}
348-
349333
type AgentSecurityConfigUpdateReq struct {
350334
AgentID uint `json:"agentId" validate:"required"`
351335
AllowedOrigins []string `json:"allowedOrigins"`
@@ -355,10 +339,6 @@ type AgentSecurityConfig struct {
355339
AllowedOrigins []string `json:"allowedOrigins"`
356340
}
357341

358-
type AgentOtherConfigReq struct {
359-
AgentID uint `json:"agentId" validate:"required"`
360-
}
361-
362342
type AgentOtherConfigUpdateReq struct {
363343
AgentID uint `json:"agentId" validate:"required"`
364344
UserTimezone string `json:"userTimezone" validate:"required"`
@@ -385,10 +365,6 @@ type AgentConfigFile struct {
385365
Content string `json:"content"`
386366
}
387367

388-
type AgentSkillsReq struct {
389-
AgentID uint `json:"agentId" validate:"required"`
390-
}
391-
392368
type AgentSkillSearchReq struct {
393369
AgentID uint `json:"agentId" validate:"required"`
394370
Source string `json:"source" validate:"required,oneof=clawhub skillhub"`

agent/app/service/agents.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ type IAgentService interface {
3232
UpdateModelConfig(req dto.AgentModelConfigUpdateReq) error
3333
GetOverview(req dto.AgentOverviewReq) (*dto.AgentOverview, error)
3434
GetProviders() ([]dto.ProviderInfo, error)
35-
GetSecurityConfig(req dto.AgentSecurityConfigReq) (*dto.AgentSecurityConfig, error)
35+
GetSecurityConfig(req dto.AgentIDReq) (*dto.AgentSecurityConfig, error)
3636
UpdateSecurityConfig(req dto.AgentSecurityConfigUpdateReq) error
37-
GetOtherConfig(req dto.AgentOtherConfigReq) (*dto.AgentOtherConfig, error)
37+
GetOtherConfig(req dto.AgentIDReq) (*dto.AgentOtherConfig, error)
3838
UpdateOtherConfig(req dto.AgentOtherConfigUpdateReq) error
3939
GetConfigFile(req dto.AgentConfigFileReq) (*dto.AgentConfigFile, error)
4040
UpdateConfigFile(req dto.AgentConfigFileUpdateReq) error
41-
ListSkills(req dto.AgentSkillsReq) ([]dto.AgentSkillItem, error)
41+
ListSkills(req dto.AgentIDReq) ([]dto.AgentSkillItem, error)
4242
SearchSkills(req dto.AgentSkillSearchReq) ([]dto.AgentSkillSearchItem, error)
4343
UpdateSkill(req dto.AgentSkillUpdateReq) error
4444
InstallSkill(req dto.AgentSkillInstallReq) error
@@ -58,14 +58,14 @@ type IAgentService interface {
5858
UpdateFeishuConfig(req dto.AgentFeishuConfigUpdateReq) error
5959
GetTelegramConfig(req dto.AgentTelegramConfigReq) (*dto.AgentTelegramConfig, error)
6060
UpdateTelegramConfig(req dto.AgentTelegramConfigUpdateReq) error
61-
GetDiscordConfig(req dto.AgentDiscordConfigReq) (*dto.AgentDiscordConfig, error)
61+
GetDiscordConfig(req dto.AgentIDReq) (*dto.AgentDiscordConfig, error)
6262
UpdateDiscordConfig(req dto.AgentDiscordConfigUpdateReq) error
63-
GetWecomConfig(req dto.AgentWecomConfigReq) (*dto.AgentWecomConfig, error)
63+
GetWecomConfig(req dto.AgentIDReq) (*dto.AgentWecomConfig, error)
6464
UpdateWecomConfig(req dto.AgentWecomConfigUpdateReq) error
65-
GetDingTalkConfig(req dto.AgentDingTalkConfigReq) (*dto.AgentDingTalkConfig, error)
65+
GetDingTalkConfig(req dto.AgentIDReq) (*dto.AgentDingTalkConfig, error)
6666
UpdateDingTalkConfig(req dto.AgentDingTalkConfigUpdateReq) error
6767
LoginWeixinChannel(req dto.AgentWeixinLoginReq) error
68-
GetQQBotConfig(req dto.AgentQQBotConfigReq) (*dto.AgentQQBotConfig, error)
68+
GetQQBotConfig(req dto.AgentIDReq) (*dto.AgentQQBotConfig, error)
6969
UpdateQQBotConfig(req dto.AgentQQBotConfigUpdateReq) error
7070
InstallPlugin(req dto.AgentPluginInstallReq) error
7171
CheckPlugin(req dto.AgentPluginCheckReq) (*dto.AgentPluginStatus, error)
@@ -640,7 +640,7 @@ func (a AgentService) DeleteAccount(req dto.AgentAccountDeleteReq) error {
640640
return agentAccountRepo.DeleteByID(req.ID)
641641
}
642642

643-
func (a AgentService) GetSecurityConfig(req dto.AgentSecurityConfigReq) (*dto.AgentSecurityConfig, error) {
643+
func (a AgentService) GetSecurityConfig(req dto.AgentIDReq) (*dto.AgentSecurityConfig, error) {
644644
agent, _, err := a.loadOpenclawAgentAndInstall(req.AgentID)
645645
if err != nil {
646646
return nil, err
@@ -679,7 +679,7 @@ func (a AgentService) UpdateSecurityConfig(req dto.AgentSecurityConfigUpdateReq)
679679
return appInstallRepo.Save(context.Background(), install)
680680
}
681681

682-
func (a AgentService) GetOtherConfig(req dto.AgentOtherConfigReq) (*dto.AgentOtherConfig, error) {
682+
func (a AgentService) GetOtherConfig(req dto.AgentIDReq) (*dto.AgentOtherConfig, error) {
683683
agent, install, err := a.loadAgentAndInstall(req.AgentID)
684684
if err != nil {
685685
return nil, err

agent/app/service/agents_channels.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (a AgentService) UpdateTelegramConfig(req dto.AgentTelegramConfigUpdateReq)
5858
})
5959
}
6060

61-
func (a AgentService) GetDiscordConfig(req dto.AgentDiscordConfigReq) (*dto.AgentDiscordConfig, error) {
61+
func (a AgentService) GetDiscordConfig(req dto.AgentIDReq) (*dto.AgentDiscordConfig, error) {
6262
_, _, conf, err := a.loadAgentConfig(req.AgentID)
6363
if err != nil {
6464
return nil, err
@@ -80,7 +80,7 @@ func (a AgentService) UpdateDiscordConfig(req dto.AgentDiscordConfigUpdateReq) e
8080
})
8181
}
8282

83-
func (a AgentService) GetQQBotConfig(req dto.AgentQQBotConfigReq) (*dto.AgentQQBotConfig, error) {
83+
func (a AgentService) GetQQBotConfig(req dto.AgentIDReq) (*dto.AgentQQBotConfig, error) {
8484
_, install, conf, err := a.loadAgentConfig(req.AgentID)
8585
if err != nil {
8686
return nil, err
@@ -102,7 +102,7 @@ func (a AgentService) UpdateQQBotConfig(req dto.AgentQQBotConfigUpdateReq) error
102102
})
103103
}
104104

105-
func (a AgentService) GetWecomConfig(req dto.AgentWecomConfigReq) (*dto.AgentWecomConfig, error) {
105+
func (a AgentService) GetWecomConfig(req dto.AgentIDReq) (*dto.AgentWecomConfig, error) {
106106
_, install, conf, err := a.loadAgentConfig(req.AgentID)
107107
if err != nil {
108108
return nil, err
@@ -125,7 +125,7 @@ func (a AgentService) UpdateWecomConfig(req dto.AgentWecomConfigUpdateReq) error
125125
})
126126
}
127127

128-
func (a AgentService) GetDingTalkConfig(req dto.AgentDingTalkConfigReq) (*dto.AgentDingTalkConfig, error) {
128+
func (a AgentService) GetDingTalkConfig(req dto.AgentIDReq) (*dto.AgentDingTalkConfig, error) {
129129
_, install, conf, err := a.loadAgentConfig(req.AgentID)
130130
if err != nil {
131131
return nil, err

agent/app/service/agents_skills.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type skillhubSearchPayload struct {
3636

3737
var clawhubSearchLinePattern = regexp.MustCompile(`^(\S+)\s+(.+?)\s+\(([\d.]+)\)$`)
3838

39-
func (a AgentService) ListSkills(req dto.AgentSkillsReq) ([]dto.AgentSkillItem, error) {
39+
func (a AgentService) ListSkills(req dto.AgentIDReq) ([]dto.AgentSkillItem, error) {
4040
_, install, err := a.loadOpenclawAgentAndInstall(req.AgentID)
4141
if err != nil {
4242
return nil, err

agent/init/migration/migrations/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ SET http_port = https_port,
11461146
WHERE version = ?
11471147
AND https_port > 0
11481148
AND app_id IN (SELECT id FROM apps WHERE key = ?)`,
1149-
"2026.3.23",
1149+
"2026.3.24",
11501150
constant.AppOpenclaw,
11511151
).Error
11521152
},

agent/init/migration/migrations/utils/agent_account_model_pool.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
"github.com/1Panel-dev/1Panel/agent/app/dto"
88
"github.com/1Panel-dev/1Panel/agent/app/model"
9+
providercatalog "github.com/1Panel-dev/1Panel/agent/app/provider"
910
"github.com/1Panel-dev/1Panel/agent/app/service"
1011

1112
"gorm.io/gorm"
@@ -107,5 +108,27 @@ func buildMigratedAgentAccountModels(tx *gorm.DB, account *legacyAgentAccountMod
107108
}
108109
return nil, err
109110
}
111+
applyLegacyAgentAccountModelDefaults(account.Provider, models)
110112
return models, nil
111113
}
114+
115+
func applyLegacyAgentAccountModelDefaults(provider string, models []dto.AgentAccountModel) {
116+
if provider != "custom" && provider != "ollama" && provider != "vllm" {
117+
return
118+
}
119+
meta, ok := providercatalog.Get(provider)
120+
if !ok {
121+
return
122+
}
123+
for i := range models {
124+
if strings.TrimSpace(models[i].Name) == "" {
125+
models[i].Name = strings.TrimSpace(models[i].ID)
126+
}
127+
if models[i].ContextWindow <= 0 {
128+
models[i].ContextWindow = meta.Default.ContextWindow
129+
}
130+
if models[i].MaxTokens <= 0 {
131+
models[i].MaxTokens = meta.Default.MaxTokens
132+
}
133+
}
134+
}

frontend/src/components/log/task/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const config = reactive({
4444
const open = ref(false);
4545
const showTail = ref(true);
4646
47-
const openWithTaskID = (id: string, tail: boolean, operateNode?: string) => {
47+
const openWithTaskID = (id: string, tail?: boolean, operateNode?: string) => {
4848
config.taskID = id;
4949
if (tail === undefined) {
5050
config.tail = true;

frontend/src/views/ai/agents/agent/components/overview.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ defineExpose({
111111
color: var(--el-text-color-primary);
112112
}
113113
:deep(.status-count) {
114+
font-size: 18px;
114115
color: var(--el-text-color-primary);
115116
}
116117
:deep(.status-label) {

frontend/src/views/ai/agents/agent/config/tabs/skills.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262
@change="(value) => toggleSkill(skill, Boolean(value))"
6363
/>
6464
</div>
65-
<el-tooltip placement="top-start" :show-after="200" popper-class="skill-desc-tooltip">
65+
<el-tooltip
66+
placement="bottom-start"
67+
:show-after="200"
68+
popper-class="skill-desc-tooltip"
69+
>
6670
<template #content>
6771
<div class="skill-desc-tooltip-content">{{ skill.description }}</div>
6872
</template>
@@ -101,7 +105,7 @@
101105
</div>
102106
<el-tooltip
103107
v-if="skill.description || skill.summary"
104-
placement="top-start"
108+
placement="bottom-start"
105109
:show-after="200"
106110
popper-class="skill-desc-tooltip"
107111
>

0 commit comments

Comments
 (0)