146 lines
4.2 KiB
Plaintext
146 lines
4.2 KiB
Plaintext
Feature: LangGraph Core Functionality
|
|
As a developer using CleverAgents
|
|
I want to use basic LangGraph features
|
|
So that I can build stateful workflows
|
|
|
|
Background:
|
|
Given the CleverAgents reactive system is available with LangGraph support
|
|
|
|
Scenario: Basic LangGraph creation
|
|
Given I have a LangGraph configuration:
|
|
"""
|
|
{
|
|
"name": "simple_graph",
|
|
"nodes": {
|
|
"process": {
|
|
"type": "function",
|
|
"function": "summarize"
|
|
}
|
|
},
|
|
"edges": [
|
|
{"source": "start", "target": "process"},
|
|
{"source": "process", "target": "end"}
|
|
]
|
|
}
|
|
"""
|
|
When I create the graph
|
|
Then the graph should be created successfully
|
|
And the graph should have 1 custom node plus start and end nodes
|
|
|
|
Scenario: LangGraph with agent nodes
|
|
Given I have agents configured:
|
|
"""
|
|
agents:
|
|
analyzer:
|
|
type: llm
|
|
config:
|
|
model: gpt-4
|
|
temperature: 0.3
|
|
system_prompt: "You are a data analyzer."
|
|
"""
|
|
Given I have a LangGraph configuration:
|
|
"""
|
|
{
|
|
"name": "agent_graph",
|
|
"nodes": {
|
|
"analyze": {
|
|
"type": "agent",
|
|
"agent": "analyzer"
|
|
}
|
|
},
|
|
"edges": [
|
|
{"source": "start", "target": "analyze"},
|
|
{"source": "analyze", "target": "end"}
|
|
]
|
|
}
|
|
"""
|
|
When I create the graph
|
|
Then the graph should be created successfully
|
|
And the graph should connect to the analyzer agent
|
|
|
|
Scenario: LangGraph with conditional routing
|
|
Given I have a LangGraph configuration:
|
|
"""
|
|
{
|
|
"name": "conditional_graph",
|
|
"nodes": {
|
|
"check": {
|
|
"type": "conditional",
|
|
"conditions": {
|
|
"positive": {"type": "contains", "text": "yes"},
|
|
"negative": {"type": "contains", "text": "no"}
|
|
}
|
|
},
|
|
"handle_yes": {
|
|
"type": "function",
|
|
"function": "handle_positive"
|
|
},
|
|
"handle_no": {
|
|
"type": "function",
|
|
"function": "handle_negative"
|
|
}
|
|
},
|
|
"edges": [
|
|
{"source": "start", "target": "check"},
|
|
{"source": "check", "target": "handle_yes", "condition": "positive"},
|
|
{"source": "check", "target": "handle_no", "condition": "negative"},
|
|
{"source": "handle_yes", "target": "end"},
|
|
{"source": "handle_no", "target": "end"}
|
|
]
|
|
}
|
|
"""
|
|
When I create the graph
|
|
Then the graph should be created successfully
|
|
And the graph should support conditional routing
|
|
|
|
Scenario: LangGraph with state management
|
|
Given I have a LangGraph configuration:
|
|
"""
|
|
{
|
|
"name": "stateful_graph",
|
|
"checkpointing": true,
|
|
"enable_time_travel": true,
|
|
"nodes": {
|
|
"accumulate": {
|
|
"type": "function",
|
|
"function": "add_to_state"
|
|
}
|
|
},
|
|
"edges": [
|
|
{"source": "start", "target": "accumulate"},
|
|
{"source": "accumulate", "target": "end"}
|
|
]
|
|
}
|
|
"""
|
|
When I create the graph
|
|
Then the graph should be created successfully
|
|
And the graph state should be persisted
|
|
And I should be able to time travel to previous states
|
|
|
|
Scenario: LangGraph as RxPy operator
|
|
Given I have created the simple_graph
|
|
And I have a stream configuration with LangGraph operator:
|
|
"""
|
|
{
|
|
"name": "graph_stream",
|
|
"type": "cold",
|
|
"operators": [
|
|
{
|
|
"type": "graph_execute",
|
|
"params": {
|
|
"graph": "simple_graph"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
"""
|
|
When I create the stream
|
|
And I send a message to the stream
|
|
Then the message should be processed by the LangGraph
|
|
|
|
Scenario: LangGraph visualization
|
|
Given I have a complex LangGraph configured
|
|
When I request visualization in mermaid format
|
|
Then I should get a mermaid diagram showing all nodes with appropriate shapes
|
|
And the diagram should show all edges with conditions if present
|
|
And the diagram should show subgraph boundaries if applicable |