Skip to content

Add Perplexity AI Sample Agent (.NET)#277

Open
Yogeshp-MSFT wants to merge 14 commits intomicrosoft:mainfrom
Yogeshp-MSFT:Dotnet-Perplexity-Sample
Open

Add Perplexity AI Sample Agent (.NET)#277
Yogeshp-MSFT wants to merge 14 commits intomicrosoft:mainfrom
Yogeshp-MSFT:Dotnet-Perplexity-Sample

Conversation

@Yogeshp-MSFT
Copy link
Copy Markdown

New .NET sample demonstrating Perplexity AI as the LLM provider with the Microsoft Agents SDK. Features live web search via Perplexity's Sonar models and MCP tools for Mail and Calendar.

New directory: dotnet/perplexity/sample-agent/

Key Capabilities

  • Perplexity Responses API — Direct HttpClient integration
  • Custom MCP client — Lightweight JSON-RPC over Streamable HTTP (McpSession.cs)
  • MCP tool discovery — Via A365 Tooling SDK with ToolingManifest.json fallback
  • A365 observability — OpenTelemetry + A365 tracing exporter
  • Prompt-injection defenses — System prompt treats all user content as data, not commands

How It Differs from Existing Samples

Aspect Agent Framework / SK Samples Perplexity Sample
AI Backend Azure OpenAI Perplexity AI via HttpClient
Tool Integration Agent Framework / SK plugins Custom MCP via McpSession
Response Mode Streaming Request-response
Conversation Thread/history managed Stateless per-turn

Files

Core: Program.cs, Agent/MyAgent.cs, PerplexityClient.cs, McpSession.cs, McpToolService.cs, AspNetExtensions.cs
Telemetry: telemetry/AgentMetrics.cs, AgentOTELExtensions.cs, A365OtelWrapper.cs
Config: appsettings.json, appsettings.Development.json, appsettings.Playground.json, ToolingManifest.json
Docs: README.md, docs/design.md
Deployment: appPackage/manifest.json, PerplexitySampleAgent.sln, .csproj

Checklist

  • No secrets in committed files (placeholder credentials only)
  • a365.config.json / a365.generated.config.json in .gitignore
  • README with setup instructions
  • Design doc with architecture overview
  • Teams manifest with parameterized IDs
  • OpenTelemetry + A365 observability
  • MIT license headers on all source files

@Yogeshp-MSFT Yogeshp-MSFT requested a review from a team as a code owner April 20, 2026 06:25
Copilot AI review requested due to automatic review settings April 20, 2026 06:25
Copy link
Copy Markdown
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

Adds a new .NET Perplexity AI sample agent under dotnet/perplexity/sample-agent/, showing Perplexity (Responses API) as the LLM provider, custom MCP-based Mail/Calendar tool invocation, and OpenTelemetry/A365 observability wiring.

Changes:

  • Introduces a Perplexity Responses API client (PerplexityClient) with a multi-turn tool-call loop.
  • Adds a lightweight MCP JSON-RPC client (McpSession) plus a tool discovery/execution service (McpToolService).
  • Adds sample app startup, configuration, Teams app package assets, and documentation (README + design doc).

Reviewed changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 32 comments.

