Skip to content

Conversation

@manekinekko
Copy link
Contributor

No description provided.

Copy link
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

This PR updates the LangChain.js integration to improve compatibility with newer versions of LangChain packages and the DeepAgents library. The changes include dependency version upgrades, refactoring of agent structures, updates to the event streaming API, improved error handling in the UI, and configuration adjustments for Azure OpenAI authentication.

  • Upgraded key dependencies including @langchain/core, @langchain/mcp-adapters, deepagents, and langchain to newer versions
  • Refactored agent configuration to use new DeepAgents API structure with direct properties instead of wrapped runnables
  • Updated event streaming API from v1 to v2 with destructured event handling
  • Added server error handling in the Angular UI service

Reviewed changes

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

Show a summary per file
File Description
packages/ui-angular/src/app/services/api.service.ts Added error handling for server errors in streaming responses
packages/mcp-servers/echo-ping/src/server.ts Reordered imports to follow standard convention (external imports before internal) and added whitespace for readability
packages/api-langchain-js/src/tools/mcp-bridge.ts Changed import to use type-only import for DynamicStructuredTool
packages/api-langchain-js/src/tools/index.ts Simplified auth configuration by replacing requestInit headers with direct accessToken property
packages/api-langchain-js/src/server.ts Removed debug console.log statement for cleaner output
packages/api-langchain-js/src/providers/azure-openai.ts Added FORCE_AZURE_OPENAI_API_KEY environment variable support, changed default model fallback, and reordered configuration properties
packages/api-langchain-js/src/graph/index.ts Updated streamEvents API to v2 with destructured event parameters and simplified event property access
packages/api-langchain-js/src/agents/index.ts Refactored agent configuration to use DeepAgents SubAgent structure with direct model/tools/systemPrompt properties instead of runnable wrappers
packages/api-langchain-js/package.json Updated dependency versions, added FORCE_AZURE_OPENAI_API_KEY to start script, and removed unused langchain packages

"Authorization": "Bearer " + process.env["MCP_ECHO_PING_ACCESS_TOKEN"],
}
},
accessToken: process.env["MCP_ECHO_PING_ACCESS_TOKEN"],
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The authentication configuration has been changed from using 'requestInit.headers' with an Authorization header to using 'accessToken'. However, the 'mcp-bridge.ts' implementation still only extracts headers from 'requestInit.headers' (lines 16-19) and does not handle the new 'accessToken' field. This means the access token will not be sent with the requests, breaking authentication for the echo-ping service.

Suggested change
accessToken: process.env["MCP_ECHO_PING_ACCESS_TOKEN"],
requestInit: {
headers: {
Authorization: `Bearer ${process.env["MCP_ECHO_PING_ACCESS_TOKEN"]}`,
},
},

Copilot uses AI. Check for mistakes.
baseURL: process.env.AZURE_OPENAI_ENDPOINT,
},
modelName: process.env.AZURE_OPENAI_DEPLOYMENT_NAME ?? "gpt-5",
modelName: process.env.AZURE_OPENAI_DEPLOYMENT_NAME ?? "gpt-5-mini",
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default model name has been changed to "gpt-5-mini", but this model does not exist in Azure OpenAI. Valid GPT-4 model names include "gpt-4", "gpt-4-turbo", "gpt-4o", "gpt-4o-mini", or valid GPT-3.5 models like "gpt-35-turbo". The model name "gpt-5-mini" will cause runtime errors when Azure OpenAI API is called without a valid AZURE_OPENAI_DEPLOYMENT_NAME environment variable.

Copilot uses AI. Check for mistakes.
Comment on lines 42 to 50
const agent = {
name: "EchoAgent",
description: "Echo back the received input. Do not respond with anything else. Always call the tools.",
runnable: createAgent({
description:
"Echo back the received input. Do not respond with anything else. Always call the tools.",
model,
tools: echoTools,
systemPrompt: "You are an Echo Agent that echoes back the received input. Do not respond with anything else. Always call the tools.",
})
systemPrompt:
"You are an Echo Agent that echoes back the received input. Do not respond with anything else. Always call the tools.",
};
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent structure has been changed to remove the 'runnable' property and instead spread the model, tools, and systemPrompt properties directly on the agent object. However, this change is incompatible with the 'SubAgent' type from 'deepagents' which expects an object with 'name', 'description', and 'runnable' properties. The new structure directly includes 'model', 'tools', and 'systemPrompt' which may not match the expected interface. This could cause type errors or runtime failures when creating the deep agent.

