Skip to content

feat: Add Node.js/TypeScript Semantic Kernel sample agent#281

Open
Akshit0022 wants to merge 5 commits intomicrosoft:mainfrom
Akshit0022:feat/nodejs-semantic-kernel-sample
Open

feat: Add Node.js/TypeScript Semantic Kernel sample agent#281
Akshit0022 wants to merge 5 commits intomicrosoft:mainfrom
Akshit0022:feat/nodejs-semantic-kernel-sample

Conversation

@Akshit0022
Copy link
Copy Markdown

@Akshit0022 Akshit0022 commented Apr 22, 2026

Adds a new Node.js/TypeScript sample demonstrating how to build a production-ready Microsoft 365 agent using OpenAI function calling (Semantic Kernel-style patterns) with the Microsoft Agent 365 SDK.
This is the Node.js/TypeScript counterpart to the existing .NET Semantic Kernel sample (dotnet/semantic-kernel/) and the Python Semantic Kernel sample (python/semantic-kernel/).

What's included

New directory: nodejs/semantic-kernel/sample-agent/

File Description
src/index.ts Express server entry point with /api/messages endpoint and auth middleware
src/agent.ts Core agent implementation using AgentApplication with message routing, notifications, install/uninstall handling
src/client.ts SemanticKernelClient with OpenAI Chat Completions function-calling loop, MCP tool integration, and A365 observability scopes
src/openai-config.ts Azure OpenAI / standard OpenAI client factory with dual provider support
src/plugins.ts Terms & conditions accept/reject plugins as OpenAI function calling tools
src/token-cache.ts In-memory token caching singleton for agentic auth flows
ToolingManifest.json MCP server manifest (fallback for SDK discovery)
.env.template Environment variable reference
package.json Project configuration with all dependencies
tsconfig.json TypeScript compiler configuration
appManifest/manifest.json Teams/M365 app manifest with proper placeholders
appManifest/color.png App icon (192×192)
appManifest/outline.png App icon (32×32)
docs/design.md Architecture and design documentation
README.md Full documentation with Quick Start, architecture, troubleshooting
.gitignore Exclusions for build artifacts, secrets, and generated configs

Features

  • Dual LLM support — Azure OpenAI or OpenAI via API key, configurable via environment variables (AZURE_OPENAI_API_KEY / OPENAI_API_KEY)
  • MCP tool integration — Auto-discovered tools via SDK with ToolingManifest.json fallback; uses @openai/agents for MCP server connections with SSE transport
  • Agentic authentication — Token exchange for Graph API, MCP servers, and observability; Playground mode with USE_AGENTIC_AUTH=false (bearer token fallback)
  • Full observability — Nested InvokeAgentScopeInferenceScopeExecuteToolScope with BaggageScope context propagation
  • Notification handling — Email and Word comment notification processing via @microsoft/agents-a365-notifications
  • Conversation continuity — Per-conversation ChatHistory maintained across turns
  • Multiple messages + typing indicators — Immediate acknowledgment, background typing loop, final response
  • Install/Uninstall events — Welcome and farewell messages on agent hire/fire
  • Terms & Conditions — Built-in accept/reject plugin demonstrating local function calling
  • Proper resource cleanup — MCP connections closed on agent shutdown
  • Generic host pattern — Express 5 server with CloudAdapter, compatible with Agents Playground, matching the pattern used by other Node.js samples

Dependencies

  • openai ^4.77.0
  • @openai/agents ^0.1.11
  • express ^5.1.0
  • @microsoft/agents-hosting ^1.2.2
  • @microsoft/agents-activity ^1.2.2
  • @microsoft/agents-a365-observability ^0.1.0-preview.125
  • @microsoft/agents-a365-tooling-extensions-openai ^0.1.0-preview.125
  • @microsoft/agents-a365-notifications ^0.1.0-preview.125
  • @microsoft/agents-a365-runtime ^0.1.0-preview.125

Full list in package.json.

Testing

  • Verified with Agents Playground (Playground mode, USE_AGENTIC_AUTH=false with bearer token)
  • Tested MCP tool invocation (mail sent via mcp_MailTools)
  • Tested both OpenAI and Azure OpenAI LLM paths with gpt-4o
  • Observability spans visible in console output
  • Deployed and tested on Azure Web App

