MCPcopy Index your code
hub / github.com/google/adk-python / build_node

Function build_node

src/google/adk/workflow/utils/_workflow_graph_utils.py:40–136  ·  view source on GitHub ↗

Converts a NodeLike to a BaseNode, wrapping async funcs in FunctionNode. Args: node_like: The item to convert to a BaseNode. name: If provided, overrides the name of the wrapped node. rerun_on_resume: If provided, overrides the rerun_on_resume property of the wrapped node. r

(
    node_like: NodeLike,
    *,
    name: str | None = None,
    rerun_on_resume: bool | None = None,
    retry_config: RetryConfig | None = None,
    timeout: float | None = None,
    auth_config: Any = None,
)

Source from the content-addressed store, hash-verified

38
39
40def build_node(
41 node_like: NodeLike,
42 *,
43 name: str | None = None,
44 rerun_on_resume: bool | None = None,
45 retry_config: RetryConfig | None = None,
46 timeout: float | None = None,
47 auth_config: Any = None,
48) -> BaseNode:
49 """Converts a NodeLike to a BaseNode, wrapping async funcs in FunctionNode.
50
51 Args:
52 node_like: The item to convert to a BaseNode.
53 name: If provided, overrides the name of the wrapped node.
54 rerun_on_resume: If provided, overrides the rerun_on_resume property of the
55 wrapped node.
56 retry_config: If provided, overrides the retry_config property of the
57 wrapped node.
58 timeout: If provided, overrides the timeout property of the wrapped node.
59 auth_config: If provided, passed to FunctionNode for authentication.
60
61 Returns:
62 A BaseNode instance.
63
64 Raises:
65 ValueError: If node_like is not a valid type (BaseNode, BaseAgent,
66 BaseTool, callable, or 'START').
67 """
68
69 if node_like == 'START':
70 return START
71
72 # Lazy import to avoid circular dependency:
73 # workflow_graph_utils -> agents.llm_agent -> ... -> workflow_graph_utils
74 from ...agents.llm_agent import LlmAgent
75
76 if isinstance(node_like, BaseNode):
77 kwargs: dict[str, Any] = {}
78 if name is not None:
79 kwargs['name'] = name
80 if rerun_on_resume is not None:
81 kwargs['rerun_on_resume'] = rerun_on_resume
82 if retry_config is not None:
83 kwargs['retry_config'] = retry_config
84 if timeout is not None:
85 kwargs['timeout'] = timeout
86
87 if isinstance(node_like, LlmAgent):
88 if rerun_on_resume is None:
89 kwargs['rerun_on_resume'] = True
90 agent = node_like.clone(update=kwargs)
91 # Preserve parent agent reference that was lost during clone
92 agent.parent_agent = node_like.parent_agent
93
94 if agent.mode is None:
95 # Sub-agents dynamically attached to a parent agent default to 'chat'
96 # mode to enable agent transfer.
97 # Standalone agents in a workflow graph default to 'single_turn'.

Calls 6

_ParallelWorkerClass · 0.85
_ToolNodeClass · 0.85
FunctionNodeClass · 0.85
typeFunction · 0.85
cloneMethod · 0.45
model_copyMethod · 0.45