From bb0dc6aa8978e4a203002dbfdd725a737a8dc393 Mon Sep 17 00:00:00 2001 From: prajapatiy9826 Date: Mon, 6 Apr 2026 21:50:54 +0530 Subject: [PATCH 1/2] fix: update package dependencies and clean up unused variables in agent logic --- nodejs/perplexity/sample-agent/package.json | 8 +++--- nodejs/perplexity/sample-agent/src/agent.ts | 29 +++++++++++++-------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/nodejs/perplexity/sample-agent/package.json b/nodejs/perplexity/sample-agent/package.json index a99e253a..7e54ae02 100644 --- a/nodejs/perplexity/sample-agent/package.json +++ b/nodejs/perplexity/sample-agent/package.json @@ -31,15 +31,15 @@ "express": "^5.1.0", "mammoth": "^1.11.0", "pdf-parse": "^2.4.5", + "@types/express": "^4.17.21", + "@types/node": "^20.14.9", + "typescript": "^5.9.2", "zod": "^3.23.8" }, "devDependencies": { "@microsoft/m365agentsplayground": "^0.2.18", - "@types/express": "^4.17.21", - "@types/node": "^20.14.9", "nodemon": "^3.1.10", "rimraf": "^5.0.0", - "ts-node": "^10.9.2", - "typescript": "^5.9.2" + "ts-node": "^10.9.2" } } diff --git a/nodejs/perplexity/sample-agent/src/agent.ts b/nodejs/perplexity/sample-agent/src/agent.ts index 05ac3498..540242ab 100644 --- a/nodejs/perplexity/sample-agent/src/agent.ts +++ b/nodejs/perplexity/sample-agent/src/agent.ts @@ -98,7 +98,6 @@ console.log(" - CLUSTER_CATEGORY:", process.env["CLUSTER_CATEGORY"]); async function queryModel( userInput: string, agentDetails: AgentDetails, - tenantDetails: TenantDetails, client: PerplexityClient, systemPrompt: string, ) { @@ -109,13 +108,12 @@ async function queryModel( inputTokens: Math.ceil(userInput.length / 4), // Rough estimate outputTokens: 0, // Will be updated after response finishReasons: [], - responseId: `inference-${Date.now()}`, }; const inferenceScope = InferenceScope.start( + { content: userInput }, inferenceDetails, agentDetails, - tenantDetails, ); try { @@ -232,13 +230,12 @@ app.onActivity(ActivityTypes.Message, async (context) => { const baggageScope = new BaggageBuilder() .tenantId(tenantId) .agentId(agentId) - .correlationId(activityId || `corr-${Date.now()}`) .agentName(agentName) .agentDescription( "AI answer engine for research, writing, and task assistance using live web search and citations", ) - .callerId(userId) - .callerName(userName) + .userId(userId) + .userName(userName) .conversationId(conversationId) .operationSource("sdk") .build(); @@ -247,6 +244,7 @@ app.onActivity(ActivityTypes.Message, async (context) => { const agentDetails = { agentId: agentId, agentName: agentName, + tenantId: tenantId, agentDescription: "AI answer engine for research, writing, and task assistance using live web search and citations", botId: activity.recipient?.id, @@ -334,10 +332,20 @@ app.onActivity(ActivityTypes.Message, async (context) => { await baggageScope.run(async () => { // Start agent invocation scope const agentScope = InvokeAgentScope.start( - invokeDetails, - tenantDetails, - undefined, // No caller agent (human-to-agent interaction) - callerDetails, + { + content: userMessage, + sessionId: sessionId, + conversationId: conversationId, + }, + { endpoint: invokeDetails.endpoint }, + agentDetails, + { + userDetails: { + userId: userId, + userName: userName, + tenantId: tenantId, + }, + }, ); try { @@ -382,7 +390,6 @@ app.onActivity(ActivityTypes.Message, async (context) => { let modelResponse = await queryModel( userMessage, agentDetails, - tenantDetails, perplexityClient, systemPrompt, ); From 4c5a47827a0a64bbaca4bab59b68f77054f8b121 Mon Sep 17 00:00:00 2001 From: Yogeshp-MSFT Date: Fri, 24 Apr 2026 14:51:39 +0530 Subject: [PATCH 2/2] Clean up formatting in agent.ts Remove unnecessary newline before the JSDoc comment. --- nodejs/perplexity/sample-agent/src/agent.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/nodejs/perplexity/sample-agent/src/agent.ts b/nodejs/perplexity/sample-agent/src/agent.ts index 540242ab..620e54e6 100644 --- a/nodejs/perplexity/sample-agent/src/agent.ts +++ b/nodejs/perplexity/sample-agent/src/agent.ts @@ -23,7 +23,6 @@ import { PerplexityClient } from "./perplexityClient"; // Load environment variables from .env file FIRST config(); - /** * Create a cache key for the agentic token */