Skip to content

Commit 96b3a6a

Browse files
authored
Merge branch 'main' into fix-mcp-hang-on-init
2 parents 93b77d3 + 889807d commit 96b3a6a

File tree

313 files changed

+13938
-14853
lines changed

Some content is hidden

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

313 files changed

+13938
-14853
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@
22
"image": "mcr.microsoft.com/devcontainers/universal:2",
33
"features": {
44
"ghcr.io/devcontainers/features/node:1": {},
5-
"ghcr.io/devcontainers/features/dotnet:1": {
6-
"version": "8"
5+
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools:1": {},
6+
"ghcr.io/devcontainers/features/github-cli:1": {
7+
"version": "2"
78
},
8-
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools:1": {}
9+
"ghcr.io/devcontainers/features/powershell:1": {
10+
"version": "latest"
11+
},
12+
"ghcr.io/azure/azure-dev/azd:0": {
13+
"version": "latest"
14+
},
15+
"ghcr.io/devcontainers/features/common-utils:2": {},
16+
"ghcr.io/devcontainers/features/dotnet:2": {
17+
"version": "none",
18+
"dotnetRuntimeVersions": "10.0",
19+
"aspNetCoreRuntimeVersions": "10.0"
20+
},
21+
"ghcr.io/devcontainers/features/copilot-cli:1": {}
922
},
1023
"customizations": {
1124
"vscode": {

.github/upgrades/prompts/SemanticKernelToAgentFramework.md

Lines changed: 70 additions & 7 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>
@@ -803,20 +870,16 @@ var agentOptions = new ChatClientAgentRunOptions(new ChatOptions
803870
{
804871
MaxOutputTokens = 8000,
805872
// Breaking glass to access provider-specific options
806-
RawRepresentationFactory = (_) => new OpenAI.Responses.ResponseCreationOptions()
873+
RawRepresentationFactory = (_) => new OpenAI.Responses.CreateResponseOptions()
807874
{
808-
ReasoningOptions = new()
809-
{
810-
ReasoningEffortLevel = OpenAI.Responses.ResponseReasoningEffortLevel.High,
811-
ReasoningSummaryVerbosity = OpenAI.Responses.ResponseReasoningSummaryVerbosity.Detailed
812-
}
875+
TruncationMode = OpenAI.Responses.ResponseTruncationMode.Auto,
813876
}
814877
});
815878
```
816879

817880
**Use this pattern when:**
818881
1. Standard `ChatOptions` properties don't cover required model settings
819-
2. Provider-specific configuration is needed (e.g., reasoning effort level)
882+
2. Provider-specific configuration is needed (e.g., truncation mode)
820883
3. Advanced SDK features need to be accessed
821884
</configuration_changes>
822885

.github/workflows/dotnet-build-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
persist-credentials: false
7575

7676
- name: Setup dotnet
77-
uses: actions/setup-dotnet@v4.3.1
77+
uses: actions/setup-dotnet@v5
7878
with:
7979
global-json-file: ${{ github.workspace }}/dotnet/global.json
8080

.github/workflows/dotnet-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
persist-credentials: false
7979

8080
- name: Setup .NET SDK ${{ matrix.dotnet-version }}
81-
uses: actions/setup-dotnet@v4
81+
uses: actions/setup-dotnet@v5
8282
with:
8383
dotnet-version: ${{ matrix.dotnet-version }}
8484
env:

.github/workflows/dotnet-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
persist-credentials: false
3030

3131
- name: Setup .NET
32-
uses: actions/setup-dotnet@v4
32+
uses: actions/setup-dotnet@v5
3333
if: ${{ github.event_name != 'pull_request' }}
3434
with:
3535
dotnet-version: 10.0.x

.github/workflows/generate-pr-description.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)