
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@stream-io/chat-langchain-sdk
Advanced tools
Shared utilities for building AI copilots that live inside Stream Chat channels. This package wires Stream’s real-time messaging primitives with LangChain chat models/tooling plus optional Mem0 long-term memory so you can stand up production agents with minimal glue code.
AgentManager, which spins agents up/down on demand and reuses shared tool definitions.getCurrentTemperature) and to summarize conversations for channel lists.npm install @stream-io/chat-langchain-sdk
# or
yarn add @stream-io/chat-langchain-sdk
This library ships TypeScript types and transpiled JavaScript under dist/.
Set the following before instantiating an agent:
| Variable | Required | Description |
|---|---|---|
STREAM_API_KEY / STREAM_API_SECRET | ✅ | Stream server client used to upsert/connect the agent user. |
OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY/GEMINI_API_KEY, XAI_API_KEY | ✅ (per provider) | API key for the provider selected via AgentPlatform. |
MEM0_API_KEY, MEM0_CONFIG_JSON, MEM0_DEFAULT_* | Optional | Enables Mem0 memory when present (see LangChainAIAgent). |
OPENWEATHER_API_KEY | Optional | Needed only when you use the weather tool returned by createDefaultTools. |
import {
Agent,
AgentPlatform,
createDefaultTools,
type ClientToolDefinition,
} from '@stream-io/chat-langchain-sdk';
const agent = new Agent({
userId: 'ai-bot-weather',
channelId: 'support-room',
platform: AgentPlatform.OPENAI,
model: 'gpt-4o-mini',
instructions: [
'Answer in a friendly, concise tone.',
'Prefer Celsius unless the user specifies otherwise.',
],
serverTools: createDefaultTools(), // any AgentTool[]
clientTools: [
{
name: 'openHelpCenter',
description: 'Open the help center in the web app',
parameters: {
type: 'object',
properties: { articleSlug: { type: 'string' } },
},
} satisfies ClientToolDefinition,
],
mem0Context: {
channelId: 'support-room',
appId: 'stream-chat-support',
},
});
await agent.start();
// Later:
await agent.stop();
Use AgentManager when you need to spin up AI copilots for many channels (e.g., one per customer conversation) and dispose them automatically once idle.
import {
AgentManager,
AgentPlatform,
createDefaultTools,
} from '@stream-io/chat-langchain-sdk';
const manager = new AgentManager({
serverToolsFactory: () => createDefaultTools(),
inactivityThresholdMs: 15 * 60 * 1000, // stop after 15 minutes of silence
agentIdResolver: (channelId) => `ai-${channelId}`, // optional custom mapping
});
await manager.startAgent({
userId: 'ai-support-bot-123', // usually derived from channelId/orgId
channelId: 'support-room',
channelType: 'messaging',
platform: AgentPlatform.OPENAI,
instructions: 'Answer with step-by-step troubleshooting tips.',
});
manager.registerClientTools('support-room', [
{
name: 'openTicket',
description: 'Open the CRM ticket in the dashboard',
parameters: {
type: 'object',
properties: { ticketId: { type: 'string' } },
required: ['ticketId'],
},
},
]);
// Later in your shutdown hook:
await manager.stopAgent('ai-support-bot-123');
manager.dispose();
AgentManager will:
userId, auto-starting it on demand.inactivityThresholdMs) to free resources.activeAgentCount for basic monitoring and a dispose method to clean intervals when your process exits.agent.registerServerTools.Need unread badges or channel list previews? Call await agent.summarize(text) or Agent.generateSummary(text, platform) to produce a short, LLM-generated headline.
npm run clean
npm run build
Publishing to npm is as simple as bumping the version and running:
npm publish --access public
src/
├─ Agent.ts // Manages lifecycle of the AI user inside Stream Chat
├─ LangChainAIAgent.ts // Handles streaming, tool invocation, and Mem0 integration
├─ defaultTools.ts // Example AgentTool implementations
├─ serverClient.ts // Stream server SDK bootstrap
└─ types.ts // Shared enums/interfaces
Use dist/ for the compiled output referenced by package.json (main/types).
FAQs
Shared LangChain agent utilities for Stream Chat
We found that @stream-io/chat-langchain-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.