Skip to content

Commit 36f6813

Browse files
authored
fix build errors (#4)
1 parent 4c1b479 commit 36f6813

4 files changed

Lines changed: 89 additions & 97 deletions

File tree

labs/00-foundations/lab07-skills/Program.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
// 2. Load - full instructions loaded on-demand via load_skill tool
5858
// 3. Read resources - supplementary files loaded via read_skill_resource tool
5959
var skillsProvider = new FileAgentSkillsProvider(
60-
skillPath: Path.Combine(AppContext.BaseDirectory, "skills"));
60+
skillPath: Path.Combine(Directory.GetCurrentDirectory(), "labs/00-foundations/lab07-skills/skills"));
6161

6262
appLogger.LogInformation("FileAgentSkillsProvider created, discovering skills from ./skills directory");
6363

@@ -86,22 +86,22 @@
8686

8787
appLogger.LogInformation("=== Travel Assistant with File-Based Skills ===");
8888

89-
// Example 1: Weather inquiry (agent will load weather-info skill)
90-
appLogger.LogInformation("Example 1: Checking weather for destination");
91-
appLogger.LogInformation("--------------------------------------------");
92-
var query1 = "I'm traveling to Tokyo in December. What's the weather like and what should I pack?";
93-
appLogger.LogInformation("User: {Query}", query1);
94-
var response1 = await agent.RunAsync(query1, session);
95-
appLogger.LogInformation("Agent: {Response}", response1.Text);
96-
97-
// // Example 2: Visa requirements (agent will load visa-recommendation skill)
98-
// appLogger.LogInformation("");
99-
// appLogger.LogInformation("Example 2: Visa requirements");
100-
// appLogger.LogInformation("----------------------------");
101-
// var query2 = "I'm an Australian citizen planning to visit Japan for 2 weeks and then Canada for a week. What visas do I need?";
102-
// appLogger.LogInformation("User: {Query}", query2);
103-
// var response2 = await agent.RunAsync(query2, session);
104-
// appLogger.LogInformation("Agent: {Response}", response2.Text);
89+
// // Example 1: Weather inquiry (agent will load weather-info skill)
90+
// appLogger.LogInformation("Example 1: Checking weather for destination");
91+
// appLogger.LogInformation("--------------------------------------------");
92+
// var query1 = "I'm traveling to Tokyo in December. What's the weather like and what should I pack?";
93+
// appLogger.LogInformation("User: {Query}", query1);
94+
// var response1 = await agent.RunAsync(query1, session);
95+
// appLogger.LogInformation("Agent: {Response}", response1.Text);
96+
97+
// Example 2: Visa requirements (agent will load visa-recommendation skill)
98+
appLogger.LogInformation("");
99+
appLogger.LogInformation("Example 2: Visa requirements");
100+
appLogger.LogInformation("----------------------------");
101+
var query2 = "I'm an Australian citizen planning to visit Japan for 2 weeks and then Canada for a week. What visas do I need?";
102+
appLogger.LogInformation("User: {Query}", query2);
103+
var response2 = await agent.RunAsync(query2, session);
104+
appLogger.LogInformation("Agent: {Response}", response2.Text);
105105

106106
// // Example 3: Destination recommendation (agent will load destination-recommendation skill)
107107
// appLogger.LogInformation("");
@@ -143,7 +143,7 @@ static string GetWeatherForecast([Description("The city name to get weather for"
143143
var temp = random.Next(-5, 40);
144144
var condition = conditions[random.Next(conditions.Length)];
145145
var humidity = random.Next(30, 90);
146-
146+
147147
return $"Weather in {city}: {condition}, {temp}C, Humidity: {humidity}%";
148148
}
149149

src/backend/Agents/Workflow/FlightSearchAgentFactory.cs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ public FlightSearchAgentFactory(
114114

115115
public AIAgent Create()
116116
{
117-
var agent = _chatClient.CreateAIAgent(new ChatClientAgentOptions
117+
// Get userId at creation time since agents are created per-request
118+
string userId = _httpContextAccessor.HttpContext?.Items["UserId"] as string ?? "default-user";
119+
120+
var agent = _chatClient.AsAIAgent(new ChatClientAgentOptions
118121
{
119122
Name = "flight_search_agent",
120123
Description = "Searches and recommends flights for a chosen destination. Helps users compare flight options, validate travel dates.",
@@ -133,27 +136,15 @@ public AIAgent Create()
133136
#pragma warning restore MEAI001
134137
]
135138
},
136-
AIContextProviderFactory = (ctx) =>
137-
{
138-
// Use ApplicationId and UserId for memory scope
139-
string userId = _httpContextAccessor.HttpContext?.Items["UserId"] as string ?? "default-user";
140-
var userProfileMemoryProvider = new UserProfileMemoryProvider(
141-
_chatClient,
142-
new UserProfileMemoryProviderScope
143-
{
144-
UserId = userId,
145-
ApplicationId = Constants.ApplicationId
146-
});
147-
148-
return userProfileMemoryProvider;
149-
}
150-
});
151-
152-
agent.AsBuilder().UseOpenTelemetry(Constants.ApplicationId, options =>
153-
{
154-
// Enable sensitive data logging for tool calls and responses
155-
options.EnableSensitiveData = true;
156-
}).UseLogging(_loggerFactory).Build();
139+
AIContextProviders = [new UserProfileMemoryProvider(
140+
_chatClient,
141+
new UserProfileMemoryProviderScope
142+
{
143+
UserId = userId,
144+
ApplicationId = Constants.ApplicationId
145+
})]
146+
}, _loggerFactory);
147+
157148
return new ServerFunctionApprovalAgent(agent, _jsonSerializerOptions);
158149
}
159150
}

