Skip to content

Updated Teams AI Lib to comply with project specs and create a proper… #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 27, 2025

Conversation

MattB-msft
Copy link
Member

This pull request includes several updates to enhance code maintainability, improve null safety, and simplify schema management. Key changes include making methods in TurnState virtual for easier extensibility, replacing hardcoded schema requirements with reusable static fields, and addressing nullable reference types across multiple files.

Enhancements to extensibility:

  • Made HasValue, SetValue, and DeleteValue methods in TurnState virtual to allow overriding in derived classes (src/libraries/Builder/Microsoft.Agents.Builder/State/TurnState.cs). [1] [2]

Improvements to schema management:

  • Replaced hardcoded required fields in JSON schemas with static arrays for better reusability and maintainability in MonologueAugmentation and related classes (src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Augmentations/MonologueAugmentation.cs). [1] [2] [3] [4] [5]

Null safety and type improvements:

  • Updated ActionCollection and ActionHandler to use nullable reference types, ensuring better handling of potential null values (src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Action/ActionCollection.cs, src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Action/ActionHandler.cs). [1] [2] [3] [4]
  • Added null-forgiving operator (!) in various scenarios to address nullable warnings and improve code clarity. [1] [2]

Additional updates:

  • Introduced #pragma directives to suppress specific code analysis warnings, such as marking members as static and attributes with AttributeUsageAttribute (src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Action/DefaultActions.cs, src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Action/ActionParameterAttribute.cs). [1] [2]
  • Consolidated and streamlined logger initialization in DefaultActions by utilizing generic type parameters (src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Action/DefaultActions.cs).… nuget package.

@Copilot Copilot AI review requested due to automatic review settings May 26, 2025 22:42
@MattB-msft MattB-msft requested a review from a team as a code owner May 26, 2025 22:42
@github-actions github-actions bot added ML: Core Tags changes to core libraries ML: Tests Tags changes to tests labels May 26, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the Teams AI Library by enhancing code maintainability, extensibility, and null safety while simplifying schema management. Key changes include making state management methods virtual for override support, replacing hardcoded schema requirements with reusable static arrays, and updating method calls to include cancellation tokens and proper null handling.

Reviewed Changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Models/OpenAIModel.cs Updated null-forgiving operators, cancellation token usage, and static modifier changes.
src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Models/ChatRole.cs and ChatMessage.cs Adjusted method signatures and optimized collection access (Count property).
src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Augmentations/MonologueAugmentation.cs Replaced inline schema requirements with static arrays and streamlined section construction.
src/libraries/Extensions/Microsoft.Agents.Extensions.Teams.AI/AI/Action/* Applied nullability improvements, generic logger initialization, and updated attribute usage.
src/libraries/Builder/Microsoft.Agents.Builder/State/TurnState.cs Marked key state methods as virtual to facilitate extensibility.

Added CA1854 to the NoWarn property in the project file
to suppress warnings related to this specific code analysis
rule, in addition to the existing warnings.
This commit introduces new features and improvements by adding essential lines of code while removing outdated or unnecessary sections. The changes aim to optimize the program's behavior and maintainability.
@MattB-msft MattB-msft enabled auto-merge (squash) May 27, 2025 03:47
Copy link
Member

@tracyboehrer tracyboehrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem mostly about the various VS suggestions and improvements. I'm fine with all this but perhaps wait for Autumn review.

@MattB-msft MattB-msft merged commit 47f317d into main May 27, 2025
8 checks passed
@MattB-msft MattB-msft deleted the users/mbarbour/FixTeamsAILib branch May 27, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ML: Core Tags changes to core libraries ML: Tests Tags changes to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants