.NET: Add Salesforce Agentforce agent provider#4080
Open
akshaykokane wants to merge 2 commits intomicrosoft:mainfrom
Open
.NET: Add Salesforce Agentforce agent provider#4080akshaykokane wants to merge 2 commits intomicrosoft:mainfrom
akshaykokane wants to merge 2 commits intomicrosoft:mainfrom
Conversation
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.
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
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, andAgentforceApiException - 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a new
Microsoft.Agents.AI.Agentforcepackage 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
AIAgentabstraction.By adding a dedicated provider, we:
RunAsync/RunStreamingAsyncAPI surface that works for every other provider also works for Agentforce.Description
The implementation follows Pattern A (direct
AIAgentsubclass), 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
AgentforceConfigAgentforceClientAgentforceAgentAIAgentsubclass: session lifecycle, message orchestration, response mappingAgentforceAgentSessionAgentSessionsubclass: holds the Salesforce session IDAgentforceApiExceptionAgentforceJsonUtilitiesJsonSerializerContextfor AOT-safe serializationArchitecture
Contribution Checklist