src/backend/Agents/Workflow/TripAdvisorAgentFactory.cs

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,42 @@ Which of these appeals to you?"
140140

141141
public AIAgent Create()
142142
{
143-
return _chatClient.CreateAIAgent(new ChatClientAgentOptions
143+
// Get userId at creation time since agents are created per-request
144+
string userId = _httpContextAccessor.HttpContext?.Items["UserId"] as string ?? "default-user";
145+
146+
var userProfileMemoryProvider = new UserProfileMemoryProvider(
147+
_chatClient,
148+
new UserProfileMemoryProviderScope
149+
{
150+
UserId = userId,
151+
ApplicationId = Constants.ApplicationId
152+
});
153+
154+
var chatHistoryMemoryProvider = new CosmosDbChatHistoryProvider(
155+
_cosmosDatabase.Client,
156+
_cosmosDatabase.Id,
157+
containerName: "ChatHistory",
158+
partitionKeyPath: "/ApplicationId",
159+
storageScope: new()
160+
{
161+
UserId = userId,
162+
ApplicationId = Constants.ApplicationId
163+
},
164+
embeddingGenerator: _embeddingClient.AsIEmbeddingGenerator(),
165+
searchScope: new()
166+
{
167+
UserId = userId,
168+
ApplicationId = Constants.ApplicationId
169+
},
170+
options: new ChatHistoryMemoryProviderOptions()
171+
{
172+
ContextPrompt = "## Memories\nConsider the following memories when answering user questions:",
173+
EnableSensitiveTelemetryData = true,
174+
MaxResults = 10
175+
},
176+
loggerFactory: _loggerFactory);
177+
178+
return _chatClient.AsAIAgent(new ChatClientAgentOptions
144179
{
145180
Name = "trip_advisor_agent",
146181
Description = "Provides personalized destination recommendations and travel advice for Contoso Travel Agency.",
@@ -154,46 +189,7 @@ public AIAgent Create()
154189
AIFunctionFactory.Create(UserContextTools.GetUserContext)
155190
]
156191
},
157-
AIContextProviderFactory = (ctx) =>
158-
{
159-
// Use ApplicationId and UserId for memory scope
160-
string userId = _httpContextAccessor.HttpContext?.Items["UserId"] as string ?? "default-user";
161-
var userProfileMemoryProvider = new UserProfileMemoryProvider(
162-
_chatClient,
163-
new UserProfileMemoryProviderScope
164-
{
165-
UserId = userId,
166-
ApplicationId = Constants.ApplicationId
167-
});
168-
169-
var chatHistoryMemoryProvider = new CosmosDbChatHistoryProvider(
170-
_cosmosDatabase.Client,
171-
_cosmosDatabase.Id,
172-
containerName: "ChatHistory",
173-
partitionKeyPath: "/ApplicationId",
174-
storageScope: new()
175-
{
176-
UserId = userId,
177-
ApplicationId = Constants.ApplicationId
178-
},
179-
embeddingGenerator: _embeddingClient.AsIEmbeddingGenerator(),
180-
searchScope: new()
181-
{
182-
UserId = userId,
183-
ApplicationId = Constants.ApplicationId
184-
},
185-
options: new ChatHistoryMemoryProviderOptions()
186-
{
187-
ContextPrompt = "## Memories\nConsider the following memories when answering user questions:",
188-
EnableSensitiveTelemetryData = true,
189-
MaxResults = 10
190-
},
191-
loggerFactory: _loggerFactory);
192-
193-
194-
return new CompositeMemoryProvider
195-
([userProfileMemoryProvider, chatHistoryMemoryProvider]);
196-
}
197-
});
192+
AIContextProviders = [new CompositeMemoryProvider([userProfileMemoryProvider, chatHistoryMemoryProvider])]
193+
}, _loggerFactory);
198194
}
199195
}

