Improve citation and reaction logic#452
Conversation
siddharthh98
commented
Feb 20, 2026
- Add GenesysHandoff.sln solution file for project structure.
- Refactor GenesysHandoffAgent to delegate Copilot client creation, activity response processing, and conversation state management to new service classes.
- Introduce ActivityResponseProcessor, CitationEntityProcessor, CitationUrlCleaner, ConversationStateManager, and CopilotClientFactory.
- Move citation and entity processing logic out of the agent for better separation of concerns.
- Improve logging, documentation, and dependency injection for maintainability and testability.
- Remove redundant code and clarify XML docs.
- Add GenesysHandoff.sln solution file for project structure. - Refactor GenesysHandoffAgent to delegate Copilot client creation, activity response processing, and conversation state management to new service classes. - Introduce ActivityResponseProcessor, CitationEntityProcessor, CitationUrlCleaner, ConversationStateManager, and CopilotClientFactory. - Move citation and entity processing logic out of the agent for better separation of concerns. - Improve logging, documentation, and dependency injection for maintainability and testability. - Remove redundant code and clarify XML docs.
There was a problem hiding this comment.
Pull request overview
This PR refactors the GenesysHandoffAgent to improve separation of concerns by extracting citation processing, activity response handling, conversation state management, and Copilot client creation into dedicated service classes. The refactoring aims to improve code maintainability, testability, and documentation.
Changes:
- Extracted Copilot client creation, activity processing, citation handling, and state management into dedicated service classes
- Improved XML documentation and logging throughout the codebase
- Added GenesysHandoff.sln solution file for project structure
- Changed from AskQuestionAsync to SendActivityAsync API for CopilotClient interaction
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| GenesysHandoffAgent.cs | Refactored to delegate responsibilities to new service classes; broke down HandleAllActivities into smaller methods |
| Services/CopilotClientFactory.cs | New factory class for creating configured CopilotClient instances |
| Services/ConversationStateManager.cs | New class to manage conversation state properties |
| Services/CitationUrlCleaner.cs | New utility class for removing citation URLs from text |
| Services/CitationEntityProcessor.cs | New class to process and fix citation entities for Teams rendering |
| Services/ActivityResponseProcessor.cs | New class to process Copilot Studio activities and prepare responses |
| GenesysHandoff.sln | New Visual Studio solution file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
samples/dotnet/GenesysHandoff/Services/ConversationStateManager.cs
Outdated
Show resolved
Hide resolved
samples/dotnet/GenesysHandoff/Services/ActivityResponseProcessor.cs
Outdated
Show resolved
Hide resolved
samples/dotnet/GenesysHandoff/Services/ActivityResponseProcessor.cs
Outdated
Show resolved
Hide resolved
- Refactored GenesysHandoffAgent to use constructor injection for CopilotClientFactory, ActivityResponseProcessor, and ConversationStateManager; registered these as singletons in Program.cs. - Enhanced CopilotClientFactory with required ILogger, robust error handling, and improved configuration validation and logging. - Improved ActivityResponseProcessor: clarified which properties are copied, made channel data handling safer, and added better logging. - Strengthened citation entity and URL processing for robustness and type safety. - Updated ConversationStateManager documentation and clarified default behaviors. - Modified message forwarding to Copilot Studio to construct a new Activity with the correct conversation ID and relevant properties. - Improved parameter validation, XML documentation, and removed unused code for better maintainability and clarity.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
samples/dotnet/GenesysHandoff/Services/ConversationStateManager.cs
Outdated
Show resolved
Hide resolved
Refactored ConversationStateManager to validate arguments and throw exceptions for null/empty values. Updated method signatures and XML docs for clarity. Replaced block comments with line comments in GenesysHandoffAgent.cs. Added using System for exception handling.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.