Skip to content

.NET: Add Salesforce Agentforce agent provider#4080

Open
akshaykokane wants to merge 2 commits intomicrosoft:mainfrom
akshaykokane:main
Open

.NET: Add Salesforce Agentforce agent provider#4080
akshaykokane wants to merge 2 commits intomicrosoft:mainfrom
akshaykokane:main

Conversation

@akshaykokane
Copy link

@akshaykokane akshaykokane commented Feb 19, 2026

Introduce a new Microsoft.Agents.AI.Agentforce package that enables developers to integrate Salesforce Agentforce (Einstein AI Agent) as a fully orchestratable agent within the Microsoft Agent Framework.

Motivation and Context

Salesforce Agentforce is a widely adopted enterprise AI platform that allows organisations to build and deploy autonomous agents within the Salesforce ecosystem. Many enterprise customers operate in hybrid environments where Salesforce handles CRM, service, and sales workflows while other systems — powered by Azure, OpenAI, Anthropic, etc. — handle complementary AI workloads.

Today there is no straightforward way to include a Salesforce Agentforce agent in a multi-agent orchestration built with the Microsoft Agent Framework. Developers must write custom HTTP plumbing, manage OAuth token lifecycles, and manually translate between the Agentforce REST API and the framework's AIAgent abstraction.

By adding a dedicated provider, we:

  1. Lower the barrier to entry — a few lines of configuration and the agent is ready.
  2. Enable cross-platform orchestration — Agentforce agents can be composed alongside OpenAI, Anthropic, Copilot Studio, and other providers in workflows, A2A scenarios, and multi-agent patterns.
  3. Provide a consistent developer experience — the same RunAsync / RunStreamingAsync API surface that works for every other provider also works for Agentforce.

Description

The implementation follows Pattern A (direct AIAgent subclass), matching the approach used by the Copilot Studio provider. This is appropriate because Agentforce exposes its own proprietary REST API rather than an OpenAI-compatible chat completions endpoint.

Components

Class Responsibility
AgentforceConfig Immutable configuration (domain host, OAuth credentials, agent ID)
AgentforceClient Low-level HTTP client: OAuth token management, session CRUD, send message
AgentforceAgent AIAgent subclass: session lifecycle, message orchestration, response mapping
AgentforceAgentSession AgentSession subclass: holds the Salesforce session ID
AgentforceApiException Typed exception with HTTP status code and Salesforce error code
AgentforceJsonUtilities Source-generated JsonSerializerContext for AOT-safe serialization

Architecture

┌─────────────┐       ┌──────────────────┐       ┌──────────────────────────┐
│  Your App   │──────▶│  AgentforceAgent  │──────▶│  Salesforce Agentforce   │
│             │◀──────│  (AIAgent)        │◀──────│  REST API                │
└─────────────┘       └──────────────────┘       └──────────────────────────┘
                              │
                              ▼
                      ┌──────────────────┐
                      │ AgentforceClient  │
                      │ • OAuth 2.0 token │
                      │ • Session mgmt    │
                      │ • Send message    │
                      └──────────────────┘

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Introduce a new Agentforce provider: adds a Microsoft.Agents.AI.Agentforce project implementing AgentforceAgent, AgentforceClient, AgentforceConfig, AgentforceAgentSession, API models, JSON utilities, and an AgentforceApiException. The client handles OAuth token requests, token caching/refresh, session lifecycle (create/send/end) and basic streaming support; the agent adapts API messages into AIAgent/ChatMessage responses and supports session serialization. Also add a sample (Agent_With_Agentforce) with README demonstrating environment variables and usage, unit tests for agent/session/client behaviors, and register the new project and tests in the solution.
Copilot AI review requested due to automatic review settings February 19, 2026 12:23
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Feb 19, 2026
@github-actions github-actions bot changed the title Add Salesforce Agentforce agent provider .NET: Add Salesforce Agentforce agent provider Feb 19, 2026
@akshaykokane
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

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 pull request adds a new Microsoft.Agents.AI.Agentforce package that enables integration with Salesforce Agentforce (Einstein AI Agent) within the Microsoft Agent Framework. The implementation follows Pattern A (direct AIAgent subclass) similar to the Copilot Studio provider, which is appropriate since Agentforce exposes a proprietary REST API rather than an OpenAI-compatible endpoint.

Changes:

  • Introduces a new agent provider package for Salesforce Agentforce with OAuth 2.0 client-credentials authentication
  • Implements core classes: AgentforceConfig, AgentforceClient, AgentforceAgent, AgentforceAgentSession, and AgentforceApiException
  • Provides unit tests for all major components and a sample application demonstrating usage

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dotnet/src/Microsoft.Agents.AI.Agentforce/Microsoft.Agents.AI.Agentforce.csproj Project configuration following framework conventions with preview versioning
dotnet/src/Microsoft.Agents.AI.Agentforce/AgentforceConfig.cs Immutable configuration class for Salesforce credentials and agent identity
dotnet/src/Microsoft.Agents.AI.Agentforce/AgentforceClient.cs HTTP client handling OAuth token management, session lifecycle, and API calls
dotnet/src/Microsoft.Agents.AI.Agentforce/AgentforceAgent.cs Main agent implementation extending AIAgent with IDisposable for resource management
dotnet/src/Microsoft.Agents.AI.Agentforce/AgentforceAgentSession.cs Session state management with serialization support
dotnet/src/Microsoft.Agents.AI.Agentforce/AgentforceApiException.cs Typed exception for Agentforce API errors with status code and error code
dotnet/src/Microsoft.Agents.AI.Agentforce/AgentforceJsonUtilities.cs Source-generated JSON serialization context for AOT compatibility
dotnet/tests/Microsoft.Agents.AI.Agentforce.UnitTests/*.cs Comprehensive unit tests covering constructors, validation, and basic functionality
dotnet/samples/GettingStarted/AgentProviders/Agent_With_Agentforce/* Sample application with README demonstrating Agentforce integration
dotnet/agent-framework-dotnet.slnx Solution file updated to include new projects

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments