Conversation
Co-authored-by: elbruno <3533489+elbruno@users.noreply.github.com>
Co-authored-by: elbruno <3533489+elbruno@users.noreply.github.com>
Co-authored-by: elbruno <3533489+elbruno@users.noreply.github.com>
|
@copilot generate the docs also in French and Spanish |
Co-authored-by: elbruno <3533489+elbruno@users.noreply.github.com>
Done! I've added comprehensive French and Spanish translations of all documentation. French translations:
Spanish translations:
All translations include:
Commit: 730e67b |
|
@copilot perform these tasks:
|
Co-authored-by: elbruno <3533489+elbruno@users.noreply.github.com>
Done! I've successfully upgraded the entire solution: ✅ Upgraded to .NET 9.0 ✅ Upgraded to Aspire 9.5.0
✅ Updated all NuGet packages to latest stable versions:
✅ Solution builds successfully with all updates. Commit: Latest commit in this PR |
Refactored chat models into a new shared `AgentContracts` project to enable reuse across the solution. Updated solution structure to include `AgentContracts` and reorganized projects into nested folders for better clarity. Implemented a functional chat interface in the Blazor app (`/assistant` page) with real-time messaging, typing indicators, error handling, and responsive design. Added `IShoppingAgentChatService` and its implementation for communication with the backend. Enhanced the `ShoppingAssistantAgent` backend with a `/api/agent/chat` endpoint, integrated shared models, and registered tools for future functionality. Updated Aspire service discovery configuration to include `AgentContracts` and `ShoppingAssistantAgent`. Added detailed documentation for implementation, API contracts, and testing. Introduced temporary models to unblock development until full integration with `AgentContracts` is complete.
Check Country Locale in URLsWe have automatically detected added country locale to URLs in your files. Check the file paths and associated URLs inside them.
|
Check Broken PathsWe have automatically detected the following broken relative paths in your files. Check the file paths and associated broken paths inside them.
|
Check Broken URLsWe have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue. Check the file paths and associated broken URLs inside them.
|
Updated dependencies to include Aspire.Azure.AI.OpenAI for OpenAI integration. Configured OpenAI client with GPT-4.1-mini and implemented Microsoft Agent Framework for dynamic function invocation. Enhanced the chat endpoint to support conversation history, tool-based function calling, and improved logging. Updated Azure OpenAI deployment configuration to align with the new model version. Refactored code for better readability and maintainability. Improved error handling in the chat endpoint.
Check Country Locale in URLsWe have automatically detected added country locale to URLs in your files. Check the file paths and associated URLs inside them.
|
Check Broken PathsWe have automatically detected the following broken relative paths in your files. Check the file paths and associated broken paths inside them.
|
Check Country Locale in URLsWe have automatically detected added country locale to URLs in your files. Check the file paths and associated URLs inside them.
|
Check Broken PathsWe have automatically detected the following broken relative paths in your files. Check the file paths and associated broken paths inside them.
|
| } | ||
|
|
||
| logger.LogInformation("Received chat message with image: {Message}, ImageSize: {Size}", | ||
| message, imageFile.Length); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix this problem, user input should be sanitized before being logged. Since this application is logging plain text, the recommended mitigation is to remove newline and carriage return characters (and optionally other non-printable/control characters) from the string before logging it. This ensures the user cannot inject line breaks or otherwise manipulate the structure of the logs. The single best change is to sanitize the message variable just before logging, replacing any \r and \n characters with empty strings.
Specifically:
- In
ChatWithAgentAndImage, immediately before line 215 (thelogger.LogInformationcall), create a sanitized version ofmessage, e.g.,sanitizedMessage, by removing newline and carriage returns. - Log
sanitizedMessageinstead ofmessage. - Use the standard
string.Replace("\r", "").Replace("\n", "")method for sanitization. - No external dependencies are needed.
Only the ChatWithAgentAndImage method needs to be changed as per the snippet and error.
| @@ -212,8 +212,9 @@ | ||
| return Results.BadRequest("Image is required"); | ||
| } | ||
|
|
||
| var sanitizedMessage = message.Replace("\r", "").Replace("\n", ""); | ||
| logger.LogInformation("Received chat message with image: {Message}, ImageSize: {Size}", | ||
| message, imageFile.Length); | ||
| sanitizedMessage, imageFile.Length); | ||
|
|
||
| conversationId = string.IsNullOrWhiteSpace(conversationId) | ||
| ? Guid.NewGuid().ToString() |
scenarios/13-AgentFramework/src/ShoppingAssistantAgent/Services/ImageAgentOrchestrator.cs
Fixed
Show fixed
Hide fixed
scenarios/13-AgentFramework/src/ShoppingAssistantAgent/Services/ImageAgentOrchestrator.cs
Fixed
Show fixed
Hide fixed
Updated namespaces and dependencies to integrate the Microsoft.Agents.AI framework. Replaced the `ImageAgent` registration with a new `ImageProcessingAgent` using `builder.AddAIAgent`, enabling advanced image analysis capabilities for outdoor and camping products. Updated `ShoppingAssistantAgent.csproj` with new AI-related packages and upgraded `Swashbuckle.AspNetCore` to v9.0.6 for improved OpenAPI support.
Check Broken PathsWe have automatically detected the following broken relative paths in your files. Check the file paths and associated broken paths inside them.
|
Check Country Locale in URLsWe have automatically detected added country locale to URLs in your files. Check the file paths and associated URLs inside them.
|
Check Broken URLsWe have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue. Check the file paths and associated broken URLs inside them.
|
1 similar comment
Check Broken URLsWe have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue. Check the file paths and associated broken URLs inside them.
|
|
@copilot perform these tasks:
-- and these sample lines to create and chat with the agent IChatClient chatClient = AIAgent writer = new ChatClientAgent( AgentRunResponse response = await writer.RunAsync("Write a short story about a haunted house."); Console.WriteLine(response.Text); -- Use the code and references from here: https://learn.microsoft.com/en-us/agent-framework/tutorials/agents/run-agent?pivots=programming-language-csharp
builder.AddAIAgent(
|
…image upload support Co-authored-by: elbruno <3533489+elbruno@users.noreply.github.com>
I've completed all the requested tasks: ✅ Agent Framework Implementation:
✅ Endpoint Refactoring:
✅ Image Upload Support:
✅ Telemetry & Monitoring:
Build Status: ✅ Solution compiles successfully with 0 errors Commit: 8c5a6f3 |
- Changed service lifetimes for `ProductDetailsTool` and `AddToCartTool` to `Scoped` for better resource management. - Refactored `HttpClient` usage in tools to simplify code. - Updated product search endpoint to align with RESTful conventions. - Added suggested questions and `SetSuggestedQuestion` method in `Assistant.razor` to improve user interaction. - Adjusted project dependencies to ensure proper API references. - Configured Azure OpenAI resources for production, including `gpt-4.1-mini` deployment. - Added `app.MapDefaultEndpoints()` to configure the HTTP pipeline. - Cleaned up code formatting for better readability.
Check Broken PathsWe have automatically detected the following broken relative paths in your files. Check the file paths and associated broken paths inside them.
|
Check Country Locale in URLsWe have automatically detected added country locale to URLs in your files. Check the file paths and associated URLs inside them.
|
|
|
||
| _logger.LogInformation( | ||
| "Message recorded - ConversationId: {ConversationId}, Type: {MessageType}, Length: {Length}", | ||
| conversationId, messageType, messageLength); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To prevent log entry forging and related confusion, all user-derived values logged should be sanitized to remove problematic characters such as newlines and carriage returns. The existing method SanitizeForLog(string input) is appropriate for this purpose and already in use for RecordError. The safest and most consistent fix is to apply this method to instances where conversationId is logged in RecordMessage (line 60) as well. This involves updating line 60 to use SanitizeForLog(conversationId) in the logger call, matching the approach in RecordError. No further code changes are required.
| @@ -57,7 +57,7 @@ | ||
|
|
||
| _logger.LogInformation( | ||
| "Message recorded - ConversationId: {ConversationId}, Type: {MessageType}, Length: {Length}", | ||
| conversationId, messageType, messageLength); | ||
| SanitizeForLog(conversationId), messageType, messageLength); | ||
| } | ||
|
|
||
| public void RecordError(string conversationId, string errorType, string errorMessage) |
scenarios/13-AgentFramework/src/ShoppingAssistantAgent/Services/TelemetryAgent.cs
Fixed
Show fixed
Hide fixed
|
|
||
| _logger.LogInformation( | ||
| "Response time recorded - ConversationId: {ConversationId}, Duration: {DurationMs}ms", | ||
| conversationId, durationMs); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, all instances where potentially user-provided data (conversationId) is written to logs must be sanitized. A dedicated sanitization utility exists already (SanitizeForLog) which strips \r and \n characters. The fix is to update all usages of conversationId in log calls to use this sanitization function. Specifically, change line 78 in RecordResponseTime to use SanitizeForLog(conversationId) instead of conversationId. This change should be localized to the block implementing the logging call, mirroring the mitigation used in RecordError in the same class.
| @@ -75,7 +75,7 @@ | ||
|
|
||
| _logger.LogInformation( | ||
| "Response time recorded - ConversationId: {ConversationId}, Duration: {DurationMs}ms", | ||
| conversationId, durationMs); | ||
| SanitizeForLog(conversationId), durationMs); | ||
| } | ||
|
|
||
| public void RecordToolInvocation(string conversationId, string toolName, bool success) |
Check Broken URLsWe have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue. Check the file paths and associated broken URLs inside them.
|
|
@copilot implement these:
builder public static TBuilder ConfigureOpenTelemetry(this TBuilder builder) where TBuilder : IHostApplicationBuilder
|
…isplays for tool usage and tokens Co-authored-by: elbruno <3533489+elbruno@users.noreply.github.com>
I've implemented all the requested features: ✅ Persisted Conversation Memory
✅ Tool Usage Display
✅ Telemetry Information Display
✅ OpenTelemetry Configuration
Build Status: ✅ Solution compiles successfully with 0 errors Commit: cbcef11 |
…m user input Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Check Country Locale in URLsWe have automatically detected added country locale to URLs in your files. Check the file paths and associated URLs inside them.
|
Check Broken PathsWe have automatically detected the following broken relative paths in your files. Check the file paths and associated broken paths inside them.
|
Check Broken URLsWe have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue. Check the file paths and associated broken URLs inside them.
|
Overview
This PR introduces Scenario 13 - Shopping Assistant Agent, a new reference implementation demonstrating the integration of Microsoft's Agent Framework with eShopLite. The scenario showcases an intelligent AI-powered shopping assistant that helps users discover products, get detailed information, and manage their shopping cart through natural language conversations with support for image-based queries, persisted conversation memory, and real-time telemetry visualization.
Built with the latest .NET 9.0 and Aspire 9.5.1 with all NuGet packages updated to their latest versions for modern cloud-native development.
What's New
Shopping Assistant Agent Service
A new ASP.NET Core Web API service that provides conversational commerce capabilities:
Three Specialized Agent Tools:
SearchCatalogTool- Searches the product catalog using natural language queriesProductDetailsTool- Retrieves detailed product information by IDAddToCartTool- Adds products to the shopping cart with quantity validationMulti-Agent Architecture with ChatClientAgent Pattern:
ChatClientAgentandChatClientAgentOptionsMicrosoft Agent Framework Integration:
Microsoft.Agents.AI.ChatClientAgentfor agent orchestrationbuilder.AddAIAgent()patternAIFunctionFactory.Create()for tool registrationAgentRunResponsefor agent execution results/api/agent/chatendpoint with persisted conversation memory/api/agent/chat-with-imageendpoint for image-based queriesAdvanced Features
Persisted Conversation Management:
ConcurrentDictionary<string, List<ChatMessage>>Real-time Telemetry Visualization in UI:
Image Upload & Processing:
DataContentfor imagesObservability & Telemetry:
EnableSensitiveTelemetryData = trueShoppingAssistant.ZavaAgentShoppingAssistant.ImageAgentShoppingAssistant.Telemetryshopping_assistant.messages.total(Counter)shopping_assistant.errors.total(Counter)shopping_assistant.response_time(Histogram)RecordMessage(),RecordResponseTime(),RecordError()Aspire Orchestration
Updated
.NET Aspire AppHostconfiguration to include:Architecture
graph TB User[User] --> Store[Store UI with Image Upload & Telemetry Display] Store --> AgentEndpoints[Agent Endpoints with Conversation Memory] AgentEndpoints --> ZavaAgent[ZavaAssistant ChatClientAgent] AgentEndpoints --> ImageAgent[Image ChatClientAgent] ZavaAgent --> SearchTool[SearchCatalog Tool] ZavaAgent --> DetailsTool[ProductDetails Tool] ZavaAgent --> CartTool[AddToCart Tool] ImageAgent --> ProductsAPI[Products API] SearchTool --> ProductsAPI DetailsTool --> ProductsAPI CartTool --> ProductsAPI TelemetryAgent[Telemetry Agent] --> Metrics[Metrics Collection] ZavaAgent --> AzureOpenAI[Azure OpenAI] ImageAgent --> AzureOpenAI TelemetryAgent --> Tracing[Distributed Tracing] Store --> TelemetryDisplay[Real-time Telemetry Display]Framework & Technology Stack
Modern .NET 9.0 Platform
Key Package Versions:
Comprehensive Documentation (English, French & Spanish)
Complete documentation is now available in three languages to support international developers:
English Documentation
README.md - Complete scenario documentation with:
azd upTechnical Documentation (
docs/agent/):10_overview.md- Scenario introduction, capabilities, and benefits20_architecture.md- Detailed system architecture with sequence diagrams30_setup_local.md- Step-by-step local development setup with troubleshootingIMPLEMENTATION_SUMMARY.md- Implementation status and roadmapFrench Documentation (Français)
10_overview.md- Vue d'ensemble et cas d'utilisation20_architecture.md- Architecture détaillée avec diagrammes30_setup_local.md- Guide de configuration localeSpanish Documentation (Español)
10_overview.md- Descripción general y casos de uso20_architecture.md- Arquitectura detallada con diagramas30_setup_local.md- Guía de configuración localAll translations include:
Project Structure
Technical Details
Persisted Conversation Implementation
Conversation Memory Pattern:
Telemetry Data Models
TelemetryData Model:
Telemetry Collection
Response Time & Token Tracking:
UI Telemetry Display
Frontend Telemetry Rendering:
ChatClientAgent Implementation
ZavaAssistant Agent Registration:
Sensitive Telemetry Enabled:
Agent Tools Implementation
Each tool is implemented with proper error handling, logging, and HTTP client integration:
API Endpoints
Conversation Endpoints:
POST /api/agent/chat- Main chat endpoint with persisted conversation memory and telemetryPOST /api/agent/chat-with-image- Image upload and analysis endpoint with multi-modal contentDELETE /api/agent/conversation/{id}- Delete conversation historyGET /api/agent/health- Health check endpointConfiguration Support
The agent supports flexible configuration for different environments:
Build & Deployment
azd updeployment to AzureTesting
Run the scenario locally:
cd scenarios/13-AgentFramework/src/eShopAppHost dotnet runAccess the Aspire Dashboard to monitor all services, view logs, and check health status. Interact with the Assistant chat to see persisted conversations and real-time telemetry visualization.
Internationalization
This scenario is designed for global adoption with complete documentation in:
All translations maintain consistency with architecture diagrams, code examples, and technical accuracy across languages.
References
Definition of Done
This PR delivers a complete Microsoft Agent Framework implementation for eShopLite using the official
ChatClientAgentpattern, complete with specialized agents (ZavaAssistant, ImageAgent, TelemetryAgent), image upload support, persisted conversation memory, real-time telemetry visualization in the UI, comprehensive multilingual documentation, and built on the latest .NET 9.0 and Aspire 9.5.1 platform. The architecture follows official Microsoft Agent Framework patterns from documentation withbuilder.AddAIAgent(),AIFunctionFactory,AgentRunResponse, conversation persistence, token tracking, tool monitoring, distributed tracing, metrics collection, and advanced observability features to support global developer adoption with modern cloud-native capabilities.Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.