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-graphrag.md
+59-8Lines changed: 59 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: Agent Retrieval Augmented Generation (RAG)
3
-
description: Learn how to use Retrieval Augmented Generation (RAG) with Agent Framework
2
+
title: Agent GraphRAG
3
+
description: Learn how to use GraphRAG with Agent Framework
4
4
zone_pivot_groups: programming-languages
5
5
author: westey-m
6
6
ms.topic: reference
@@ -9,17 +9,17 @@ ms.date: 11/11/2025
9
9
ms.service: agent-framework
10
10
---
11
11
12
-
# Agent Retrieval Augmented Generation (RAG)
12
+
# Agent GraphRAG
13
13
14
-
Microsoft Agent Framework supports adding Retrieval Augmented Generation (RAG) capabilities to agents easily by adding AI Context Providers to the agent.
14
+
Microsoft Agent Framework supports adding GraphRAG capabilities to agents easily by adding AI Context Providers to the agent.
15
15
16
16
::: zone pivot="programming-language-csharp"
17
17
18
18
## Using TextSearchProvider
19
19
20
-
The `TextSearchProvider` class is an out-of-the-box implementation of a RAG context provider.
20
+
The `TextSearchProvider` class is an out-of-the-box implementation of a GraphRAG context provider.
21
21
22
-
It can easily be attached to a `ChatClientAgent` using the `AIContextProviderFactory` option to provide RAG capabilities to the agent.
22
+
It can easily be attached to a `ChatClientAgent` using the `AIContextProviderFactory` option to provide GraphRAG capabilities to the agent.
23
23
24
24
The factory is an async function that receives a context object and a cancellation token.
25
25
@@ -92,7 +92,7 @@ The `TextSearchProvider` class supports the following options via the `TextSearc
92
92
93
93
## Using Semantic Kernel VectorStore with Agent Framework
94
94
95
-
Agent Framework supports using Semantic Kernel's VectorStore collections to provide RAG capabilities to agents. This is achieved through the bridge functionality that converts Semantic Kernel search functions into Agent Framework tools.
95
+
Agent Framework supports using Semantic Kernel's VectorStore collections to provide GraphRAG capabilities to agents. This is achieved through the bridge functionality that converts Semantic Kernel search functions into Agent Framework tools.
96
96
97
97
> [!IMPORTANT]
98
98
> This feature requires `semantic-kernel` version 1.38 or higher.
@@ -160,7 +160,7 @@ async with collection:
160
160
tools=search_tool
161
161
)
162
162
163
-
# Use the agent with RAG capabilities
163
+
# Use the agent with GraphRAG capabilities
164
164
response =await agent.run("How do I return a product?")
165
165
print(response.text)
166
166
```
@@ -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.
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-graphrag.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: semantic-kernel/Frameworks/agent/agent-graphrag.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: Adding Retrieval Augmented Generation (RAG) to Semantic Kernel Agents
3
-
description: How to use the TextSearchProvider for Retrieval Augmented Generation (RAG) with Semantic Kernel Agents
2
+
title: Adding GraphRAG to Semantic Kernel Agents
3
+
description: How to use the TextSearchProvider for GraphRAG with Semantic Kernel Agents
4
4
zone_pivot_groups: programming-languages
5
5
author: westey-m
6
6
ms.topic: conceptual
@@ -9,14 +9,14 @@ ms.date: 05/22/2025
9
9
ms.service: semantic-kernel
10
10
---
11
11
12
-
# Adding Retrieval Augmented Generation (RAG) to Semantic Kernel Agents
12
+
# Adding GraphRAG to Semantic Kernel Agents
13
13
14
14
::: zone pivot="programming-language-csharp"
15
15
16
16
> [!WARNING]
17
-
> The Semantic Kernel Agent RAG functionality is experimental, subject to change, and will only be finalized based on feedback and evaluation.
17
+
> The Semantic Kernel Agent GraphRAG functionality is experimental, subject to change, and will only be finalized based on feedback and evaluation.
18
18
19
-
## Using the TextSearchProvider for RAG
19
+
## Using the TextSearchProvider for GraphRAG
20
20
21
21
The `Microsoft.SemanticKernel.Data.TextSearchProvider` allows agents to retrieve relevant documents based on user input and inject them into the agent's context for more informed responses.
22
22
It integrates an `Microsoft.SemanticKernel.Data.ITextSearch` instance with Semantic Kernel agents.
@@ -30,7 +30,7 @@ We also provide a `Microsoft.SemanticKernel.Data.TextSearchStore`, which provide
30
30
31
31
The `TextSearchProvider` can be used with a `VectorStore` and `TextSearchStore` to store and search text documents.
32
32
33
-
The following example demonstrates how to set up and use the `TextSearchProvider` with a `TextSearchStore` and `InMemoryVectorStore` for an agent to perform simple RAG over text.
33
+
The following example demonstrates how to set up and use the `TextSearchProvider` with a `TextSearchStore` and `InMemoryVectorStore` for an agent to perform simple GraphRAG over text.
34
34
35
35
```csharp
36
36
// Create an embedding generator using Azure OpenAI.
ChatMessageContentresponse=awaitagent.InvokeAsync("Where is Contoso based?", agentThread).FirstAsync();
72
72
Console.WriteLine(response.Content);
73
73
```
@@ -110,7 +110,7 @@ using var textSearchStore = new TextSearchStore<string>(
110
110
);
111
111
```
112
112
113
-
### Automatic vs on-demand RAG
113
+
### Automatic vs on-demand GraphRAG
114
114
115
115
The `TextSearchProvider` can perform searches automatically during each agent invocation or allow on-demand searches via tool calls when the agent needs additional information.
116
116
@@ -182,7 +182,7 @@ You can write your own output by implementing and providing this callback.
182
182
183
183
**Note**: If this delegate is provided, the `ContextPrompt` and `IncludeCitationsPrompt` settings will not be used.
184
184
185
-
## Combining RAG with Other Providers
185
+
## Combining GraphRAG with Other Providers
186
186
187
187
The `TextSearchProvider` can be combined with other providers, such as `mem0` or `WhiteboardProvider`, to create agents with both memory and retrieval capabilities.
188
188
@@ -201,7 +201,7 @@ By combining these features, agents can deliver a more personalized and context-
201
201
## Next steps
202
202
203
203
> [!div class="nextstepaction"]
204
-
> [Explore the Agent with RAG sample](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Agents/ChatCompletion_Rag.cs)
204
+
> [Explore the Agent with GraphRAG sample](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/samples/Concepts/Agents/ChatCompletion_Rag.cs)
Copy file name to clipboardExpand all lines: semantic-kernel/concepts/vector-store-connectors/index.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,18 +42,18 @@ The Semantic Kernel provided imlementations are referred to as 'connectors'.
42
42
43
43
::: zone pivot="programming-language-csharp"
44
44
45
-
## Retrieval Augmented Generation (RAG) with Vector Stores
45
+
## GraphRAG with Vector Stores
46
46
47
47
The vector store abstraction is a low level api for adding and retrieving data from vector stores.
48
-
Semantic Kernel has built-in support for using any one of the Vector Store implementations for RAG.
48
+
Semantic Kernel has built-in support for using any one of the Vector Store implementations for GraphRAG.
49
49
This is achieved by wrapping `IVectorSearchable<TRecord>` and exposing it as a Text Search implementation.
50
50
51
51
> [!TIP]
52
-
> To learn more about how to use vector stores for RAG see [How to use Vector Stores with Semantic Kernel Text Search](../text-search/text-search-vector-stores.md).
52
+
> To learn more about how to use vector stores for GraphRAG see [How to use Vector Stores with Semantic Kernel Text Search](../text-search/text-search-vector-stores.md).
53
53
> [!TIP]
54
54
> To learn more about text search see [What is Semantic Kernel Text Search?](../text-search/index.md)
55
55
> [!TIP]
56
-
> To learn more about how to quickly add RAG into your agent see [Adding Retrieval Augmented Generation (RAG) to Semantic Kernel Agents](../../Frameworks/agent/agent-rag.md).
56
+
> To learn more about how to quickly add GraphRAG into your agent see [Adding GraphRAG to Semantic Kernel Agents](../../Frameworks/agent/agent-graphrag.md).
57
57
58
58
## The Vector Store Abstraction
59
59
@@ -81,14 +81,14 @@ Finally, the abstract base class inherits from `IVectorSearchable<TRecord>` prov
81
81
::: zone-end
82
82
::: zone pivot="programming-language-python"
83
83
84
-
## Retrieval Augmented Generation (RAG) with Vector Stores
84
+
## GraphRAG with Vector Stores
85
85
86
86
The vector store abstractions are a low level api for adding and retrieving data from vector stores.
87
-
Semantic Kernel has built-in support for using any one of the Vector Store implementations for RAG.
87
+
Semantic Kernel has built-in support for using any one of the Vector Store implementations for GraphRAG.
88
88
This is achieved by wrapping `VectorSearchBase[TKey, TModel]` with either `VectorizedSearchMixin[Tmodel]`, `VectorizableTextSearchMixin[TModel]` or `VectorTextSearch[TModel]` and exposing it as a Text Search implementation.
89
89
90
90
> [!TIP]
91
-
> To learn more about how to use vector stores for RAG see [How to use Vector Stores with Semantic Kernel Text Search](../text-search/text-search-vector-stores.md).
91
+
> To learn more about how to use vector stores for GraphRAG see [How to use Vector Stores with Semantic Kernel Text Search](../text-search/text-search-vector-stores.md).
92
92
> [!TIP]
93
93
> To learn more about text search see [What is Semantic Kernel Text Search?](../text-search/index.md)
0 commit comments