Add multi_agent_chat supervisor agent graph and supervisor prompt.

This commit is contained in:
CREDO23 2026-04-30 00:59:57 +02:00
parent 5a0a265b2b
commit 0fcb2acfdc
3 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,5 @@
"""Supervisor agent graph only; supply routing ``tools`` from ``build_supervisor_routing_tools``."""
from app.agents.multi_agent_chat.supervisor.graph import build_supervisor_agent
__all__ = ["build_supervisor_agent"]

View file

@ -0,0 +1,30 @@
"""Compile the supervisor agent graph (supervisor prompt + caller-supplied routing tools)."""
from __future__ import annotations
from collections.abc import Sequence
import app.agents.multi_agent_chat.supervisor as supervisor_pkg
from langchain.agents import create_agent
from langchain_core.language_models import BaseChatModel
from langchain_core.tools import BaseTool
from langgraph.types import Checkpointer
from app.agents.multi_agent_chat.shared.prompt_loader import read_prompt_md
def build_supervisor_agent(
llm: BaseChatModel,
*,
tools: Sequence[BaseTool],
checkpointer: Checkpointer | None = None,
):
"""Compile the supervisor **agent** (graph). ``tools`` = output of ``build_supervisor_routing_tools``."""
system_prompt = read_prompt_md(supervisor_pkg.__name__, "supervisor_prompt")
return create_agent(
llm,
system_prompt=system_prompt,
tools=list(tools),
checkpointer=checkpointer,
)

View file

@ -0,0 +1 @@
You are the supervisor agent. Route Gmail-related requests through the **gmail** tool and Google Calendar requests through the **calendar** tool, each with a clear task description. Answer directly when no sub-agent is needed. When sub-agents return results, combine them into one coherent reply for the user.