Fix Devin sample agent: observability v2 migration, runtime crashes, and deployment issues#264
Open
Yogeshp-MSFT wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix Devin sample agent: observability v2 migration, runtime crashes, and deployment issues#264Yogeshp-MSFT wants to merge 1 commit intomicrosoft:mainfrom
Yogeshp-MSFT wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the nodejs/devin/sample-agent to work with @microsoft/agents-a365-observability v2 API changes, while addressing deployment/runtime issues discovered during App Service deployment.
Changes:
- Migrates observability scope initialization in
src/agent.tsto the v2Request/InvokeAgentScopeDetails-based signatures and adjusts inference tracking. - Fixes Devin polling to return after the first emitted reply and avoids turn-context proxy revocation by deferring
sendActivityuntil afterinvokeAgentcompletes. - Updates build/runtime configuration (TypeScript excludes, start script) and adds missing type dependencies.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| nodejs/devin/sample-agent/src/agent.ts | Updates observability v2 scope APIs and changes streaming handling to avoid revoked-proxy crashes. |
| nodejs/devin/sample-agent/src/utils.ts | Updates helper return types to match v2 AgentDetails shape. |
| nodejs/devin/sample-agent/src/index.ts | Tightens error handler typing for strict TS. |
| nodejs/devin/sample-agent/src/devin-client.ts | Breaks polling loop after first Devin reply; fixes debug output. |
| nodejs/devin/sample-agent/package.json | Removes --env-file from start; adds @types/express. |
| nodejs/devin/sample-agent/tsconfig.json | Excludes publish/, dist/, node_modules/ from compilation. |
73e13d1 to
e3d79eb
Compare
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.
Summary
Updates the
nodejs/devin/sample-agentto compile and run correctly against@microsoft/agents-a365-observabilityv2 breaking API changes, fixes multiple runtime crashes discovered during App Service deployment, and addresses code quality issues.Changes
src/agent.ts
InvokeAgentScopeDetails(L11),Request(L13)Reason: v2 SDK renamed/removed these types;
InvokeAgentScope.start()now requiresInvokeAgentScopeDetailsandRequestinstead of the old positional args..correlationId(uuidv4())fromBaggageBuilderchainReason:
.correlationId()method was removed in the v2 SDK.Requestobject withconversationId,sessionId,contentReason: v2 SDK requires a
Requestobject as the first argument to scope.start()methods;conversationIdmoved here fromAgentDetails.InvokeAgentScopeDetailstyped variableReason: v2 SDK requires this as the second argument to
InvokeAgentScope.start().InvokeAgentScope.start()to new 3-arg signature withtenantIdmerged intoagentDetailsReason: v2 SDK changed the signature from
(agentDetails, tenantDetails)to(request, scopeDetails, agentDetails)and movedtenantIdontoAgentDetails.inferenceScopedeclaration with definite assignment assertion (let inferenceScope!:) beforetryReason: Allows
finallyblock to callinferenceScope?.dispose()even when an exception is thrown insidetry.responseIdfield fromInferenceDetailsReason:
responseIdwas moved toInferenceResponsein v2 and is no longer accepted onInferenceDetails.InferenceScope.start()to new 3-arg signatureReason: v2 SDK changed the signature from
(inferenceDetails, agentDetails, tenantDetails)to(conversationId, inferenceDetails, agentDetails).data/error/closehandlers synchronous; chunks collected into an arrayReason:
Stream.emit()is synchronous — async handlers' returned promises are silently discarded. CallingturnContext.sendActivity()inside an async handler raced against turn-context proxy revocation, causing "Cannot perform 'set' on a proxy that has been revoked" crashes.sendActivityafterinvokeAgentresolvesReason: The turn context is still valid at this point; sending here avoids the revoked-proxy crash.
catchblock callsstopTypingLoop()before sending error messageReason: Ensures the typing indicator stops even on error paths.
finallyblock callsinferenceScope?.dispose()Reason: Previously
dispose()was only called on the happy path; an exception would leak the scope.src/utils.ts
InvokeAgentDetailsandExecutionTypeimport withAgentDetailsReason:
InvokeAgentDetailstype was removed in v2;AgentDetailsis the replacement.getAgentDetails()return type changed toAgentDetailsReason: Matches the new v2 type.
conversationIdandrequestfields from return valueReason: These fields moved to the
Requestinterface in v2 and are no longer part ofAgentDetails.src/index.ts
Errortype annotation toerrparameterReason: TypeScript strict mode requires an explicit type; without it the implicit
anycaused a compilation error.src/devin-client.ts
breakafter emitting adevin_messageeventReason:
DevinSessionStatusonly includesnew/claimed/running; Devin stays inrunningafter replying, so without thebreakthe poll loop ran until the 5-minute timeout, and the agent never returned a response.package.json
startscript fromnode --env-file=.env dist/index.jstonode dist/index.jsReason: App Service doesn't have a
.envfile — env vars come from Application Settings.--env-file=.envcrashed on startup with "file not found".@types/expresstodevDependenciesReason: Missing type definitions caused TypeScript compilation errors for Express types.
tsconfig.json
"exclude": ["publish", "dist", "node_modules"]Reason: Without this,
tsctried to compile.tsfiles (or.jsonwithresolveJsonModule) insidepublish/anddist/, causing duplicate identifier and type errors.Testing
npm run buildpasses with zero errorssendActivitycall afterinvokeAgentresolves