Commit 98e8391f by sunqi02

消除歧义,避免调用sub agent失败

1 parent 7be83f49
...@@ -119,7 +119,10 @@ class AgentHub: ...@@ -119,7 +119,10 @@ class AgentHub:
continue continue
if allowed_agent_codes is not None and code not in allowed_agent_codes: if allowed_agent_codes is not None and code not in allowed_agent_codes:
continue continue
duty_lines.append(f"- {agent.name}({agent.role}): {agent.prompt_template}") duty_lines.append(
f"- {agent.name}({agent.role},调用码: {code}): "
f"{agent.prompt_template}"
)
duties_text = "\n".join(duty_lines) if duty_lines else "暂无子Agent" duties_text = "\n".join(duty_lines) if duty_lines else "暂无子Agent"
...@@ -294,7 +297,11 @@ class AgentHub: ...@@ -294,7 +297,11 @@ class AgentHub:
async def _call_sub_agent(self, agent_code: str, instruction: str) -> str: async def _call_sub_agent(self, agent_code: str, instruction: str) -> str:
"""通过 ReActAgent 调用子 Agent。""" """通过 ReActAgent 调用子 Agent。"""
if agent_code not in self.agents: if agent_code not in self.agents:
return f"错误:子 Agent '{agent_code}' 不存在" valid = [c for c in self.agents if c != "main"]
return (
f"错误:子 Agent '{agent_code}' 不存在。"
f"可用调用码: {valid}"
)
sub_prompt = self._build_sub_agent_prompt(agent_code, {}) sub_prompt = self._build_sub_agent_prompt(agent_code, {})
sub_memory = InMemoryMemory() sub_memory = InMemoryMemory()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!