forked from langchain-ai/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforked-subagents-basic.py
More file actions
42 lines (33 loc) · 910 Bytes
/
Copy pathforked-subagents-basic.py
File metadata and controls
42 lines (33 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""Forked subagents page code samples."""
from __future__ import annotations
# :snippet-start: forked-subagents-basic-py
from deepagents import create_deep_agent
def read_diff(path: str) -> str:
"""Read a file's diff."""
return f"diff for {path}"
comment_writer = {
"name": "comment-writer",
"description": "Continues an in-progress PR review and drafts review comments",
"mode": "fork",
"tools": [read_diff],
}
agent = create_deep_agent(
# KEEP MODEL
model="google_genai:gemini-3.7-flash",
tools=[read_diff],
subagents=[comment_writer],
)
result = agent.invoke(
{
"messages": [
{
"role": "user",
"content": "Review PR #482 and hand it off to comment-writer to draft comments for the issues found",
}
]
}
)
# :snippet-end:
# :remove-start:
assert result is not None
# :remove-end: