mirror of
https://github.com/langchain-ai/docs.git
synced 2026-08-27 02:41:59 -04:00
387 lines
12 KiB
Plaintext
387 lines
12 KiB
Plaintext
<CodeGroup>
|
|
```python Google
|
|
from deepagents import (
|
|
create_deep_agent
|
|
)
|
|
|
|
agent = create_deep_agent(
|
|
model="google_genai:gemini-3.6-flash",
|
|
system_prompt=(
|
|
"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."
|
|
),
|
|
"system_prompt": (
|
|
"You are a great researcher. Return a brief summary."
|
|
),
|
|
},
|
|
],
|
|
name="main-agent",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
stream = agent.stream_events(
|
|
{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "Research one recent advance in quantum computing.",
|
|
}
|
|
]
|
|
},
|
|
version="v3",
|
|
)
|
|
|
|
coordinator_messages: list[str] = []
|
|
subagent_handles = []
|
|
|
|
for name, item in stream.interleave("messages", "subagents"):
|
|
if name == "messages":
|
|
print("[coordinator]", item.text)
|
|
coordinator_messages.append(item.text)
|
|
else:
|
|
print(f"[{item.name}] started")
|
|
subagent_handles.append(item)
|
|
for message in item.messages:
|
|
print(f"[{item.name}]", message.text)
|
|
print(f"[{item.name}] status: {item.status}")
|
|
```
|
|
|
|
```python OpenAI
|
|
from deepagents import (
|
|
create_deep_agent
|
|
)
|
|
|
|
agent = create_deep_agent(
|
|
model="openai:gpt-5.5",
|
|
system_prompt=(
|
|
"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."
|
|
),
|
|
"system_prompt": (
|
|
"You are a great researcher. Return a brief summary."
|
|
),
|
|
},
|
|
],
|
|
name="main-agent",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
stream = agent.stream_events(
|
|
{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "Research one recent advance in quantum computing.",
|
|
}
|
|
]
|
|
},
|
|
version="v3",
|
|
)
|
|
|
|
coordinator_messages: list[str] = []
|
|
subagent_handles = []
|
|
|
|
for name, item in stream.interleave("messages", "subagents"):
|
|
if name == "messages":
|
|
print("[coordinator]", item.text)
|
|
coordinator_messages.append(item.text)
|
|
else:
|
|
print(f"[{item.name}] started")
|
|
subagent_handles.append(item)
|
|
for message in item.messages:
|
|
print(f"[{item.name}]", message.text)
|
|
print(f"[{item.name}] status: {item.status}")
|
|
```
|
|
|
|
```python Anthropic
|
|
from deepagents import (
|
|
create_deep_agent
|
|
)
|
|
|
|
agent = create_deep_agent(
|
|
model="anthropic:claude-sonnet-4-6",
|
|
system_prompt=(
|
|
"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."
|
|
),
|
|
"system_prompt": (
|
|
"You are a great researcher. Return a brief summary."
|
|
),
|
|
},
|
|
],
|
|
name="main-agent",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
stream = agent.stream_events(
|
|
{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "Research one recent advance in quantum computing.",
|
|
}
|
|
]
|
|
},
|
|
version="v3",
|
|
)
|
|
|
|
coordinator_messages: list[str] = []
|
|
subagent_handles = []
|
|
|
|
for name, item in stream.interleave("messages", "subagents"):
|
|
if name == "messages":
|
|
print("[coordinator]", item.text)
|
|
coordinator_messages.append(item.text)
|
|
else:
|
|
print(f"[{item.name}] started")
|
|
subagent_handles.append(item)
|
|
for message in item.messages:
|
|
print(f"[{item.name}]", message.text)
|
|
print(f"[{item.name}] status: {item.status}")
|
|
```
|
|
|
|
```python OpenRouter
|
|
from deepagents import (
|
|
create_deep_agent
|
|
)
|
|
|
|
agent = create_deep_agent(
|
|
model="openrouter:z-ai/glm-5.2",
|
|
system_prompt=(
|
|
"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."
|
|
),
|
|
"system_prompt": (
|
|
"You are a great researcher. Return a brief summary."
|
|
),
|
|
},
|
|
],
|
|
name="main-agent",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
stream = agent.stream_events(
|
|
{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "Research one recent advance in quantum computing.",
|
|
}
|
|
]
|
|
},
|
|
version="v3",
|
|
)
|
|
|
|
coordinator_messages: list[str] = []
|
|
subagent_handles = []
|
|
|
|
for name, item in stream.interleave("messages", "subagents"):
|
|
if name == "messages":
|
|
print("[coordinator]", item.text)
|
|
coordinator_messages.append(item.text)
|
|
else:
|
|
print(f"[{item.name}] started")
|
|
subagent_handles.append(item)
|
|
for message in item.messages:
|
|
print(f"[{item.name}]", message.text)
|
|
print(f"[{item.name}] status: {item.status}")
|
|
```
|
|
|
|
```python Fireworks
|
|
from deepagents import (
|
|
create_deep_agent
|
|
)
|
|
|
|
agent = create_deep_agent(
|
|
model="fireworks:accounts/fireworks/models/glm-5p2",
|
|
system_prompt=(
|
|
"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."
|
|
),
|
|
"system_prompt": (
|
|
"You are a great researcher. Return a brief summary."
|
|
),
|
|
},
|
|
],
|
|
name="main-agent",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
stream = agent.stream_events(
|
|
{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "Research one recent advance in quantum computing.",
|
|
}
|
|
]
|
|
},
|
|
version="v3",
|
|
)
|
|
|
|
coordinator_messages: list[str] = []
|
|
subagent_handles = []
|
|
|
|
for name, item in stream.interleave("messages", "subagents"):
|
|
if name == "messages":
|
|
print("[coordinator]", item.text)
|
|
coordinator_messages.append(item.text)
|
|
else:
|
|
print(f"[{item.name}] started")
|
|
subagent_handles.append(item)
|
|
for message in item.messages:
|
|
print(f"[{item.name}]", message.text)
|
|
print(f"[{item.name}] status: {item.status}")
|
|
```
|
|
|
|
```python Baseten
|
|
from deepagents import (
|
|
create_deep_agent
|
|
)
|
|
|
|
agent = create_deep_agent(
|
|
model="baseten:zai-org/GLM-5.2",
|
|
system_prompt=(
|
|
"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."
|
|
),
|
|
"system_prompt": (
|
|
"You are a great researcher. Return a brief summary."
|
|
),
|
|
},
|
|
],
|
|
name="main-agent",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
stream = agent.stream_events(
|
|
{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "Research one recent advance in quantum computing.",
|
|
}
|
|
]
|
|
},
|
|
version="v3",
|
|
)
|
|
|
|
coordinator_messages: list[str] = []
|
|
subagent_handles = []
|
|
|
|
for name, item in stream.interleave("messages", "subagents"):
|
|
if name == "messages":
|
|
print("[coordinator]", item.text)
|
|
coordinator_messages.append(item.text)
|
|
else:
|
|
print(f"[{item.name}] started")
|
|
subagent_handles.append(item)
|
|
for message in item.messages:
|
|
print(f"[{item.name}]", message.text)
|
|
print(f"[{item.name}] status: {item.status}")
|
|
```
|
|
|
|
```python Ollama
|
|
from deepagents import (
|
|
create_deep_agent
|
|
)
|
|
|
|
agent = create_deep_agent(
|
|
model="ollama:north-mini-code-1.0",
|
|
system_prompt=(
|
|
"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."
|
|
),
|
|
"system_prompt": (
|
|
"You are a great researcher. Return a brief summary."
|
|
),
|
|
},
|
|
],
|
|
name="main-agent",
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
stream = agent.stream_events(
|
|
{
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": "Research one recent advance in quantum computing.",
|
|
}
|
|
]
|
|
},
|
|
version="v3",
|
|
)
|
|
|
|
coordinator_messages: list[str] = []
|
|
subagent_handles = []
|
|
|
|
for name, item in stream.interleave("messages", "subagents"):
|
|
if name == "messages":
|
|
print("[coordinator]", item.text)
|
|
coordinator_messages.append(item.text)
|
|
else:
|
|
print(f"[{item.name}] started")
|
|
subagent_handles.append(item)
|
|
for message in item.messages:
|
|
print(f"[{item.name}]", message.text)
|
|
print(f"[{item.name}] status: {item.status}")
|
|
```
|
|
</CodeGroup>
|