mirror of
https://github.com/langchain-ai/docs.git
synced 2026-08-27 21:00:00 -04:00
408 lines
12 KiB
Plaintext
408 lines
12 KiB
Plaintext
<CodeGroup>
|
|
```ts Google
|
|
import { createDeepAgent } from "deepagents";
|
|
|
|
const agent = createDeepAgent({
|
|
model: "google-genai:gemini-3.6-flash",
|
|
systemPrompt:
|
|
"You are a project coordinator with no research knowledge. " +
|
|
"For every user request, you must call the task() tool with " +
|
|
"subagent_type set to research-agent. Never answer research " +
|
|
"questions yourself.",
|
|
subagents: [
|
|
{
|
|
name: "research-agent",
|
|
description:
|
|
"Delegate research to this subagent. Give one topic at a time.",
|
|
systemPrompt: "You are a great researcher. Return a brief summary.",
|
|
},
|
|
],
|
|
});
|
|
|
|
async function streamSubagentProgress() {
|
|
const stream = await agent.streamEvents(
|
|
{
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Research one recent advance in quantum computing.",
|
|
},
|
|
],
|
|
},
|
|
{ version: "v3" },
|
|
);
|
|
|
|
const coordinatorMessages: string[] = [];
|
|
const subagentHandles: { name: string }[] = [];
|
|
|
|
await Promise.all([
|
|
(async () => {
|
|
for await (const message of stream.messages) {
|
|
console.log("[coordinator]", await message.text);
|
|
coordinatorMessages.push(await message.text);
|
|
}
|
|
})(),
|
|
(async () => {
|
|
for await (const subagent of stream.subagents) {
|
|
console.log(`[${subagent.name}] started`);
|
|
subagentHandles.push({ name: subagent.name });
|
|
for await (const message of subagent.messages) {
|
|
console.log(`[${subagent.name}]`, await message.text);
|
|
}
|
|
}
|
|
})(),
|
|
]);
|
|
|
|
return { coordinatorMessages, subagentHandles };
|
|
}
|
|
```
|
|
|
|
```ts OpenAI
|
|
import { createDeepAgent } from "deepagents";
|
|
|
|
const agent = createDeepAgent({
|
|
model: "openai:gpt-5.5",
|
|
systemPrompt:
|
|
"You are a project coordinator with no research knowledge. " +
|
|
"For every user request, you must call the task() tool with " +
|
|
"subagent_type set to research-agent. Never answer research " +
|
|
"questions yourself.",
|
|
subagents: [
|
|
{
|
|
name: "research-agent",
|
|
description:
|
|
"Delegate research to this subagent. Give one topic at a time.",
|
|
systemPrompt: "You are a great researcher. Return a brief summary.",
|
|
},
|
|
],
|
|
});
|
|
|
|
async function streamSubagentProgress() {
|
|
const stream = await agent.streamEvents(
|
|
{
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Research one recent advance in quantum computing.",
|
|
},
|
|
],
|
|
},
|
|
{ version: "v3" },
|
|
);
|
|
|
|
const coordinatorMessages: string[] = [];
|
|
const subagentHandles: { name: string }[] = [];
|
|
|
|
await Promise.all([
|
|
(async () => {
|
|
for await (const message of stream.messages) {
|
|
console.log("[coordinator]", await message.text);
|
|
coordinatorMessages.push(await message.text);
|
|
}
|
|
})(),
|
|
(async () => {
|
|
for await (const subagent of stream.subagents) {
|
|
console.log(`[${subagent.name}] started`);
|
|
subagentHandles.push({ name: subagent.name });
|
|
for await (const message of subagent.messages) {
|
|
console.log(`[${subagent.name}]`, await message.text);
|
|
}
|
|
}
|
|
})(),
|
|
]);
|
|
|
|
return { coordinatorMessages, subagentHandles };
|
|
}
|
|
```
|
|
|
|
```ts Anthropic
|
|
import { createDeepAgent } from "deepagents";
|
|
|
|
const agent = createDeepAgent({
|
|
model: "anthropic:claude-sonnet-4-6",
|
|
systemPrompt:
|
|
"You are a project coordinator with no research knowledge. " +
|
|
"For every user request, you must call the task() tool with " +
|
|
"subagent_type set to research-agent. Never answer research " +
|
|
"questions yourself.",
|
|
subagents: [
|
|
{
|
|
name: "research-agent",
|
|
description:
|
|
"Delegate research to this subagent. Give one topic at a time.",
|
|
systemPrompt: "You are a great researcher. Return a brief summary.",
|
|
},
|
|
],
|
|
});
|
|
|
|
async function streamSubagentProgress() {
|
|
const stream = await agent.streamEvents(
|
|
{
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Research one recent advance in quantum computing.",
|
|
},
|
|
],
|
|
},
|
|
{ version: "v3" },
|
|
);
|
|
|
|
const coordinatorMessages: string[] = [];
|
|
const subagentHandles: { name: string }[] = [];
|
|
|
|
await Promise.all([
|
|
(async () => {
|
|
for await (const message of stream.messages) {
|
|
console.log("[coordinator]", await message.text);
|
|
coordinatorMessages.push(await message.text);
|
|
}
|
|
})(),
|
|
(async () => {
|
|
for await (const subagent of stream.subagents) {
|
|
console.log(`[${subagent.name}] started`);
|
|
subagentHandles.push({ name: subagent.name });
|
|
for await (const message of subagent.messages) {
|
|
console.log(`[${subagent.name}]`, await message.text);
|
|
}
|
|
}
|
|
})(),
|
|
]);
|
|
|
|
return { coordinatorMessages, subagentHandles };
|
|
}
|
|
```
|
|
|
|
```ts OpenRouter
|
|
import { createDeepAgent } from "deepagents";
|
|
|
|
const agent = createDeepAgent({
|
|
model: "openrouter:openrouter:z-ai/glm-5.2",
|
|
systemPrompt:
|
|
"You are a project coordinator with no research knowledge. " +
|
|
"For every user request, you must call the task() tool with " +
|
|
"subagent_type set to research-agent. Never answer research " +
|
|
"questions yourself.",
|
|
subagents: [
|
|
{
|
|
name: "research-agent",
|
|
description:
|
|
"Delegate research to this subagent. Give one topic at a time.",
|
|
systemPrompt: "You are a great researcher. Return a brief summary.",
|
|
},
|
|
],
|
|
});
|
|
|
|
async function streamSubagentProgress() {
|
|
const stream = await agent.streamEvents(
|
|
{
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Research one recent advance in quantum computing.",
|
|
},
|
|
],
|
|
},
|
|
{ version: "v3" },
|
|
);
|
|
|
|
const coordinatorMessages: string[] = [];
|
|
const subagentHandles: { name: string }[] = [];
|
|
|
|
await Promise.all([
|
|
(async () => {
|
|
for await (const message of stream.messages) {
|
|
console.log("[coordinator]", await message.text);
|
|
coordinatorMessages.push(await message.text);
|
|
}
|
|
})(),
|
|
(async () => {
|
|
for await (const subagent of stream.subagents) {
|
|
console.log(`[${subagent.name}] started`);
|
|
subagentHandles.push({ name: subagent.name });
|
|
for await (const message of subagent.messages) {
|
|
console.log(`[${subagent.name}]`, await message.text);
|
|
}
|
|
}
|
|
})(),
|
|
]);
|
|
|
|
return { coordinatorMessages, subagentHandles };
|
|
}
|
|
```
|
|
|
|
```ts Fireworks
|
|
import { createDeepAgent } from "deepagents";
|
|
|
|
const agent = createDeepAgent({
|
|
model: "fireworks:accounts/fireworks/models/glm-5p2",
|
|
systemPrompt:
|
|
"You are a project coordinator with no research knowledge. " +
|
|
"For every user request, you must call the task() tool with " +
|
|
"subagent_type set to research-agent. Never answer research " +
|
|
"questions yourself.",
|
|
subagents: [
|
|
{
|
|
name: "research-agent",
|
|
description:
|
|
"Delegate research to this subagent. Give one topic at a time.",
|
|
systemPrompt: "You are a great researcher. Return a brief summary.",
|
|
},
|
|
],
|
|
});
|
|
|
|
async function streamSubagentProgress() {
|
|
const stream = await agent.streamEvents(
|
|
{
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Research one recent advance in quantum computing.",
|
|
},
|
|
],
|
|
},
|
|
{ version: "v3" },
|
|
);
|
|
|
|
const coordinatorMessages: string[] = [];
|
|
const subagentHandles: { name: string }[] = [];
|
|
|
|
await Promise.all([
|
|
(async () => {
|
|
for await (const message of stream.messages) {
|
|
console.log("[coordinator]", await message.text);
|
|
coordinatorMessages.push(await message.text);
|
|
}
|
|
})(),
|
|
(async () => {
|
|
for await (const subagent of stream.subagents) {
|
|
console.log(`[${subagent.name}] started`);
|
|
subagentHandles.push({ name: subagent.name });
|
|
for await (const message of subagent.messages) {
|
|
console.log(`[${subagent.name}]`, await message.text);
|
|
}
|
|
}
|
|
})(),
|
|
]);
|
|
|
|
return { coordinatorMessages, subagentHandles };
|
|
}
|
|
```
|
|
|
|
```ts Baseten
|
|
import { createDeepAgent } from "deepagents";
|
|
|
|
const agent = createDeepAgent({
|
|
model: "baseten:zai-org/GLM-5.2",
|
|
systemPrompt:
|
|
"You are a project coordinator with no research knowledge. " +
|
|
"For every user request, you must call the task() tool with " +
|
|
"subagent_type set to research-agent. Never answer research " +
|
|
"questions yourself.",
|
|
subagents: [
|
|
{
|
|
name: "research-agent",
|
|
description:
|
|
"Delegate research to this subagent. Give one topic at a time.",
|
|
systemPrompt: "You are a great researcher. Return a brief summary.",
|
|
},
|
|
],
|
|
});
|
|
|
|
async function streamSubagentProgress() {
|
|
const stream = await agent.streamEvents(
|
|
{
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Research one recent advance in quantum computing.",
|
|
},
|
|
],
|
|
},
|
|
{ version: "v3" },
|
|
);
|
|
|
|
const coordinatorMessages: string[] = [];
|
|
const subagentHandles: { name: string }[] = [];
|
|
|
|
await Promise.all([
|
|
(async () => {
|
|
for await (const message of stream.messages) {
|
|
console.log("[coordinator]", await message.text);
|
|
coordinatorMessages.push(await message.text);
|
|
}
|
|
})(),
|
|
(async () => {
|
|
for await (const subagent of stream.subagents) {
|
|
console.log(`[${subagent.name}] started`);
|
|
subagentHandles.push({ name: subagent.name });
|
|
for await (const message of subagent.messages) {
|
|
console.log(`[${subagent.name}]`, await message.text);
|
|
}
|
|
}
|
|
})(),
|
|
]);
|
|
|
|
return { coordinatorMessages, subagentHandles };
|
|
}
|
|
```
|
|
|
|
```ts Ollama
|
|
import { createDeepAgent } from "deepagents";
|
|
|
|
const agent = createDeepAgent({
|
|
model: "ollama:north-mini-code-1.0",
|
|
systemPrompt:
|
|
"You are a project coordinator with no research knowledge. " +
|
|
"For every user request, you must call the task() tool with " +
|
|
"subagent_type set to research-agent. Never answer research " +
|
|
"questions yourself.",
|
|
subagents: [
|
|
{
|
|
name: "research-agent",
|
|
description:
|
|
"Delegate research to this subagent. Give one topic at a time.",
|
|
systemPrompt: "You are a great researcher. Return a brief summary.",
|
|
},
|
|
],
|
|
});
|
|
|
|
async function streamSubagentProgress() {
|
|
const stream = await agent.streamEvents(
|
|
{
|
|
messages: [
|
|
{
|
|
role: "user",
|
|
content: "Research one recent advance in quantum computing.",
|
|
},
|
|
],
|
|
},
|
|
{ version: "v3" },
|
|
);
|
|
|
|
const coordinatorMessages: string[] = [];
|
|
const subagentHandles: { name: string }[] = [];
|
|
|
|
await Promise.all([
|
|
(async () => {
|
|
for await (const message of stream.messages) {
|
|
console.log("[coordinator]", await message.text);
|
|
coordinatorMessages.push(await message.text);
|
|
}
|
|
})(),
|
|
(async () => {
|
|
for await (const subagent of stream.subagents) {
|
|
console.log(`[${subagent.name}] started`);
|
|
subagentHandles.push({ name: subagent.name });
|
|
for await (const message of subagent.messages) {
|
|
console.log(`[${subagent.name}]`, await message.text);
|
|
}
|
|
}
|
|
})(),
|
|
]);
|
|
|
|
return { coordinatorMessages, subagentHandles };
|
|
}
|
|
```
|
|
</CodeGroup>
|