Skip to content

Fix: Observability SDK API compatibility + Azure App Service deployment#267

Open
Yogeshp-MSFT wants to merge 2 commits intomicrosoft:mainfrom
Yogeshp-MSFT:Perplexity-sample
Open

Fix: Observability SDK API compatibility + Azure App Service deployment#267
Yogeshp-MSFT wants to merge 2 commits intomicrosoft:mainfrom
Yogeshp-MSFT:Perplexity-sample

Conversation

@Yogeshp-MSFT
Copy link
Copy Markdown

Summary

This PR fixes TypeScript compilation errors caused by a breaking API change in @microsoft/agents-a365-observability, resolves a runtime crash in production due to missing tenantId, and fixes Azure App Service deployment failures.


src/agent.ts

1. InferenceScope.start — updated to new API signature (line ~116)

  • Before: InferenceScope.start(inferenceDetails, agentDetails, tenantDetails) — first arg was InferenceDetails
  • After: InferenceScope.start({ content: userInput }, inferenceDetails, agentDetails) — first arg is now a Request object
  • Also removed: responseId field from inferenceDetails (no longer part of InferenceDetails type)

2. queryModel function signature — removed tenantDetails param (line ~100)

  • Before: queryModel(userInput, agentDetails, tenantDetails, client, systemPrompt)
  • After: queryModel(userInput, agentDetails, client, systemPrompt)
  • TenantDetails is no longer passed to InferenceScope.start, so it was removed from the function

3. BaggageBuilder chain — removed non-existent methods (line ~232)

  • Removed: .correlationId(activityId) — method does not exist on BaggageBuilder
  • Renamed: .callerId(userId).userId(userId) — method was renamed in the SDK
  • Renamed: .callerName(userName).userName(userName) — method was renamed in the SDK

4. InvokeAgentScope.start — updated to new API signature (line ~336)

  • Before: InvokeAgentScope.start(invokeDetails, tenantDetails, undefined, callerDetails) — old 4-arg signature
  • After: InvokeAgentScope.start(request, invokeScopeDetails, agentDetails, callerDetails) where:
    • request: { content, sessionId, conversationId }
    • invokeScopeDetails: { endpoint: invokeDetails.endpoint }
    • callerDetails: { userDetails: { userId, userName, tenantId } } — uses new CallerDetails wrapper type

5. agentDetails — added missing tenantId field (line ~247)

  • Before: agentDetails object had no tenantId
  • After: tenantId: tenantId added to agentDetails
  • Impact: Without this, InvokeAgentScope.start threw at runtime in production (observability enabled), causing the agent to reply "Sorry, something went wrong with the observability context." for every message. Worked locally only because ENABLE_A365_OBSERVABILITY=false in .env silently bypassed validation.

package.json

6. Moved typescript, @types/express, @types/node from devDependenciesdependencies

  • Why: Azure App Service runs npm install with NODE_ENV=production, which skips devDependencies. Without typescript and the @types packages, tsc fails during the Oryx build step, causing Deployment Failed.

@Yogeshp-MSFT Yogeshp-MSFT requested a review from a team as a code owner April 6, 2026 16:26
Copilot AI review requested due to automatic review settings April 6, 2026 16:26
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

Updates the Perplexity Node.js sample agent to match the latest @microsoft/agents-a365-observability APIs, prevent a production crash related to missing tenantId, and ensure Azure App Service deployments can build TypeScript successfully.

Changes:

  • Updated InferenceScope.start and InvokeAgentScope.start calls to align with the new Observability SDK signatures and types.
  • Adjusted baggage/user fields to match renamed/removed BaggageBuilder APIs and ensured agentDetails.tenantId is populated.
  • Moved typescript and relevant @types/* packages into dependencies to avoid Oryx build failures when NODE_ENV=production.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
nodejs/perplexity/sample-agent/src/agent.ts Aligns observability scope creation with updated SDK APIs and ensures required tenantId is present to prevent runtime crashes.
nodejs/perplexity/sample-agent/package.json Ensures Azure App Service/Oryx can run tsc by installing TypeScript and type packages during production installs.

@Yogeshp-MSFT Yogeshp-MSFT force-pushed the Perplexity-sample branch 2 times, most recently from c6afd82 to 36e3325 Compare April 15, 2026 06:48
@Yogeshp-MSFT
Copy link
Copy Markdown
Author

HI @gwharris7 can you review this pr?

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