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: agent-framework/user-guide/agents/agent-memory.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -329,6 +329,59 @@ agent = ChatAgent(
329
329
)
330
330
```
331
331
332
+
#### Neo4j Memory Provider
333
+
334
+
Neo4j offers two separate integrations for Agent Framework, each serving a different purpose. This provider (`neo4j-agent-memory`) is for **persistent memory** — storing and recalling agent interactions, extracting entities, and building a knowledge graph over time. For **GraphRAG** from an existing knowledge graph using vector, fulltext, or hybrid search, see the [Neo4j Context Provider for GraphRAG](./agent-rag.md#using-neo4j-for-graphrag).
335
+
336
+
The Neo4j Memory Provider gives agents persistent memory backed by a knowledge graph. Unlike GraphRAG providers that retrieve from static knowledge bases, the memory provider stores and recalls agent interactions, automatically extracting entities and building a knowledge graph over time.
337
+
338
+
The provider manages three types of memory:
339
+
-**Short-term memory**: Conversation history and recent context
340
+
-**Long-term memory**: Entities, preferences, and facts extracted from interactions
341
+
-**Reasoning memory**: Past reasoning traces and tool usage patterns
342
+
343
+
```python
344
+
from agent_framework import Agent
345
+
from agent_framework.azure import AzureAIClient
346
+
from azure.identity.aio import AzureCliCredential
347
+
from neo4j_agent_memory import MemoryClient, MemorySettings
348
+
from neo4j_agent_memory.integrations.microsoft_agent import (
349
+
Neo4jMicrosoftMemory,
350
+
create_memory_tools,
351
+
)
352
+
353
+
settings = MemorySettings()
354
+
memory_client = MemoryClient(settings)
355
+
356
+
asyncwith memory_client:
357
+
memory = Neo4jMicrosoftMemory.from_memory_client(
358
+
memory_client=memory_client,
359
+
session_id="user-123",
360
+
)
361
+
tools = create_memory_tools(memory)
362
+
363
+
asyncwith (
364
+
AzureAIClient(credential=AzureCliCredential(), project_endpoint=project_endpoint) as client,
365
+
Agent(
366
+
client=client,
367
+
instructions="You are a helpful assistant with persistent memory.",
368
+
tools=tools,
369
+
context_providers=[memory.context_provider],
370
+
) as agent,
371
+
):
372
+
session = agent.create_session()
373
+
response =await agent.run("Remember that I prefer window seats on flights.", session=session)
374
+
```
375
+
376
+
Key features:
377
+
-**Bidirectional**: Automatically retrieves relevant context before invocation and saves new memories after responses
378
+
-**Entity extraction**: Builds a knowledge graph from conversations using a multi-stage extraction pipeline
379
+
-**Preference learning**: Infers and stores user preferences across sessions
380
+
-**Memory tools**: Agents can explicitly search memory, remember preferences, and find entity connections
381
+
382
+
> [!TIP]
383
+
> Install with `pip install neo4j-agent-memory[microsoft-agent]`. See the [Neo4j Agent Memory repository](https://github.com/neo4j-labs/agent-memory) for complete documentation.
384
+
332
385
### Thread Serialization and Persistence
333
386
The framework supports serializing entire thread states for persistence across application restarts:
Copy file name to clipboardExpand all lines: agent-framework/user-guide/agents/agent-rag.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -295,6 +295,57 @@ This pattern works with any Semantic Kernel VectorStore connector, including:
295
295
296
296
Each connector provides the same `create_search_function` method that can be bridged to Agent Framework tools, allowing you to choose the vector database that best fits your needs. See [the full list here](/semantic-kernel/concepts/vector-store-connectors/out-of-the-box-connectors).
297
297
298
+
### Using Neo4j for GraphRAG
299
+
300
+
Neo4j offers two separate integrations for Agent Framework, each serving a different purpose. This provider (`agent-framework-neo4j`) is for **GraphRAG** — searching an existing knowledge graph to ground agent responses. For **persistent memory** that learns from conversations and builds a knowledge graph over time, see the [Neo4j Memory Provider](./agent-memory.md#neo4j-memory-provider).
301
+
302
+
For knowledge graph scenarios where relationships between entities matter, the Neo4j Context Provider offers GraphRAG. It supports vector, fulltext, and hybrid search modes, with optional graph traversal to enrich results with related entities via custom Cypher queries.
303
+
304
+
```python
305
+
from agent_framework import Agent
306
+
from agent_framework.azure import AzureAIClient
307
+
from agent_framework_neo4j import Neo4jContextProvider, Neo4jSettings, AzureAIEmbedder
308
+
from azure.identity.aio import AzureCliCredential
309
+
310
+
settings = Neo4jSettings()
311
+
312
+
neo4j_provider = Neo4jContextProvider(
313
+
uri=settings.uri,
314
+
username=settings.username,
315
+
password=settings.get_password(),
316
+
index_name="documentChunks",
317
+
index_type="vector",
318
+
embedder=AzureAIEmbedder(...),
319
+
top_k=5,
320
+
retrieval_query="""
321
+
MATCH (node)-[:FROM_DOCUMENT]->(doc:Document)
322
+
OPTIONAL MATCH (doc)<-[:FILED]-(company:Company)
323
+
RETURN node.text AS text, score, doc.title AS title, company.name AS company
324
+
ORDER BY score DESC
325
+
""",
326
+
)
327
+
328
+
asyncwith (
329
+
neo4j_provider,
330
+
AzureAIClient(credential=AzureCliCredential(), project_endpoint=project_endpoint) as client,
331
+
Agent(
332
+
client=client,
333
+
instructions="You are a financial analyst assistant.",
334
+
context_providers=[neo4j_provider],
335
+
) as agent,
336
+
):
337
+
session = agent.create_session()
338
+
response =await agent.run("What risks does Acme Corp face?", session=session)
339
+
```
340
+
341
+
Key features:
342
+
-**Index-driven**: Works with any Neo4j vector or fulltext index
343
+
-**Graph traversal**: Custom Cypher queries enrich search results with related entities
> Install with `pip install agent-framework-neo4j`. See the [Neo4j Context Provider repository](https://github.com/neo4j-labs/neo4j-maf-provider) for complete documentation.
0 commit comments