Commit 112555e1 by sunqi02 Committed by 胡悦

Revert "feat(agent_hub): 新增子Agent职责摘要功能,优化职责描述生成逻辑"

This reverts commit 932bfbd1.
1 parent 422fa3fe
......@@ -99,8 +99,6 @@ async def lifespan(app: FastAPI):
preloaded_agents=agents,
)
await agent_hub_instance.summarize_agent_duties()
# ── MessageGate 实例化 ──
from app.service.message_gate import MessageGate
from app.hooks.post_reply import PostReplyHook
......
......@@ -247,9 +247,6 @@ class AgentHub:
group_name="basic",
)
# 子 Agent 职责摘要缓存(由 summarize_agent_duties() 填充)
self.agent_duty_summaries: Dict[str, str] = {}
# 构建每个 agent 的专属 toolkit(按 skills 字段过滤)
self.agent_toolkits: Dict[str, Toolkit] = {}
for agent_code, agent_config in self.agents.items():
......@@ -309,34 +306,6 @@ class AgentHub:
return key
raise AgentHubError("未找到主 Agent(is_steward=True)")
async def summarize_agent_duties(self):
"""启动时用模型将每个子 Agent 的完整 prompt 总结为一句职责描述。"""
for code, agent in self.agents.items():
if agent.is_steward:
continue
if not agent.prompt:
self.agent_duty_summaries[code] = agent.name
continue
try:
system_msg = Msg(
"system",
"你是一个系统配置助手。请将以下Agent的完整系统提示词总结为一句职责范围描述(≤30字),只输出描述本身,不要加引号或解释。",
"system",
)
user_msg = Msg("user", agent.prompt, "user")
formatted = await self.formatter.format([system_msg, user_msg])
response = await self.thinking_summary_model(formatted)
text_parts = []
for block in response.content:
if isinstance(block, dict) and block.get("type") == "text":
text_parts.append(block.get("text", ""))
summary = "".join(text_parts).strip()
self.agent_duty_summaries[code] = summary or agent.name
logger.info("子Agent职责摘要完成: code=%s name=%s summary=%s", code, agent.name, summary)
except Exception:
logger.warning("子Agent职责摘要失败,回退用name: code=%s", code, exc_info=True)
self.agent_duty_summaries[code] = agent.name
def _build_main_prompt(
self,
allowed_agent_codes: Optional[list] = None,
......@@ -355,8 +324,7 @@ class AgentHub:
continue
if allowed_agent_codes is not None and code not in allowed_agent_codes:
continue
duty = self.agent_duty_summaries.get(code) or f"{agent.name}相关任务"
sub_lines.append(f"- {agent.name}(调用码: {code}): {duty}")
sub_lines.append(f"- {agent.name}(调用码: {code}): {agent.name}相关任务")
if sub_lines:
prompt += "\n\n## 可调用的子Agent\n" + "\n".join(sub_lines)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!