Skip to content

Commit 0a3f3f0

Browse files
release: v0.0.14 and prep for langgraph v0.6 (#92)
Tests passing locally, waiting for v0.6 to merge.
1 parent 0efaf35 commit 0a3f3f0

File tree

3 files changed

+162
-142
lines changed

3 files changed

+162
-142
lines changed

langgraph_swarm/swarm.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from typing import Literal, Optional, Union, cast, get_args, get_origin
2+
from warnings import warn
23

4+
from langgraph._internal._typing import DeprecatedKwargs
35
from langgraph.graph import START, MessagesState, StateGraph
46
from langgraph.pregel import Pregel
5-
from typing_extensions import Any, TypeVar
7+
from typing_extensions import Any, TypeVar, Unpack
68

79
from langgraph_swarm.handoff import get_handoff_destinations
810

@@ -143,12 +145,13 @@ def route_to_active_agent(state: dict) -> str:
143145
return builder
144146

145147

146-
def create_swarm(
148+
def create_swarm( # noqa: D417
147149
agents: list[Pregel],
148150
*,
149151
default_active_agent: str,
150152
state_schema: StateSchemaType = SwarmState,
151-
config_schema: type[Any] | None = None,
153+
context_schema: type[Any] | None = None,
154+
**deprecated_kwargs: Unpack[DeprecatedKwargs],
152155
) -> StateGraph:
153156
"""Create a multi-agent swarm.
154157
@@ -159,8 +162,7 @@ def create_swarm(
159162
or any other [Pregel](https://langchain-ai.github.io/langgraph/reference/pregel/#langgraph.pregel.Pregel) object.
160163
default_active_agent: Name of the agent to route to by default (if no agents are currently active).
161164
state_schema: State schema to use for the multi-agent graph.
162-
config_schema: An optional schema for configuration.
163-
Use this to expose configurable parameters via `swarm.config_specs`.
165+
context_schema: Specifies the schema for the context object that will be passed to the workflow.
164166
165167
Returns:
166168
A multi-agent swarm StateGraph.
@@ -208,14 +210,22 @@ def add(a: int, b: int) -> int:
208210
```
209211
210212
"""
213+
if (config_schema := deprecated_kwargs.get("config_schema")) is not None:
214+
warn(
215+
"`config_schema` is deprecated. Please use `context_schema` instead.",
216+
DeprecationWarning,
217+
stacklevel=2,
218+
)
219+
context_schema = config_schema # type: ignore[assignment]
220+
211221
active_agent_annotation = state_schema.__annotations__.get("active_agent")
212222
if active_agent_annotation is None:
213223
msg = "Missing required key 'active_agent' in state_schema"
214224
raise ValueError(msg)
215225

216226
agent_names = [agent.name for agent in agents]
217227
state_schema = _update_state_schema_agent_names(state_schema, agent_names)
218-
builder = StateGraph(state_schema, config_schema)
228+
builder = StateGraph(state_schema, context_schema)
219229
add_active_agent_router(
220230
builder,
221231
route_to=agent_names,

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "pdm.backend"
44

55
[project]
66
name = "langgraph-swarm"
7-
version = "0.0.13"
7+
version = "0.0.14"
88
description = "An implementation of a multi-agent swarm using LangGraph"
99
authors = [
1010
{name = "Vadym Barda", email = "19161700+vbarda@users.noreply.github.com "}
@@ -14,7 +14,7 @@ license-files = ["LICENSE"]
1414
readme = "README.md"
1515
requires-python = ">=3.10"
1616
dependencies = [
17-
"langgraph>=0.5",
17+
"langgraph>=0.6.0,<0.7.0",
1818
"langchain-core>=0.3.40,<0.4.0"
1919
]
2020

@@ -68,7 +68,7 @@ check_untyped_defs = true
6868
"tests/**/*.py" = [
6969
# at least this three should be fine in tests:
7070
"S101", # asserts allowed in tests...
71-
"ARG", # Unused function args -> fixtures nevertheless are functionally relevant...
71+
"ARG", # Unused function args -> fixtures nevertheless are functionally relevant
7272
"FBT", # Don't care about booleans as positional arguments in tests, e.g. via @pytest.mark.parametrize()
7373
"D104",
7474
# The below are debateable
@@ -82,4 +82,3 @@ check_untyped_defs = true
8282
"D105", # Missing docstring in magic method
8383
"D415", # First line should end with a period, question mark, or exclamation point
8484
]
85-

0 commit comments

Comments
 (0)