11from langgraph .graph import START , MessagesState , StateGraph
22from langgraph .graph .state import CompiledStateGraph
3- from typing_extensions import Literal , Optional , Type , TypeVar , Union , get_args , get_origin
3+ from typing_extensions import Any , Literal , Optional , Type , TypeVar , Union , get_args , get_origin
44
55from langgraph_swarm .handoff import get_handoff_destinations
66
@@ -90,13 +90,16 @@ def create_swarm(
9090 * ,
9191 default_active_agent : str ,
9292 state_schema : StateSchemaType = SwarmState ,
93+ config_schema : Type [Any ] | None = None ,
9394) -> StateGraph :
9495 """Create a multi-agent swarm.
9596
9697 Args:
9798 agents: List of agents to add to the swarm
9899 default_active_agent: Name of the agent to route to by default (if no agents are currently active).
99100 state_schema: State schema to use for the multi-agent graph.
101+ config_schema: An optional schema for configuration.
102+ Use this to expose configurable parameters via supervisor.config_specs.
100103
101104 Returns:
102105 A multi-agent swarm StateGraph.
@@ -107,7 +110,7 @@ def create_swarm(
107110
108111 agent_names = [agent .name for agent in agents ]
109112 state_schema = _update_state_schema_agent_names (state_schema , agent_names )
110- builder = StateGraph (state_schema )
113+ builder = StateGraph (state_schema , config_schema )
111114 add_active_agent_router (
112115 builder ,
113116 route_to = agent_names ,
0 commit comments