auto-sync: 2026-05-29 22:22:19

This commit is contained in:
cfdaily
2026-05-29 22:22:19 +08:00
parent b0bd78dc34
commit 1c96f2141d
+28
View File
@@ -255,6 +255,29 @@ class AgentSpawner:
self._compact_waits: Dict[str, int] = {}
# B1 假死计数器 {task_id: count}
self._stuck_counts: Dict[str, int] = {}
self._valid_agents_cache: Optional[set] = None
def _load_valid_agents(self) -> set:
"""从 config/default.yaml 读取有效 Agent ID 列表(带缓存)"""
if self._valid_agents_cache is not None:
return self._valid_agents_cache
config_path = Path(__file__).parent.parent / "config" / "default.yaml"
if config_path.exists():
try:
import yaml
with open(config_path) as f:
cfg = yaml.safe_load(f)
profiles = cfg.get("daemon", {}).get("agent_profiles", {})
if profiles:
self._valid_agents_cache = set(profiles.keys())
return self._valid_agents_cache
except Exception:
pass
self._valid_agents_cache = {
"zhangfei-dev", "guanyu-dev", "zhaoyun-data",
"jiangwei-infra", "pangtong-fujunshi", "simayi-challenger"
}
return self._valid_agents_cache
@property
def active_sessions(self) -> Dict[str, Dict[str, Any]]:
@@ -393,6 +416,10 @@ curl -X POST http://{self.api_host}:{self.api_port}/api/projects/{project_id}/ta
safe_title = (title or "").replace('"', '\\"')[:100]
safe_text = (description or "").replace('"', '\\"')
# 获取有效 Agent 列表(从 config/default.yaml 读取)
valid_agents_list = self._load_valid_agents()
valid_agents_str = " / ".join(sorted(valid_agents_list))
common_kwargs = dict(
from_agent=from_agent,
title=safe_title,
@@ -401,6 +428,7 @@ curl -X POST http://{self.api_host}:{self.api_port}/api/projects/{project_id}/ta
agent_id=agent_id,
api_host=self.api_host,
api_port=self.api_port,
valid_agents=valid_agents_str,
)
if performative == "inform":