feat(admin): Agent 并发 - 后台可调同时对话上限并展示 Agent 服务状态
新增运行策略 agentMaxSessions(默认 30,范围 1-64),保存后同时下发到内嵌进程闸门与独立 yingce-agent 的 /v1/limit,降低上限不会中断已开始的对话。系统性能页展示 Agent 服务健康、进行中/排队数量,并可直接修改上限。
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -166,6 +167,7 @@ func (s *Service) StartWorker() {
|
||||
s.startResourceDeletionWorker(ctx)
|
||||
s.startSkillSyncWorker(ctx)
|
||||
s.startPaymentWorker(ctx)
|
||||
go s.syncAgentSessionLimit()
|
||||
s.runWorkerLoop(func(ctx context.Context) {
|
||||
ticker := time.NewTicker(3 * time.Second)
|
||||
defer ticker.Stop()
|
||||
@@ -180,6 +182,19 @@ func (s *Service) StartWorker() {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Service) syncAgentSessionLimit() {
|
||||
policy, err := s.RuntimePolicy()
|
||||
if err != nil {
|
||||
slog.Warn("agent session limit load failed", "error", err)
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
if err := s.applyAgentSessionLimit(ctx, policy.Task.AgentMaxSessions); err != nil {
|
||||
slog.Warn("agent session limit apply failed", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) BeginDrain() { s.backgroundWorkers().BeginDrain() }
|
||||
|
||||
func (s *Service) StopWorker(ctx context.Context) error { return s.backgroundWorkers().Stop(ctx) }
|
||||
|
||||
Reference in New Issue
Block a user