@@ -43,7 +43,155 @@ pip install toondb-client
4343
4444> ℹ️ ** About the Binaries** : This Python SDK packages pre- compiled binaries from the [main ToonDB repository](https:// github.com/ toondb/ toondb). Each wheel contains platform- specific executables (`toondb- bulk` , `toondb- server` , `toondb- grpc- server` ) and native FFI libraries. See [RELEASE .md](RELEASE .md) for details on the release process.
4545
46- # # What's New in Latest Release
46+ # # What's New in v0.3.3
47+
48+ # ## 🕸️ Graph Overlay for Agent Memory
49+ Build lightweight graph structures on top of ToonDB' s KV storage for agent memory:
50+
51+ ```python
52+ from toondb import Database, GraphOverlay
53+
54+ db = Database.open(" ./agent_db" )
55+ graph = GraphOverlay(db, namespace = " agent_memory" )
56+
57+ # Add nodes (entities, concepts, events)
58+ graph.add_node(" user_alice" , " person" , {" name" : " Alice" , " role" : " developer" })
59+ graph.add_node(" conv_123" , " conversation" , {" topic" : " ToonDB features" })
60+ graph.add_node(" action_456" , " action" , {" type" : " code_commit" , " status" : " success" })
61+
62+ # Add edges (relationships, causality, references)
63+ graph.add_edge(" user_alice" , " started" , " conv_123" , {" timestamp" : " 2026-01-05" })
64+ graph.add_edge(" conv_123" , " triggered" , " action_456" , {" reason" : " user request" })
65+
66+ # Retrieve nodes and edges
67+ node = graph.get_node(" user_alice" )
68+ edges = graph.get_edges(" user_alice" , edge_type = " started" )
69+
70+ # Graph traversal
71+ visited = graph.bfs_traversal(" user_alice" , max_depth = 3 ) # BFS from Alice
72+ path = graph.shortest_path(" user_alice" , " action_456" ) # Find connection
73+
74+ # Get neighbors
75+ neighbors = graph.get_neighbors(" conv_123" , direction = " both" )
76+
77+ # Extract subgraph
78+ subgraph = graph.get_subgraph([" user_alice" , " conv_123" , " action_456" ])
79+ ```
80+
81+ ** Use Cases:**
82+ - Agent conversation history with causal chains
83+ - Entity relationship tracking across sessions
84+ - Action dependency graphs for planning
85+ - Knowledge graph construction
86+
87+ # ## 🛡️ Policy & Safety Hooks
88+ Enforce safety policies on agent operations with pre/ post triggers:
89+
90+ ```python
91+ from toondb import Database, PolicyEngine, PolicyAction
92+
93+ db = Database.open(" ./agent_data" )
94+ policy = PolicyEngine(db)
95+
96+ # Block writes to system keys from agents
97+ @ policy.before_write(" system/*" )
98+ def block_system_writes(key, value, context):
99+ if context.get(" agent_id" ):
100+ return PolicyAction.DENY
101+ return PolicyAction.ALLOW
102+
103+ # Redact sensitive data on read
104+ @ policy.after_read(" users/*/email" )
105+ def redact_emails(key, value, context):
106+ if context.get(" redact_pii" ):
107+ return b " [REDACTED]"
108+ return value
109+
110+ # Rate limit writes per agent
111+ policy.add_rate_limit(" write" , max_per_minute = 100 , scope = " agent_id" )
112+
113+ # Enable audit logging
114+ policy.enable_audit()
115+
116+ # Use policy-wrapped operations
117+ policy.put(b " users/alice" , b " data" , context = {" agent_id" : " agent_001" })
118+ ```
119+
120+ # ## 🔀 Multi-Agent Tool Routing
121+ Route tool calls to specialized agents with automatic failover:
122+
123+ ```python
124+ from toondb import Database, ToolDispatcher, ToolCategory, RoutingStrategy
125+
126+ db = Database.open(" ./agent_data" )
127+ dispatcher = ToolDispatcher(db)
128+
129+ # Register agents with capabilities
130+ dispatcher.register_local_agent(
131+ " code_agent" ,
132+ capabilities = [ToolCategory.CODE , ToolCategory.GIT ],
133+ handler = lambda tool , args : {" result" : f " Processed { tool} " },
134+ )
135+
136+ dispatcher.register_remote_agent(
137+ " search_agent" ,
138+ capabilities = [ToolCategory.SEARCH ],
139+ endpoint = " http://localhost:8001/invoke" ,
140+ )
141+
142+ # Register tools
143+ dispatcher.register_tool(
144+ name = " search_code" ,
145+ description = " Search codebase" ,
146+ category = ToolCategory.CODE ,
147+ )
148+
149+ # Invoke with automatic routing (priority, round-robin, fastest, etc.)
150+ result = dispatcher.invoke(" search_code" , {" query" : " auth" }, session_id = " sess_001" )
151+ print (f " Routed to: { result.agent_id} , Success: { result.success} " )
152+ ```
153+
154+ # ## 🕸️ Graph Overlay
155+ Lightweight graph layer for agent memory relationships:
156+
157+ ```python
158+ from toondb import Database, GraphOverlay, TraversalOrder
159+
160+ db = Database.open(" ./agent_data" )
161+ graph = GraphOverlay(db)
162+
163+ # Add nodes (entities, concepts, events)
164+ graph.add_node(" user:alice" , node_type = " user" , properties = {" role" : " admin" })
165+ graph.add_node(" project:toondb" , node_type = " project" , properties = {" status" : " active" })
166+
167+ # Add relationships
168+ graph.add_edge(" user:alice" , " project:toondb" , edge_type = " owns" , properties = {" since" : " 2024" })
169+
170+ # Traverse graph (BFS/DFS)
171+ related = graph.bfs(" user:alice" , max_depth = 2 , edge_filter = lambda e : e.edge_type == " owns" )
172+
173+ # Find shortest path
174+ path = graph.shortest_path(" user:alice" , " project:toondb" )
175+ ```
176+
177+ # ## 🔗 Unified Connection API
178+ Single entry point with auto- detection:
179+
180+ ```python
181+ import toondb
182+
183+ # Auto-detects embedded mode from path
184+ db = toondb.connect(" ./my_database" )
185+
186+ # Auto-detects IPC mode from socket
187+ db = toondb.connect(" /tmp/toondb.sock" )
188+
189+ # Auto-detects gRPC mode from host:port
190+ db = toondb.connect(" localhost:50051" )
191+
192+ # Explicit mode
193+ db = toondb.connect(" ./data" , mode = " embedded" , config = {" sync_mode" : " full" })
194+ ```
47195
48196# ## 🎯 Namespace Isolation
49197Logical database namespaces for true multi- tenancy without key prefixing:
0 commit comments