Hello, I have created a supervisor agent and things are working, but my supervisor is not aware of the sub-agent and specifically the tools that the sub-agent has. How can I resolve this?
I assume you create the supervisor somewhat like this (supervisor readme):
workflow = create_supervisor(
[research_agent, math_agent],
model=model,
prompt=(
"You are a team supervisor managing a research expert and a math expert. "
"For current events, use research_agent. "
"For math problems, use math_agent."
)
)
I think you should either:
- Make it clear in the prompt of the supervisor who he supervises and what the sub-graphs can do.
- Make the name of the subagent clear of it’s capabilities (i.e `math_agent`)
- Create custom handoff messages with a clear description of the sub-agent capabilities. This will appear to the supervisor as the description of the handoff tools. (GitHub - langchain-ai/langgraph-supervisor-py)
In either of above cases, you can only implicitly tell the supervisor what tools the sub-agents have. Binding the tools to the supervisor itself will not work as the supervisor would think it has accces to them itself.
Hope that helps you.
Yes, i have created like this.
class SupervisorAgent:
def __init__(self):
intelligence_manager = asyncio.run(setup_intelligence_manager(temperature=0.4, streaming=True))
self.llm = asyncio.run(intelligence_manager.get_chat_model())
def build(self):
# Create supervisor workflow
NAME_SUPERVISOR_AGENT="supervisor_agent"
# Pass the forwarding tool along with any other custom or default handoff tools
forwarding_tool = create_forward_message_tool(NAME_SUPERVISOR_AGENT)
workflow = create_supervisor(
[EndeavorAgentGraph, DocumentAgentGraph],
model=self.llm,
prompt=(
"You are a planning supervisor agent managing other agent agents:\n"
f"- a {ENDEAVOR_AGENT_NAME} this agent have ability to extract information from ENDEAVOR, DB2 & Cobol related information. assign related tasks to this agent\n"
f"- a {DOCUMENT_AGENT_NAME}. This agent can make a document using cobol code and other metadata. Assign document-related tasks to this agent\n"
"Assign work to one agent at a time, do not call agents in parallel.\n"
"Do not do any work yourself, your responsibility is to plan what agents need to do and assign tasks to them, till then you can get all the info to answer user query\n"
),
supervisor_name=NAME_SUPERVISOR_AGENT,
output_mode="full_history",
add_handoff_messages=True,
#handoff_tool_prefix="delegate_to",
tools=[transfer_to_endeavor_assistant, transfer_to_document_assistant, transfer_to_autoexplain_assistant],
)
graph = workflow.compile()
return graph
supervisor_agent = SupervisorAgent()
graph=supervisor_agent.build()
Each agent have set of tools that created like this.
# ------------------------------------------------------------------
# Agent Handoff Tools
# ------------------------------------------------------------------
transfer_to_autoexplain_assistant = create_handoff_tool(
name=AUTOEXPLAIN_AGENT_NAME,
agent_name=AUTOEXPLAIN_AGENT_NAME,
description="Handoff to the AutoExplain agent for COBOL code explanations and documentation."
)
transfer_to_endeavor_assistant = create_handoff_tool(
name=ENDEAVOR_AGENT_NAME,
agent_name=ENDEAVOR_AGENT_NAME,
description="Handoff to the Endeavor agent for COBOL code and Endevor-related tasks."
)
transfer_to_document_assistant = create_handoff_tool(
name=DOCUMENT_AGENT_NAME,
agent_name=DOCUMENT_AGENT_NAME,
description="Handoff to the Document agent for COBOL code documentation generation."
)
# -----------------------------------------------------------------
# Tool Collections by Agent
# -----------------------------------------------------------------
ENDEAVOR_TOOLS = [
get_cobol_code_tool,
get_cobol_code_metadata,
get_db2_table_schema,
transfer_to_autoexplain_assistant,
transfer_to_document_assistant
]
ENDEAVOR_TOOLS_BY_NAME = {tool.name: tool for tool in ENDEAVOR_TOOLS}
DOCUMENT_TOOLS = [
create_cobol_document_tool,
transfer_to_autoexplain_assistant
]
DOCUMENT_TOOLS_BY_NAME = {tool.name: tool for tool in DOCUMENT_TOOLS}```
Okay, interesting. What did you specifically mean by “things are working” in your original message?
Is the supervisor able to transfer to sub-agents, but just the wrong one or not at all?
Perhaps sharing some chat-screenshots or LangSmith traces would be helpful.