Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Pydantic AI is still pre-version 1, so breaking changes will occur, however:
!!! note
Here's a filtered list of the breaking changes for each version to help you upgrade Pydantic AI.

### v0.6.0 (2025-08-06)

See [#2440](https://github.com/pydantic/pydantic-ai/pull/2440) - The `next` method was removed from the `Graph` class. Use `async with graph.iter(...) as run: run.next()` instead.

### v0.5.0 (2025-08-04)

See [#2388](https://github.com/pydantic/pydantic-ai/pull/2388) - The `source` field of an `EvaluationResult` is now of type `EvaluatorSpec` rather than the actual source `Evaluator` instance, to help with serialization/deserialization.
Expand Down
38 changes: 0 additions & 38 deletions pydantic_graph/pydantic_graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import logfire_api
import typing_extensions
from typing_extensions import deprecated
from typing_inspection import typing_objects

from . import _utils, exceptions, mermaid
Expand Down Expand Up @@ -342,43 +341,6 @@ async def initialize(
persistence.set_graph_types(self)
await persistence.snapshot_node(state, node)

@deprecated('`next` is deprecated, use `async with graph.iter(...) as run: run.next()` instead')
async def next(
self,
node: BaseNode[StateT, DepsT, RunEndT],
persistence: BaseStatePersistence[StateT, RunEndT],
*,
state: StateT = None,
deps: DepsT = None,
infer_name: bool = True,
) -> BaseNode[StateT, DepsT, Any] | End[RunEndT]:
"""Run a node in the graph and return the next node to run.

Args:
node: The node to run.
persistence: State persistence interface, defaults to
[`SimpleStatePersistence`][pydantic_graph.SimpleStatePersistence] if `None`.
state: The current state of the graph.
deps: The dependencies of the graph.
infer_name: Whether to infer the graph name from the calling frame.

Returns:
The next node to run or [`End`][pydantic_graph.nodes.End] if the graph has finished.
"""
if infer_name and self.name is None:
self._infer_name(inspect.currentframe())

persistence.set_graph_types(self)
run = GraphRun[StateT, DepsT, RunEndT](
graph=self,
start_node=node,
persistence=persistence,
state=state,
deps=deps,
traceparent=None,
)
return await run.next(node)

def mermaid_code(
self,
*,
Expand Down
33 changes: 0 additions & 33 deletions tests/graph/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,39 +401,6 @@ async def run(self, ctx: GraphRunContext) -> End[None]:
await run.next()


async def test_next(mock_snapshot_id: object):
@dataclass
class Foo(BaseNode):
async def run(self, ctx: GraphRunContext) -> Bar:
return Bar()

@dataclass
class Bar(BaseNode):
async def run(self, ctx: GraphRunContext) -> Foo:
return Foo() # pragma: no cover

g = Graph(nodes=(Foo, Bar))
assert g.name is None
sp = FullStatePersistence()
with pytest.warns(DeprecationWarning, match='`next` is deprecated, use `async with graph.iter(...)'):
n = await g.next(Foo(), persistence=sp) # pyright: ignore[reportDeprecated]
assert n == Bar()
assert g.name == 'g'
assert sp.history == snapshot(
[
NodeSnapshot(
state=None,
node=Foo(),
start_ts=IsNow(tz=timezone.utc),
duration=IsFloat(),
status='success',
id='Foo:1',
),
NodeSnapshot(state=None, node=Bar(), id='Bar:2'),
]
)


async def test_deps(mock_snapshot_id: object):
@dataclass
class Deps:
Expand Down