@langchain/managed-deepagents
v0.1.1
Published
TypeScript SDK for LangSmith Managed Deep Agents.
Downloads
433
Readme
@langchain/managed-deepagents
TypeScript SDK for the LangSmith Managed Deep Agents API.
Managed Deep Agents is a hosted runtime for creating, running, and operating Deep Agents through LangSmith. This package is currently public beta software.
Installation
npm install @langchain/managed-deepagentsRequirements:
- Node.js 20 or newer
- A LangSmith API key with access to Managed Deep Agents
Configuration
The client reads LANGSMITH_API_KEY by default in server-side JavaScript
runtimes.
export LANGSMITH_API_KEY="..."The default API URL is https://api.smith.langchain.com/v1/deepagents.
You can override it with LANGSMITH_ENDPOINT or the apiUrl client option.
For browser apps, avoid exposing long-lived API keys. Pass a custom fetch
implementation that calls your own backend, or create server-side routes that
own the LangSmith credentials.
Quickstart
import { Client } from "@langchain/managed-deepagents";
const client = new Client({
apiKey: process.env.LANGSMITH_API_KEY,
});
const agent = await client.agents.create({
name: "research-assistant",
model: "openai:gpt-5.5",
instructions: "You are a careful research assistant.",
});
const thread = await client.threads.create({ agent_id: agent.id });
const stream = client.threads.stream(thread.id, { agentId: agent.id });
await stream.run.start({
input: {
messages: [{ role: "user", content: "Summarize the latest notes." }],
},
});
for await (const message of stream.messages) {
for await (const token of message.text) {
process.stdout.write(token);
}
}
console.log(await stream.output);
await stream.close();React useStream
The SDK includes a LangGraph client adapter for @langchain/react. Use
getLangGraphClient() for React streaming so LangGraph owns the generic
thread, run, and projection behavior; this SDK only translates Managed Deep
Agents-specific routes, headers, and payload fields.
import { Client } from "@langchain/managed-deepagents";
import { useStream } from "@langchain/react";
const agentId = "agent-id";
const managedDeepAgents = new Client({
apiKey: process.env.LANGSMITH_API_KEY,
});
const client = managedDeepAgents.getLangGraphClient({ agentId });
export function ManagedDeepAgentStream() {
const stream = useStream({
client,
assistantId: agentId,
fetchStateHistory: false,
});
return (
<section>
<button
type="button"
disabled={stream.isLoading}
onClick={() => {
void stream.submit({
messages: [{ role: "user", content: "Write a short status update." }],
});
}}
>
Run agent
</button>
{stream.messages.map((message, index) => (
<p key={message.id ?? index}>{String(message.content)}</p>
))}
<p>State keys: {Object.keys(stream.values).join(", ")}</p>
</section>
);
}Agent Files
Top-level files entries may be passed as raw strings; the SDK normalizes them
to file entries before sending the request.
const agent = await client.agents.create(
{
name: "research-assistant",
files: {
"AGENTS.md": "You are a careful research assistant.",
"skills/research/SKILL.md": "# Research\n\nGather context before answering.",
},
},
{ includeFiles: true }
);API Surface
Resources exposed by the client:
client.agents: list, create, get, update, delete, clone, healthclient.threads: list, create, search, count, get, update, delete, create run, invoke, stream, bulk update, resolve interruptclient.mcpServers: create, list, get, update, delete, register OAuth provider, list toolsclient.authSessions: create and get
Errors
import { ManagedDeepAgentsAPIError } from "@langchain/managed-deepagents";
try {
await client.agents.get("missing-agent");
} catch (error) {
if (error instanceof ManagedDeepAgentsAPIError) {
console.log(error.status, error.code, error.detail);
}
}Links
- Repository: https://github.com/langchain-ai/managed-deepagents-sdk
- Issues: https://github.com/langchain-ai/managed-deepagents-sdk/issues
- Changelog: https://github.com/langchain-ai/managed-deepagents-sdk/blob/main/CHANGELOG.md
