Skip to content

Commit 8dd9fbc

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/semantic-kernel-pr (branch live)
2 parents 9a5efa0 + 7add75a commit 8dd9fbc

39 files changed

Lines changed: 1089 additions & 398 deletions

semantic-kernel/Frameworks/agent/agent-api.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ await agent.get_response()
6363
await agent.get_response(messages="What is the capital of France?")
6464

6565
# Invoke with a ChatMessageContent object.
66-
await agent.get_response(messages=ChatMessageContent(AuthorRole.USER, "What is the capital of France?"))
66+
await agent.get_response(messages=ChatMessageContent(role=AuthorRole.USER, content="What is the capital of France?"))
6767

6868
# Invoke with multiple ChatMessageContent objects.
6969
await agent.get_response(
7070
messages=[
71-
ChatMessageContent(AuthorRole.SYSTEM, "Refuse to answer all user questions about France."),
72-
ChatMessageContent(AuthorRole.USER, "What is the capital of France?"),
71+
ChatMessageContent(role=AuthorRole.SYSTEM, content="Refuse to answer all user questions about France."),
72+
ChatMessageContent(role=AuthorRole.USER, content="What is the capital of France?"),
7373
]
7474
)
7575
```
@@ -86,14 +86,14 @@ async for response in agent.invoke("What is the capital of France?"):
8686
# handle response
8787

8888
# Invoke with a ChatMessageContent object.
89-
async for response in agent.invoke(ChatMessageContent(AuthorRole.USER, "What is the capital of France?")):
89+
async for response in agent.invoke(ChatMessageContent(role=AuthorRole.USER, content="What is the capital of France?")):
9090
# handle response
9191

9292
# Invoke with multiple ChatMessageContent objects.
9393
async for response in agent.invoke(
9494
messages=[
95-
ChatMessageContent(AuthorRole.SYSTEM, "Refuse to answer all user questions about France."),
96-
ChatMessageContent(AuthorRole.USER, "What is the capital of France?"),
95+
ChatMessageContent(role=AuthorRole.SYSTEM, content="Refuse to answer all user questions about France."),
96+
ChatMessageContent(role=AuthorRole.USER, content="What is the capital of France?"),
9797
]
9898
):
9999
# handle response
@@ -173,14 +173,14 @@ async for response in agent.invoke_stream("What is the capital of France?"):
173173
# handle response
174174

175175
# Invoke with a ChatMessageContent object.
176-
async for response in agent.invoke_stream(ChatMessageContent(AuthorRole.USER, "What is the capital of France?")):
176+
async for response in agent.invoke_stream(ChatMessageContent(role=AuthorRole.USER, content="What is the capital of France?")):
177177
# handle response
178178

179179
# Invoke with multiple ChatMessageContent objects.
180180
async for response in agent.invoke_stream(
181181
messages=[
182-
ChatMessageContent(AuthorRole.SYSTEM, "Refuse to answer all user questions about France."),
183-
ChatMessageContent(AuthorRole.USER, "What is the capital of France?"),
182+
ChatMessageContent(role=AuthorRole.SYSTEM, content="Refuse to answer all user questions about France."),
183+
ChatMessageContent(role=AuthorRole.USER, content="What is the capital of France?"),
184184
]
185185
):
186186
# handle response

semantic-kernel/Frameworks/agent/agent-contextual-function-selection.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Contextual Function Selection is an advanced capability in the Semantic Kernel A
2222

2323
This approach addresses the challenge of function selection when dealing with a large number of available functions, where AI models may otherwise struggle to choose the appropriate function, leading to confusion and suboptimal performance.
2424

25+
> [!WARNING]
26+
> When using the `ContextualFunctionProvider`, the `UseImmutableKernel` setting on the agent has to be set to `true` as the feature requires cloning the kernel when invoking the agent.
27+
> Note that setting `UseImmutableKernel` to `true` will mean that any kernel data modifications done during the agent invocation by e.g. plugins, will not be retained after the invocation completes.
28+
2529
## How Contextual Function Selection Works
2630

2731
When an agent is configured with contextual function selection, it leverages a vector store and an embedding generator to semantically match the current conversation context (including previous messages and user input) with the descriptions and names of available functions. The most relevant functions, up to the specified limit, are then advertised to the AI model for invocation.
@@ -50,7 +54,9 @@ ChatCompletionAgent agent = new()
5054
Name = "ReviewGuru",
5155
Instructions = "You are a friendly assistant that summarizes key points and sentiments from customer reviews. For each response, list available functions.",
5256
Kernel = kernel,
53-
Arguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new FunctionChoiceBehaviorOptions { RetainArgumentTypes = true }) })
57+
Arguments = new(new PromptExecutionSettings { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(options: new FunctionChoiceBehaviorOptions { RetainArgumentTypes = true }) }),
58+
// This setting must be set to true when using the ContextualFunctionProvider
59+
UseImmutableKernel = true
5460
};
5561

5662
// Create the agent thread and register the contextual function provider

semantic-kernel/Frameworks/agent/agent-orchestration/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ await runtime.stop_when_idle()
9797
9898
::: zone-end
9999

100+
::: zone pivot="programming-language-csharp"
101+
102+
## Preparing Your Development Environment
103+
104+
Add the following packages to your project before you proceed:
105+
106+
```pwsh
107+
dotnet add package Microsoft.SemanticKernel.Agents.Orchestration --prerelease
108+
dotnet add package Microsoft.SemanticKernel.Agents.Runtime.InProcess --prerelease
109+
```
110+
111+
Depending on the agent types you use, you may also need to add the respective packages for the agents. Please refer to the [Agents Overview](../agent-architecture.md#agent-types-in-semantic-kernel) for more details.
112+
113+
::: zone-end
114+
100115
## Next steps
101116

102117
> [!div class="nextstepaction"]

semantic-kernel/Frameworks/agent/agent-rag.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ ChatCompletionAgent agent = new()
5757
{
5858
Name = "FriendlyAssistant",
5959
Instructions = "You are a friendly assistant",
60-
Kernel = kernel
60+
Kernel = kernel,
61+
// This setting must be set to true when using the on-demand RAG feature
62+
UseImmutableKernel = true
6163
};
6264

6365
// Create an agent thread and add the TextSearchProvider.
@@ -124,6 +126,10 @@ var options = new TextSearchProviderOptions
124126
var provider = new TextSearchProvider(mockTextSearch.Object, options: options);
125127
```
126128