Copilot uses AI. Check for mistakes.
Comment on lines 60 to 68
const agent = {
name: "CustomerQueryAgent",
description: "Assists employees in better understanding customer needs, facilitating more accurate and personalized service. This agent is particularly useful for handling nuanced queries, such as specific travel preferences or budget constraints, which are common in travel agency interactions.",
runnable: createAgent({
model,
name: "CustomerQueryAgent",
tools: customerTools,
systemPrompt: "You are a Customer Query Agent that assists employees in better understanding customer needs, facilitating more accurate and personalized service. This agent is particularly useful for handling nuanced queries, such as specific travel preferences or budget constraints, which are common in travel agency interactions.",
}),
description:
"Assists employees in better understanding customer needs, facilitating more accurate and personalized service. This agent is particularly useful for handling nuanced queries, such as specific travel preferences or budget constraints, which are common in travel agency interactions.",
model,
tools: customerTools,
systemPrompt:
"You are a Customer Query Agent that assists employees in better understanding customer needs, facilitating more accurate and personalized service. This agent is particularly useful for handling nuanced queries, such as specific travel preferences or budget constraints, which are common in travel agency interactions.",
};
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent structure has been changed to remove the 'runnable' property and instead spread the model, tools, and systemPrompt properties directly on the agent object. However, this change is incompatible with the 'SubAgent' type from 'deepagents' which expects an object with 'name', 'description', and 'runnable' properties. The new structure directly includes 'model', 'tools', and 'systemPrompt' which may not match the expected interface. This could cause type errors or runtime failures when creating the deep agent.

Copilot uses AI. Check for mistakes.
"types": "dist/index.d.ts",
"scripts": {
"start": "tsx --watch src/server.ts",
"start": "FORCE_AZURE_OPENAI_API_KEY=true tsx --watch src/server.ts",
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The start script sets FORCE_AZURE_OPENAI_API_KEY=true using Unix/Linux shell syntax, which will not work on Windows systems. This makes the project less portable. Consider using cross-platform tools like 'cross-env' (e.g., "cross-env FORCE_AZURE_OPENAI_API_KEY=true tsx --watch src/server.ts") to ensure the script works across all operating systems.

Copilot uses AI. Check for mistakes.
Comment on lines +204 to +210
if (parsedData.data.error) {
this.handleApiError(
"Server error: " + parsedData.data.error,
0
);
return null;
}
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling logic accesses 'parsedData.data.error' without first verifying that 'parsedData.data' exists. If parsedData.data is null or undefined, this will throw a TypeError. Consider adding a null/undefined check for parsedData.data before accessing its error property.

Copilot uses AI. Check for mistakes.
baseURL: process.env.AZURE_OPENAI_ENDPOINT,
},
modelName: process.env.AZURE_OPENAI_DEPLOYMENT_NAME ?? "gpt-5",
modelName: process.env.AZURE_OPENAI_DEPLOYMENT_NAME ?? "gpt-5-mini",
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default model name has been changed to "gpt-5-mini", but this model does not exist in Azure OpenAI. Valid GPT-4 model names include "gpt-4", "gpt-4-turbo", "gpt-4o", "gpt-4o-mini", or valid GPT-3.5 models like "gpt-35-turbo". The model name "gpt-5-mini" will cause runtime errors when Azure OpenAI API is called without a valid AZURE_OPENAI_DEPLOYMENT_NAME environment variable.

Copilot uses AI. Check for mistakes.
Comment on lines 78 to 86
const agent = {
name: "ItineraryPlanningAgent",
description: "Creates a travel itinerary based on user preferences and requirements.",
runnable: createAgent({
model,
tools: itineraryTools,
systemPrompt: "You are an Itinerary Planning Agent that creates travel itineraries based on user preferences and requirements.",
}),
description:
"Creates a travel itinerary based on user preferences and requirements.",
model,
tools: itineraryTools,
systemPrompt:
"You are an Itinerary Planning Agent that creates travel itineraries based on user preferences and requirements.",
};
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent structure has been changed to remove the 'runnable' property and instead spread the model, tools, and systemPrompt properties directly on the agent object. However, this change is incompatible with the 'SubAgent' type from 'deepagents' which expects an object with 'name', 'description', and 'runnable' properties. The new structure directly includes 'model', 'tools', and 'systemPrompt' which may not match the expected interface. This could cause type errors or runtime failures when creating the deep agent.

Copilot uses AI. Check for mistakes.
Comment on lines 96 to 104
const agent = {
name: "DestinationRecommendationAgent",
description: "Suggests destinations based on customer preferences and requirements.",
runnable: createAgent({
model,
tools: destinationTools,
systemPrompt: "You are a Destination Recommendation Agent that suggests destinations based on customer preferences and requirements.",
})
description:
"Suggests destinations based on customer preferences and requirements.",
model,
tools: destinationTools,
systemPrompt:
"You are a Destination Recommendation Agent that suggests destinations based on customer preferences and requirements.",
};
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The agent structure has been changed to remove the 'runnable' property and instead spread the model, tools, and systemPrompt properties directly on the agent object. However, this change is incompatible with the 'SubAgent' type from 'deepagents' which expects an object with 'name', 'description', and 'runnable' properties. The new structure directly includes 'model', 'tools', and 'systemPrompt' which may not match the expected interface. This could cause type errors or runtime failures when creating the deep agent.

Copilot uses AI. Check for mistakes.
} else if (event.event === "on_tool_start") {
// Tool execution started
} else if (event === "on_tool_start") {
// // Tool execution started
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has an extra leading space and appears to be commented out or incomplete ("// // Tool execution started"). This should either be removed entirely or properly completed as a single-line comment without the extra spaces and duplicate comment markers.

Suggested change
// // Tool execution started
// Tool execution started

Copilot uses AI. Check for mistakes.
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