From 37d3dcb0cb7e3892a2848bf7ba64e32f000e5f60 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sun, 17 May 2026 21:41:58 +0800 Subject: [PATCH] auto-sync: 2026-05-17 21:41:58 --- src/main.py | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/main.py b/src/main.py index 499b153..4868b5e 100644 --- a/src/main.py +++ b/src/main.py @@ -118,13 +118,49 @@ async def lifespan(app: FastAPI): max_global=daemon_config.get("max_global_agents", 5), max_per_agent=daemon_config.get("max_per_agent", 2), ) - registered_agents = daemon_config.get("registered_agents", []) - capability_map = daemon_config.get("capability_map", {}) + + # 构建 Agent 能力画像(v2.6.1 路由) + agent_profiles_config = daemon_config.get("agent_profiles", {}) + agent_profiles = {} + for aid, prof in agent_profiles_config.items(): + agent_profiles[aid] = AgentProfile( + agent_id=aid, + capabilities=prof.get("capabilities", []), + can_review=prof.get("can_review", False), + max_concurrent=prof.get("max_concurrent", 1), + is_fallback=prof.get("is_fallback", False), + ) + + # 构建 LLM Driver(Mode A 路由) + routing_config = daemon_config.get("routing", {}) + llm_driver = None + routing_model = routing_config.get("model", "") + if routing_model: + llm_driver = LLMDriver( + model=routing_model, + api_base=routing_config.get("api_base", ""), + api_key=routing_config.get("api_key", ""), + timeout=routing_config.get("timeout", 5.0), + max_tokens=routing_config.get("max_tokens", 200), + temperature=routing_config.get("temperature", 0.1), + ) + logger.info("LLM routing driver initialized (model=%s)", routing_model) + + # 构建 Router + Dispatcher + router = AgentRouter( + agent_profiles=agent_profiles, + llm_driver=llm_driver, + counter=counter, + ) + + # 获取项目级 DB 路径(用于路由审计日志) + default_db_path = DATA_ROOT / "default" / "blackboard.db" + dispatcher = Dispatcher( - registered_agents=registered_agents, + router=router, spawner=spawner, counter=counter, - capability_map=capability_map, + db_path=default_db_path, ) ticker = Ticker(