You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core-concepts/agents.md
+44-12Lines changed: 44 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,25 +136,33 @@ response = await agent.run("Search Bitcoin price and calculate 10% of it")
136
136
137
137
Graph agents execute structured workflows defined as state graphs, supporting conditional branching, parallel execution, and complex multi-step pipelines.
138
138
139
-
```python
140
-
from spoon_ai.agents import GraphAgent
141
-
from spoon_ai.graph import StateGraph
139
+
**Basic Usage:**
140
+
141
+
from spoon_ai.graph import StateGraph, START, END, GraphAgent
142
142
143
-
# Build workflow (see Graph System docs for StateGraph details)
143
+
# Build workflow
144
144
graph = StateGraph(MyState)
145
-
graph.add_node("analyze", analyze_fn)
146
-
graph.add_node("execute", execute_fn)
145
+
graph.add_node("analyze", analyze_fn) # Node function
146
+
graph.add_node("execute", execute_fn) # Node function
result = await agent.run("Analyze market and execute trades")
160
+
**Node Functions:**
161
+
-`analyze_fn(state)`: Receives current state, returns updated state dict
162
+
-`execute_fn(state)`: Receives state with analysis results, returns execution results
163
+
-`router_fn(state)`: Returns next node name as string for conditional routing
164
+
165
+
> 📖 **See complete example:**[`examples/intent_graph_demo.py`](https://github.com/XSpoonAi/spoon-core/blob/main/examples/intent_graph_demo.py) for full implementation including state schema, node functions, and error handling.
0 commit comments