feat(admin): Agent 并发 - 后台可调同时对话上限并展示 Agent 服务状态
新增运行策略 agentMaxSessions(默认 30,范围 1-64),保存后同时下发到内嵌进程闸门与独立 yingce-agent 的 /v1/limit,降低上限不会中断已开始的对话。系统性能页展示 Agent 服务健康、进行中/排队数量,并可直接修改上限。
This commit is contained in:
@@ -24,6 +24,25 @@ func fakeRuntime(t *testing.T, script string) {
|
||||
t.Setenv("CANVAS_PI_RUNTIME_DIR", dir)
|
||||
}
|
||||
|
||||
func TestSetProcessLimitDoesNotStopActiveWork(t *testing.T) {
|
||||
t.Cleanup(func() { SetProcessLimit(defaultAgentProcessLimit) })
|
||||
release, err := acquireAgentProcess(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
active, limit := SetProcessLimit(1)
|
||||
if active != 1 || limit != 1 {
|
||||
t.Fatalf("active=%d limit=%d, want active 1 and limit 1", active, limit)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Millisecond)
|
||||
defer cancel()
|
||||
if _, err := acquireAgentProcess(ctx); err == nil {
|
||||
t.Fatal("lowered limit still admitted another process")
|
||||
}
|
||||
release()
|
||||
SetProcessLimit(defaultAgentProcessLimit)
|
||||
}
|
||||
|
||||
func noopBridge() Bridge {
|
||||
handler := func(context.Context, map[string]json.RawMessage) (any, error) { return map[string]any{"ok": true}, nil }
|
||||
return Bridge{Model: handler, Tool: handler, Event: handler}
|
||||
|
||||
Reference in New Issue
Block a user