langgraph 0.3.7
Summary of Changes
- Fixed handling of subgraphs with a single node in Graph.add_edge (#3780)
- Added proper Pydantic model validation for graph inputs, with support for both Pydantic v1 and v2 (#3782)
Detailed Changes
langgraph.graph.graph.Graph
- Modified
add_edgemethod to allow adding edges to subgraphs with a single node, changing the condition fromlen(subgraph.nodes) > 1tolen(subgraph.nodes) >= 1(#3780)
langgraph.graph.state.StateGraph and langgraph.graph.state.CompiledStateGraph
- Added support for properly validating input against Pydantic models during state graph execution
- Added specialized handling for both Pydantic v1 and v2 models by using their respective constructor methods (
constructvsmodel_construct) - Improved state coercion with the new
_pick_mapperfunction that correctly handles different schema types (#3782)
langgraph.pregel.Pregel
- Added
input_modelsupport to allow for proper Pydantic model validation of inputs - Modified
get_input_schemato prioritize the input model when available - Updated both synchronous and asynchronous execution paths to pass the input model for validation (#3782)
langgraph.pregel.loop.PregelLoop
- Added validation logic for input data against provided Pydantic models
- Improved handling of resuming executions by properly setting input status
- Enhanced input processing to ensure validation happens at the appropriate time (#3782)