Related samples

This follows the same architecture and conventions as:

  • nodejs/claude/sample-agent/
  • nodejs/openai/sample-agent/
  • dotnet/semantic-kernel/sample-agent/ (the .NET equivalent)
  • python/semantic-kernel/sample-agent/ (the Python equivalent)

Adds a new Node.js/TypeScript sample under nodejs/semantic-kernel/sample-agent/
demonstrating the Microsoft Agent 365 SDK with OpenAI function calling
(Semantic Kernel-style patterns).

Features:
- Dual LLM support (Azure OpenAI / OpenAI)
- MCP tool integration with @openai/agents SSE transport
- Full A365 observability (InvokeAgent, Inference, ExecuteTool scopes)
- Agentic authentication with token exchange
- Notification handling (email, Word comments)
- Conversation continuity with per-conversation chat history
- Install/uninstall event handling
- Express 5 server with CloudAdapter
Copilot AI review requested due to automatic review settings April 22, 2026 15:27
@Akshit0022 Akshit0022 requested a review from a team as a code owner April 22, 2026 15:27
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 Node.js/TypeScript “Semantic Kernel-style” sample agent under nodejs/semantic-kernel/sample-agent/, mirroring the existing .NET/Python semantic-kernel samples and the existing Node.js OpenAI/Claude samples. The sample demonstrates OpenAI Chat Completions tool-calling (local plugins + MCP tools), Agent 365 notifications, and A365 observability wiring.

Changes:

  • Introduces a new Express-based agent host with /api/messages and JWT auth middleware.
  • Implements a Semantic Kernel-style function-calling loop (local plugins) plus MCP tool registration/execution.
  • Adds full sample documentation, manifests, env template, and basic token caching for observability export.

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
nodejs/semantic-kernel/sample-agent/tsconfig.json TypeScript build configuration for the sample
nodejs/semantic-kernel/sample-agent/package.json Sample dependencies and scripts
nodejs/semantic-kernel/sample-agent/src/index.ts Express server entry point and routing/auth middleware
nodejs/semantic-kernel/sample-agent/src/agent.ts AgentApplication implementation (messages, notifications, install/uninstall, observability token preload)
nodejs/semantic-kernel/sample-agent/src/client.ts Core “Semantic Kernel-style” client with tool loop + MCP integration + observability scope
nodejs/semantic-kernel/sample-agent/src/openai-config.ts OpenAI/Azure OpenAI client selection and @openai/agents Azure configuration
nodejs/semantic-kernel/sample-agent/src/plugins.ts Local plugin tools (terms & conditions accept/reject flow)
nodejs/semantic-kernel/sample-agent/src/token-cache.ts In-memory token cache + custom observability token resolver
nodejs/semantic-kernel/sample-agent/ToolingManifest.json MCP server manifest fallback for tooling discovery
nodejs/semantic-kernel/sample-agent/.env.template Environment variable template for auth, tooling, and LLM config
nodejs/semantic-kernel/sample-agent/.gitignore Ignores build output and secret/config files
nodejs/semantic-kernel/sample-agent/appManifest/manifest.json Teams/M365 app manifest for the sample
nodejs/semantic-kernel/sample-agent/appManifest/color.png Teams app icon (color)
nodejs/semantic-kernel/sample-agent/appManifest/outline.png Teams app icon (outline)
nodejs/semantic-kernel/sample-agent/docs/design.md Architecture/design notes for the sample
nodejs/semantic-kernel/sample-agent/README.md End-to-end sample documentation (setup, run, troubleshooting)

Comment thread nodejs/semantic-kernel/sample-agent/README.md Outdated
Comment thread nodejs/semantic-kernel/sample-agent/README.md Outdated
Comment thread nodejs/semantic-kernel/sample-agent/src/client.ts
Comment thread nodejs/semantic-kernel/sample-agent/package.json Outdated
Comment thread nodejs/semantic-kernel/sample-agent/src/openai-config.ts
Comment thread nodejs/semantic-kernel/sample-agent/src/client.ts
Comment thread nodejs/semantic-kernel/sample-agent/src/agent.ts
Comment thread nodejs/semantic-kernel/sample-agent/README.md Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Akshit0022
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

Akshit0022 and others added 3 commits April 23, 2026 10:27
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>
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