Skip to content

Commit 3329aae

Browse files
authored
Merge branch 'main' into main
2 parents 6667c46 + fe11ab6 commit 3329aae

File tree

43 files changed

+1929
-624
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1929
-624
lines changed

.github/upgrades/prompts/SemanticKernelToAgentFramework.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,73 @@ AIAgent agent = chatClient.CreateAIAgent(
384384
7. Pass tools directly to agent creation method
385385
</configuration_changes>
386386

387+
### Runtime Tool Registration Transformation
388+
389+
<configuration_changes>
390+
In Semantic Kernel, plugins/tools could be added to the kernel after it was already built using `kernel.Plugins.Add()`. Agent Framework provides a similar capability using the builder middleware API.
391+
392+
**Replace this Semantic Kernel post-creation tool registration pattern:**
393+
```csharp
394+
// Define the tool function
395+
[Description("Get the weather for a location")]
396+
static string GetWeather(string location) => $"Weather in {location}";
397+
398+
// Semantic Kernel - Tools added after kernel is already built
399+
Kernel kernel = kernelBuilder.Build();
400+
ChatCompletionAgent agent = new() { Kernel = kernel };
401+
402+
// Later: Add tools to the existing kernel instance
403+
KernelFunction function = KernelFunctionFactory.CreateFromMethod(GetWeather);
404+
KernelPlugin plugin = KernelPluginFactory.CreateFromFunctions("WeatherPlugin", [function]);
405+
kernel.Plugins.Add(plugin);
406+
407+
// Tools are now available on subsequent invocations
408+
await foreach (var item in agent.InvokeAsync(userInput, thread)) { ... }
409+
```
410+
411+
**With this Agent Framework pattern using builder middleware:**
412+
```csharp
413+
// Define the tool function
414+
[Description("Get the weather for a location")]
415+
static string GetWeather(string location) => $"Weather in {location}";
416+
417+
// Start with an existing agent
418+
AIAgent existingAgent = chatClient.CreateAIAgent(
419+
instructions: "You are a helpful assistant");
420+
421+
// Create an augmented agent with additional tools using builder middleware
422+
var augmentedAgent = existingAgent.AsBuilder()
423+
.Use(async (chatMessages, agentThread, agentRunOptions, next, cancellationToken) =>
424+
{
425+
if (agentRunOptions is ChatClientAgentRunOptions chatClientAgentRunOptions)
426+
{
427+
chatClientAgentRunOptions.ChatOptions ??= new ChatOptions();
428+
chatClientAgentRunOptions.ChatOptions.Tools ??= [];
429+
chatClientAgentRunOptions.ChatOptions.Tools.Add(AIFunctionFactory.Create(GetWeather));
430+
}
431+
432+
return await next(chatMessages, agentThread, agentRunOptions, cancellationToken);
433+
})
434+
.Build();
435+
436+
// Use the augmented agent with the additional tools
437+
AgentRunResponse result = await augmentedAgent.RunAsync(userInput, thread);
438+
```
439+
440+
**Required changes:**
441+
1. Call `AsBuilder()` on the existing agent to get a builder
442+
2. Use the `Use()` middleware method to intercept and modify run options
443+
3. Add tools to `ChatClientAgentRunOptions.ChatOptions.Tools` in the middleware
444+
4. Call `Build()` to create the augmented agent instance
445+
5. Use the new augmented agent for invocations that need the additional tools
446+
447+
**Note:** This pattern is the preferred approach as it provides:
448+
- A controlled environment with a dedicated agent instance
449+
- No disruption to existing agent usages
450+
- Dynamic tool composition per user, tenant, or feature flags
451+
- Modular system composition without recreating agents
452+
</configuration_changes>
453+
387454
### Invocation Method Transformation
388455

389456
<api_changes>

dotnet/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
<PackageVersion Include="Testcontainers" Version="4.6.0" />
186186
<PackageVersion Include="Testcontainers.Milvus" Version="4.8.1" />
187187
<PackageVersion Include="Testcontainers.MongoDB" Version="4.6.0" />
188+
<PackageVersion Include="Testcontainers.MsSql" Version="4.6.0" />
188189
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.6.0" />
189190
<PackageVersion Include="Testcontainers.Qdrant" Version="4.6.0" />
190191
<PackageVersion Include="Testcontainers.Redis" Version="4.6.0" />

dotnet/nuget/nuget-package.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project>
22
<PropertyGroup>
33
<!-- Central version prefix - applies to all nuget packages. -->
4-
<VersionPrefix>1.69.0</VersionPrefix>
4+
<VersionPrefix>1.70.0</VersionPrefix>
55
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
66
<PackageVersion Condition="'$(VersionSuffix)' == ''">$(VersionPrefix)</PackageVersion>
77

88
<Configurations>Debug;Release;Publish</Configurations>
99
<IsPackable>true</IsPackable>
1010

1111
<!-- Package validation. Baseline Version should be the latest version available on NuGet. -->
12-
<PackageValidationBaselineVersion>1.68.0</PackageValidationBaselineVersion>
12+
<PackageValidationBaselineVersion>1.69.0</PackageValidationBaselineVersion>
1313
<!-- Validate assembly attributes only for Publish builds -->
1414
<NoWarn Condition="'$(Configuration)' != 'Publish'">$(NoWarn);CP0003</NoWarn>
1515
<!-- Do not validate reference assemblies -->

dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToImageTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public sealed class AzureOpenAITextToImageTests
2424
.AddUserSecrets<AzureOpenAITextToImageTests>()
2525
.Build();
2626

27-
[Fact]
27+
[Fact(Skip = "This test is for manual verification.")]
2828
public async Task ItCanReturnImageUrlAsync()
2929
{
3030
// Arrange

0 commit comments

Comments
 (0)