196 lines
8.0 KiB
Gherkin
196 lines
8.0 KiB
Gherkin
Feature: LangGraph Core Functionality
|
|
As a developer
|
|
I want to use LangGraph for complex graph-based agent workflows
|
|
So that I can build reactive agent systems with proper state management
|
|
|
|
Background:
|
|
Given I have imported the necessary modules
|
|
And I have a clean graph test environment
|
|
|
|
Scenario: Initialize basic LangGraph with minimal configuration
|
|
Given I have a GraphConfig with name "test_graph"
|
|
When I create a LangGraph instance
|
|
Then the graph should be initialized successfully
|
|
And the graph should have "start" and "end" nodes
|
|
And the state manager should be initialized
|
|
|
|
Scenario: Initialize LangGraph with custom state class
|
|
Given I have a custom state class
|
|
And I have a GraphConfig with custom state class
|
|
When I create a LangGraph instance with the custom state
|
|
Then the state manager should use the custom state class
|
|
|
|
Scenario: Initialize LangGraph with checkpointing enabled
|
|
Given I have a temporary checkpoint directory
|
|
And I have a GraphConfig with checkpointing enabled
|
|
When I create a LangGraph instance
|
|
Then the state manager should have checkpointing enabled
|
|
|
|
Scenario: Initialize LangGraph with provided scheduler
|
|
Given I have an AsyncIO scheduler for graph
|
|
And I have a GraphConfig with name "scheduled_graph"
|
|
When I create a LangGraph instance with the scheduler
|
|
Then the graph should use the provided scheduler
|
|
|
|
Scenario: Initialize LangGraph with existing stream router
|
|
Given I have a ReactiveStreamRouter instance
|
|
And I have a GraphConfig with name "routed_graph"
|
|
When I create a LangGraph instance with the router
|
|
Then the graph should use the provided router
|
|
|
|
Scenario: Validate graph with invalid entry point
|
|
Given I have a GraphConfig with invalid entry point "nonexistent"
|
|
When I try to create a LangGraph instance
|
|
Then it should raise a ValueError with message "Entry point 'nonexistent' not found"
|
|
|
|
Scenario: Validate graph with invalid edge source
|
|
Given I have a GraphConfig with name "invalid_edge_graph"
|
|
And I add an edge from "nonexistent" to "end"
|
|
When I try to create a LangGraph instance
|
|
Then it should raise a ValueError with message "Edge source 'nonexistent' not found"
|
|
|
|
Scenario: Validate graph with invalid edge target
|
|
Given I have a GraphConfig with name "invalid_target_graph"
|
|
And I add an edge from "start" to "nonexistent"
|
|
When I try to create a LangGraph instance
|
|
Then it should raise a ValueError with message "Edge target 'nonexistent' not found"
|
|
|
|
Scenario: Detect cycles in graph
|
|
Given I have a GraphConfig with cyclic edges
|
|
When I create a LangGraph instance
|
|
Then the graph should detect cycles
|
|
|
|
Scenario: Find parallel execution groups
|
|
Given I have a GraphConfig with parallel execution enabled
|
|
And I have nodes that can execute in parallel
|
|
When I create a LangGraph instance
|
|
Then the graph should identify parallel groups
|
|
|
|
Scenario: Find reachable nodes from entry point
|
|
Given I have a GraphConfig with disconnected nodes
|
|
When I create a LangGraph instance
|
|
Then the graph should warn about unreachable nodes
|
|
|
|
Scenario: Execute graph with message input
|
|
Given I have a GraphConfig with agent nodes
|
|
And I have created a LangGraph instance
|
|
When I execute the graph with message input
|
|
Then the state should be updated with messages
|
|
|
|
Scenario: Execute graph while already running
|
|
Given I have a GraphConfig with name "busy_graph"
|
|
And I have created a LangGraph instance
|
|
And the graph is already running
|
|
When I try to execute the graph again
|
|
Then it should raise a RuntimeError with message "Graph is already running"
|
|
|
|
Scenario: Add node to existing graph
|
|
Given I have a GraphConfig with basic nodes
|
|
And I have created a LangGraph instance
|
|
When I add a new node "processor"
|
|
Then the node should be added successfully
|
|
And the graph should be re-analyzed
|
|
|
|
Scenario: Add duplicate node to graph
|
|
Given I have a GraphConfig with a node "processor"
|
|
And I have created a LangGraph instance
|
|
When I try to add a duplicate node "processor"
|
|
Then it should raise a ValueError with message "Node 'processor' already exists"
|
|
|
|
Scenario: Add edge to existing graph
|
|
Given I have a GraphConfig with nodes "start", "middle", "end"
|
|
And I have created a LangGraph instance
|
|
When I add an edge from "middle" to "end"
|
|
Then the edge should be added successfully
|
|
And the graph should be re-analyzed
|
|
|
|
Scenario: Add edge with invalid source
|
|
Given I have a GraphConfig with basic nodes
|
|
And I have created a LangGraph instance
|
|
When I try to add an edge from "invalid" to "end"
|
|
Then it should raise a ValueError with message "Source node 'invalid' not found"
|
|
|
|
Scenario: Add edge with invalid target
|
|
Given I have a GraphConfig with basic nodes
|
|
And I have created a LangGraph instance
|
|
When I try to add an edge from "start" to "invalid"
|
|
Then it should raise a ValueError with message "Target node 'invalid' not found"
|
|
|
|
Scenario: Get current graph state
|
|
Given I have a GraphConfig with state management
|
|
And I have created a LangGraph instance
|
|
When I get the current state
|
|
Then I should receive the current GraphState
|
|
|
|
Scenario: Get execution history
|
|
Given I have a GraphConfig with tracking enabled
|
|
And I have created a LangGraph instance
|
|
And I have executed some nodes
|
|
When I get the execution history
|
|
Then I should receive a copy of the execution history
|
|
|
|
Scenario: Visualize graph in mermaid format
|
|
Given I have a GraphConfig with various node types
|
|
And I have created a LangGraph instance
|
|
When I visualize the graph in "mermaid" format
|
|
Then I should receive valid mermaid diagram syntax
|
|
|
|
Scenario: Visualize graph in unsupported format
|
|
Given I have a GraphConfig with basic nodes
|
|
And I have created a LangGraph instance
|
|
When I visualize the graph in "invalid" format
|
|
Then I should receive "Format invalid not supported"
|
|
|
|
Scenario: Register node executor function
|
|
Given I have a GraphConfig with a node "worker"
|
|
And I have created a LangGraph instance
|
|
When the node executor is registered
|
|
Then the executor function should be stored in the router
|
|
|
|
Scenario: Execute node with state updates
|
|
Given I have a GraphConfig with an agent node
|
|
And I have created a LangGraph instance
|
|
When I execute a node that returns updates
|
|
Then the state should be updated accordingly
|
|
And the execution history should be recorded
|
|
|
|
Scenario: Analyze graph with topological levels
|
|
Given I have a GraphConfig with hierarchical structure
|
|
When I create a LangGraph instance
|
|
Then the topological levels should be computed correctly
|
|
|
|
Scenario: Check node execution prerequisites
|
|
Given I have a GraphConfig with dependencies
|
|
And I have created a LangGraph instance
|
|
When I check if a node can execute
|
|
Then it should verify all predecessors are executed
|
|
|
|
Scenario: Get next nodes with conditional edges
|
|
Given I have a GraphConfig with conditional routing
|
|
And I have created a LangGraph instance
|
|
When I get next nodes for execution
|
|
Then it should evaluate edge conditions
|
|
|
|
Scenario: Create control streams for graph
|
|
Given I have a GraphConfig with stream control
|
|
And I have created a LangGraph instance
|
|
When I check control and state streams
|
|
Then control and state streams should be created
|
|
|
|
Scenario: Execute nodes in parallel mode
|
|
Given I have a GraphConfig with parallel execution
|
|
And I have created a LangGraph instance
|
|
When I execute multiple nodes in parallel
|
|
Then they should run concurrently
|
|
|
|
Scenario: Execute graph from specific node
|
|
Given I have a GraphConfig with multiple paths
|
|
And I have created a LangGraph instance
|
|
When I execute from a specific node
|
|
Then execution should follow the correct path
|
|
|
|
Scenario: Handle node shape mapping for visualization
|
|
Given I have a GraphConfig with all node types
|
|
And I have created a LangGraph instance
|
|
When I get node shapes for visualization
|
|
Then each node type should have the correct shape |