* Bump Azure.AI.Projects to 2.0.0 GA - Update Azure.AI.Projects from 2.0.0-beta.2 to 2.0.0 in CPM - Update Azure.Identity from 1.19.0 to 1.20.0 (transitive dep) - Update System.ClientModel from 1.9.0 to 1.10.0 (transitive dep) - Rename types per Azure.AI.Projects.Agents 2.0.0 breaking changes: - AgentVersion -> ProjectsAgentVersion - AgentRecord -> ProjectsAgentRecord - AgentDefinition -> ProjectsAgentDefinition - AgentVersionCreationOptions -> ProjectsAgentVersionCreationOptions - PromptAgentDefinition -> DeclarativeAgentDefinition - AgentTool -> ProjectsAgentTool - AgentsClient -> AgentAdministrationClient - .Agents property -> .AgentAdministrationClient - Add using Azure.AI.Projects.Memory namespace (types moved) - Update AGENTS.md with BOM and output capture conventions * Address PR review feedback - Rename AIProjectClient parameter to aiProjectClient in AsChatClientAgent overloads - Fix XML doc: ProjectsAgentTool namespace from Azure.AI.Projects.OpenAI to Azure.AI.Projects.Agents - Rename test method to reflect DeclarativeAgentDefinition terminology
3.9 KiB
AGENTS.md
Instructions for AI coding agents working in the .NET codebase.
Build, Test, and Lint Commands
See ./.github/skills/build-and-test/SKILL.md for detailed instructions on building, testing, and linting projects.
Project Structure
See ./.github/skills/project-structure/SKILL.md for an overview of the project structure.
Core types
AIAgent: The abstract base class that all agents derive from, providing common methods for interacting with an agent.AgentSession: The abstract base class that all agent sessions derive from, representing a conversation with an agent.ChatClientAgent: AnAIAgentimplementation that uses anIChatClientto send messages to an AI provider and receive responses.IChatClient: Interface for sending messages to an AI provider and receiving responses. Used byChatClientAgentand implemented by provider-specific packages.FunctionInvokingChatClient: Decorator forIChatClientthat adds function invocation capabilities.AITool: Represents a tool that an agent/AI provider can use, with metadata and an execution delegate.AIFunction: A specific type ofAIToolthat represents a local function the agent/AI provider can call, with parameters and return types defined.ChatMessage: Represents a message in a conversation.AIContent: Represents content in a message, which can be text, a function call, tool output and more.
External Dependencies
The framework integrates with Microsoft.Extensions.AI and Microsoft.Extensions.AI.Abstractions (external NuGet packages)
using types like IChatClient, FunctionInvokingChatClient, AITool, AIFunction, ChatMessage, and AIContent.
Key Conventions
- Command output capture: When running
dotnet build,dotnet test,dotnet format, or similar commands, redirect output to a temp file first (e.g.,dotnet build --tl:off 2>&1 | Out-File $env:TEMP\build.log), then analyze the file as needed. This avoids re-running expensive commands when the initial analysis misses something. - Encoding: All new files must be saved with UTF-8 encoding with BOM (Byte Order Mark). This is required for
dotnet formatto work correctly. When using PowerShellSet-Content, always pass-Encoding UTF8BOMto preserve the BOM (e.g.,Set-Content $file $content -NoNewline -Encoding UTF8BOM). - Copyright header:
// Copyright (c) Microsoft. All rights reserved.at top of all.csfiles - XML docs: Required for all public methods and classes
- Async: Use
Asyncsuffix for methods returningTask/ValueTask - Private classes: Should be
sealedunless subclassed - Config: Read from environment variables with
UPPER_SNAKE_CASEnaming - Tests: Add Arrange/Act/Assert comments; use Moq for mocking
Key Design Principles
When developing or reviewing code, verify adherence to these key design principles:
- DRY: Avoid code duplication by moving common logic into helper methods or helper classes.
- Single Responsibility: Each class should have one clear responsibility.
- Encapsulation: Keep implementation details private and expose only necessary public APIs.
- Strong Typing: Use strong typing to ensure that code is self-documenting and to catch errors at compile time.
Sample Structure
Samples (in ./samples/ folder) should follow this structure:
- Copyright header:
// Copyright (c) Microsoft. All rights reserved. - Description comment explaining what the sample demonstrates
- Using statements
- Main code logic
- Helper methods at bottom
Configuration via environment variables (never hardcode secrets). Keep samples simple and focused.
When adding a new sample:
- Create a standalone project in
samples/with matching directory and project names - Include a README.md explaining what the sample does and how to run it
- Add the project to the solution file
- Reference the sample in the parent directory's README.md