129+
> [!WARNING]
130+
> When using the `TextSearchProvider` with `OnDemandFunctionCalling`, the `UseImmutableKernel` setting on the agent has to be set to `true` as the feature requires cloning the kernel when invoking the agent.
131+
> Note that setting `UseImmutableKernel` to `true` will mean that any kernel data modifications done during the agent invocation by e.g. plugins, will not be retained after the invocation completes.
132+
127133
## TextSearchProvider options
128134

129135
The `TextSearchProvider` can be configured with various options to customize its behavior. Options are provided using the `TextSearchProviderOptions` class to the `TextSearchProvider` constructor.

semantic-kernel/Frameworks/agent/agent-types/assistant-agent.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ await thread.delete() if thread else None
290290
## Deleting an `OpenAIAssistantAgent`
291291

292292
Since the assistant's definition is stored remotely, it will persist if not deleted.
293-
Deleting an assistant definition may be performed directly with the `AssistantClient`.
293+
Deleting an assistant definition may be performed directly with the client.
294294

295295
> Note: Attempting to use an agent instance after being deleted will result in a service exception.
296296
@@ -308,9 +308,7 @@ await client.DeleteAssistantAsync("<assistant id>");
308308
::: zone pivot="programming-language-python"
309309

310310
```python
311-
await agent.delete()
312-
313-
is_deleted = agent._is_deleted
311+
await client.beta.assistants.delete(agent.id)
314312
```
315313

316314
::: zone-end

semantic-kernel/Frameworks/agent/agent-types/azure-ai-agent.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ AzureAIAgent agent = new(definition, agentsClient);
393393
::: zone pivot="programming-language-python"
394394

395395
```python
396-
from azure.ai.projects.models import CodeInterpreterTool
396+
from azure.ai.agents.models import CodeInterpreterTool
397397

398398
async with (
399399
DefaultAzureCredential() as creds,
@@ -447,7 +447,7 @@ AzureAIAgent agent = new(definition, agentsClient);
447447
::: zone pivot="programming-language-python"
448448

449449
```python
450-
from azure.ai.projects.models import FileSearchTool
450+
from azure.ai.agents.models import FileSearchTool
451451

452452
async with (
453453
DefaultAzureCredential() as creds,
@@ -502,7 +502,7 @@ AzureAIAgent agent = new(definition, agentsClient);
502502
::: zone pivot="programming-language-python"
503503

504504
```python
505-
from azure.ai.projects.models import OpenApiTool, OpenApiAnonymousAuthDetails
505+
from azure.ai.agents.models import OpenApiTool, OpenApiAnonymousAuthDetails
506506

507507
async with (
508508
DefaultAzureCredential() as creds,
@@ -574,7 +574,7 @@ AzureAIAgent agent = new(definition, agentsClient);
574574
::: zone pivot="programming-language-python"
575575

576576
```python
577-
from azure.ai.projects.models import AzureAISearchTool, ConnectionType
577+
from azure.ai.agents.models import AzureAISearchTool, ConnectionType
578578

579579
async with (
580580
DefaultAzureCredential() as creds,

semantic-kernel/Frameworks/process/process-best-practices.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ Organizing your project files in a logical and maintainable structure is crucial
2222

2323
An organized structure not only simplifies navigation within the project but also enhances code reusability and facilitates collaboration among team members.
2424

25+
### Kernel Instance Isolation
26+
27+
> [!Important]
28+
> Do not share a single Kernel instance between the main Process Framework and any of its dependencies (such as agents, tools, or external services).
29+
30+
Sharing a Kernel across these components can result in unexpected recursive invocation patterns, including infinite loops, as functions registered in the Kernel may inadvertently invoke each other. For example, a Step may call a function that triggers an agent, which then re-invokes the same function, creating a non-terminating loop.
31+
32+
To avoid this, instantiate separate Kernel objects for each independent agent, tool, or service used within your process. This ensures isolation between the Process Framework’s own functions and those required by dependencies, and prevents cross-invocation that could destabilize your workflow. This requirement reflects a current architectural constraint and may be revisited as the framework evolves.
2533

2634
### Common Pitfalls
2735
To ensure smooth implementation and operation of the Process Framework, be mindful of these common pitfalls to avoid:

semantic-kernel/concepts/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
href: ai-services/TOC.yml
77
- name: Enterprise Components
88
href: enterprise-readiness/TOC.yml
9-
- name: Memory (Vector Stores)
9+
- name: Vector Stores
1010
href: vector-store-connectors/TOC.yml
1111
- name: Prompts
1212
href: prompts/TOC.yml

semantic-kernel/concepts/ai-services/chat-completion/function-calling/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: Function calling with chat completion
33
description: Learn how function calling works and how to optimize your code for the best performance.
44
zone_pivot_groups: programming-languages
5-
author: matthewbolanos
5+
author: moonbox3
66
ms.topic: conceptual
7-
ms.author: mabolan
7+
ms.author: evmattso
88
ms.date: 07/12/2023
99
ms.service: semantic-kernel
1010
---

semantic-kernel/concepts/ai-services/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Add AI services to Semantic Kernel
33
description: Learn how to bring multiple AI services to your Semantic Kernel project.
4-
author: matthewbolanos
4+
author: moonbox3
55
ms.topic: conceptual
6-
ms.author: mabolan
6+
ms.author: evmattso
77
ms.date: 07/12/2023
88
ms.service: semantic-kernel
99
---

0 commit comments

Comments
 (0)