src/backend/ContosoTravelAgent.Host.csproj

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<Compile Remove="Agents\Workflow\**" />
1213
<Compile Remove="Controllers\**" />
1314
<Compile Remove="Mem0\**" />
15+
<Content Remove="Agents\Workflow\**" />
1416
<Content Remove="Controllers\**" />
1517
<Content Remove="Mem0\**" />
18+
<EmbeddedResource Remove="Agents\Workflow\**" />
1619
<EmbeddedResource Remove="Controllers\**" />
1720
<EmbeddedResource Remove="Mem0\**" />
21+
<None Remove="Agents\Workflow\**" />
1822
<None Remove="Controllers\**" />
1923
<None Remove="Mem0\**" />
2024
</ItemGroup>
2125

2226
<ItemGroup>
27+
<Compile Remove="Agents\ServerFunctionApprovalAgent.cs" />
2328
<Compile Remove="Services\ChatHistoryMemoryProvider.cs" />
2429
<Compile Remove="Services\ChatHistoryMemoryProviderOptions.cs" />
2530
<Compile Remove="Services\ChatHistoryMemoryProviderScope.cs" />
@@ -28,31 +33,31 @@
2833

2934
<ItemGroup>
3035
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
31-
<PackageReference Include="Azure.Identity" Version="1.17.1" />
36+
<PackageReference Include="Azure.Identity" Version="1.18.0" />
3237
<PackageReference Include="DotNetEnv" Version="3.1.1" />
33-
<PackageReference Include="Microsoft.Agents.AI.Abstractions" Version="1.0.0-preview.260108.1" />
34-
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
35-
<PackageReference Include="Microsoft.Agents.AI" Version="1.0.0-preview.260108.1" />
36-
<PackageReference Include="Microsoft.Agents.AI.DevUI" Version="1.0.0-preview.260108.1" />
37-
<PackageReference Include="Microsoft.Agents.AI.Hosting.AGUI.AspNetCore" Version="1.0.0-preview.260108.1" />
38-
<PackageReference Include="Microsoft.Agents.AI.Workflows" Version="1.0.0-preview.260108.1" />
39-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.2" />
38+
<PackageReference Include="Microsoft.Agents.AI.Abstractions" Version="1.0.0-rc2" />
39+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="3.0.0" />
40+
<PackageReference Include="Microsoft.Agents.AI" Version="1.0.0-rc2" />
41+
<PackageReference Include="Microsoft.Agents.AI.DevUI" Version="1.0.0-preview.260225.1" />
42+
<PackageReference Include="Microsoft.Agents.AI.Hosting.AGUI.AspNetCore" Version="1.0.0-preview.260225.1" />
43+
<PackageReference Include="Microsoft.Agents.AI.Workflows" Version="1.0.0-rc2" />
44+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.3" />
4045
<PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.6.0" />
41-
<PackageReference Include="Microsoft.Extensions.AI" Version="10.2.0" />
42-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.1.1-preview.1.25612.2" />
43-
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="10.2.0" />
44-
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.57.0" />
46+
<PackageReference Include="Microsoft.Extensions.AI" Version="10.3.0" />
47+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.3.0" />
48+
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="10.3.0" />
49+
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.57.1" />
4550
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
46-
<PackageReference Include="OpenAI" Version="2.8.0" />
47-
<PackageReference Include="ModelContextProtocol" Version="0.5.0-preview.1" />
51+
<PackageReference Include="OpenAI" Version="2.9.0" />
52+
<PackageReference Include="ModelContextProtocol" Version="1.0.0" />
4853
<PackageReference Include="OpenTelemetry" Version="1.15.0" />
4954
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.15.0" />
5055
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.15.0" />
5156
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.15.0" />
5257
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.15.0" />
5358
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.15.0" />
5459
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.15.0" />
55-
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.1" />
60+
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.4" />
5661
</ItemGroup>
5762

5863
<ItemGroup>

0 commit comments

Comments
 (0)