Show a summary per file
File Description
dotnet/perplexity/sample-agent/Program.cs ASP.NET Core startup wiring for agent, telemetry, auth, MCP tools, and message endpoint.
dotnet/perplexity/sample-agent/Agent/MyAgent.cs Main agent implementation: prompt, tool loading, typing/streaming response behavior.
dotnet/perplexity/sample-agent/PerplexityClient.cs Perplexity Responses API integration and tool-call loop logic.
dotnet/perplexity/sample-agent/McpSession.cs Minimal MCP JSON-RPC over HTTP (incl. SSE parsing).
dotnet/perplexity/sample-agent/McpToolService.cs MCP server discovery + tool schema sanitization + tool executor dispatch.
dotnet/perplexity/sample-agent/telemetry/AgentOTELExtensions.cs OpenTelemetry setup (resources, tracing, metrics, exporters, health/resilience defaults).
dotnet/perplexity/sample-agent/telemetry/AgentMetrics.cs Custom ActivitySource + Meter instruments and wrapper helpers.
dotnet/perplexity/sample-agent/telemetry/A365OtelWrapper.cs A365 observability baggage/token-cache wrapper around agent execution.
dotnet/perplexity/sample-agent/AspNetExtensions.cs JWT token validation / auth setup helpers for the sample.
dotnet/perplexity/sample-agent/PerplexitySampleAgent.csproj Sample project dependencies (A365 SDK packages + OTEL + resilience).
dotnet/perplexity/sample-agent/appsettings.json Base configuration template for auth + Perplexity settings.
dotnet/perplexity/sample-agent/appsettings.Development.json Dev overrides (token validation disabled, placeholder secrets).
dotnet/perplexity/sample-agent/appsettings.Playground.json Playground overrides (token validation disabled, placeholder secrets).
dotnet/perplexity/sample-agent/ToolingManifest.json MCP server fallback manifest for Mail + Calendar tools.
dotnet/perplexity/sample-agent/README.md Setup/run documentation and sample overview.
dotnet/perplexity/sample-agent/docs/design.md Architecture/design notes for the sample.
dotnet/perplexity/sample-agent/appPackage/manifest.json Teams app manifest template for the sample agent.
dotnet/perplexity/sample-agent/appPackage/color.png Teams app icon (color).
dotnet/perplexity/sample-agent/appPackage/outline.png Teams app icon (outline).
dotnet/perplexity/sample-agent/.gitignore Sample-local ignores (build outputs + A365 generated config).
dotnet/perplexity/PerplexitySampleAgent.sln Solution file referencing the sample project.

Comment thread dotnet/perplexity/sample-agent/docs/design.md Outdated
Comment thread dotnet/perplexity/sample-agent/Program.cs Outdated
Comment thread dotnet/perplexity/sample-agent/Agent/MyAgent.cs Outdated
Comment thread dotnet/perplexity/sample-agent/Program.cs
Comment thread dotnet/perplexity/sample-agent/telemetry/AgentMetrics.cs
Comment thread dotnet/perplexity/sample-agent/Program.cs
Comment thread dotnet/perplexity/sample-agent/telemetry/AgentMetrics.cs Outdated
Comment thread dotnet/perplexity/sample-agent/telemetry/AgentOTELExtensions.cs Outdated
Comment thread dotnet/perplexity/sample-agent/telemetry/AgentOTELExtensions.cs
Comment thread dotnet/perplexity/sample-agent/AspNetExtensions.cs Outdated
Copy link
Copy Markdown
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

Copilot reviewed 19 out of 21 changed files in this pull request and generated 9 comments.

Comment thread dotnet/perplexity/sample-agent/McpSession.cs
Comment thread dotnet/perplexity/sample-agent/Program.cs
Comment thread dotnet/perplexity/sample-agent/Program.cs
Comment thread dotnet/perplexity/sample-agent/docs/design.md Outdated
Comment thread dotnet/perplexity/sample-agent/McpSession.cs
Comment thread dotnet/perplexity/sample-agent/McpToolService.cs
Comment thread dotnet/perplexity/sample-agent/Program.cs
Comment thread dotnet/perplexity/sample-agent/AspNetExtensions.cs
Comment thread dotnet/perplexity/sample-agent/McpSession.cs
@Yogeshp-MSFT
Copy link
Copy Markdown
Author

hi @ajmfehr can you review this pr?

Yogeshp-MSFT and others added 14 commits April 29, 2026 16:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Yogeshp-MSFT Yogeshp-MSFT force-pushed the Dotnet-Perplexity-Sample branch from 7ae10e2 to 85eee60 Compare April 29, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants