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
The graph runtime builds on the SpoonOS Memory System to persist context, metadata, and execution state across runs. Every compiled graph can attach a `Memory` store so routers, reducers, and agents reason over accumulated history without bespoke plumbing.
412
+
413
+
### Overview
414
+
415
+
- Persistent JSON-backed storage keyed by `session_id`
416
+
- Chronological message history with metadata enrichment
417
+
- Query helpers for search and time-based filtering
418
+
- Automatic wiring inside `GraphAgent` and high-level APIs
Use metadata to thread routing hints and conversation topics, and prune history with retention policies or manual cleanup (`memory.clear()`).
449
+
450
+
### Graph Workflow Integration
451
+
452
+
`GraphAgent` wires memory automatically and exposes statistics for monitoring:
453
+
454
+
```python
455
+
from spoon_ai.graph import GraphAgent, StateGraph
456
+
457
+
agent = GraphAgent(
458
+
name="crypto_analyzer",
459
+
graph=my_graph,
460
+
memory_path="./agent_memory",
461
+
session_id="crypto_session"
462
+
)
463
+
464
+
result =await agent.run("Analyze BTC trends")
465
+
stats = agent.get_memory_statistics()
466
+
print(stats["total_messages"])
467
+
```
468
+
469
+
Switch between sessions to isolate experiments (`agent.load_session("research_session")`) or inject custom `Memory` subclasses for domain-specific validation.
470
+
471
+
### Advanced Patterns
472
+
473
+
- Call `memory.get_statistics()` to monitor file size, last update time, and record counts
474
+
- Implement custom subclasses to enforce schemas or add enrichment hooks
475
+
- Use time-window retrieval for reducers that need the most recent facts only
476
+
- Build automated cleanup jobs for oversized stores (>10MB) to keep execution tight
0 commit comments