strands.vended_tools.graph.graph
Graph tool for running a directed acyclic graph of sub-agents at runtime.
Provides :func:make_graph (a factory that lets the developer pin safety
limits and authority modes) and :data:graph (a default instance). The tool is
a thin shim over :class:~strands.multiagent.graph.Graph: it resolves each node
spec through the authority-mode system, builds agents via an :data:AgentBuilder,
runs the graph, and maps the result.
DEFAULT_GRAPH_DESCRIPTION
Section titled “DEFAULT_GRAPH_DESCRIPTION”Description for the default graph tool.
EdgeSpec
Section titled “EdgeSpec”class EdgeSpec(TypedDict)Defined in: src/strands/vended_tools/graph/graph.py:56
One directed edge in a graph topology.
make_graph
Section titled “make_graph”def make_graph( *, name: str = "graph", description: str = DEFAULT_GRAPH_DESCRIPTION, builder: AgentBuilder | None = None, presets: Mapping[str, Preset] | None = None, default_preset: str | None = None, instructions: Open | Choice | Fixed | None = None, tools: Choice | Fixed | Inherit | None = None, model: Inherit | Choice | Fixed | None = None, max_nodes: int = _DEFAULT_MAX_NODES, max_edges: int = _DEFAULT_MAX_EDGES, max_node_executions: int | None = None, execution_timeout: float | None = _DEFAULT_EXECUTION_TIMEOUT, node_timeout: float | None = _DEFAULT_NODE_TIMEOUT) -> DecoratedFunctionToolDefined in: src/strands/vended_tools/graph/graph.py:86
Create a graph tool with developer-controlled safety limits and authority modes.
Each node spec from the model is resolved through the authority-mode system
(see :mod:~strands.multiagent.spec), then built via builder. A running graph
cannot be cancelled from the parent agent.
A child’s interrupt is surfaced as an interrupt of this tool and can be resumed after a parent-agent snapshot restore.
Arguments:
name- Tool name shown to the model.description- Tool description shown to the model.builder- Callable that turns an :class:AgentSpecinto anAgent. WhenNonea default builder is used that creates anAgentinheriting the caller’s model with the spec’s instructions and tools.presets- Named roles the model can select viaagent_type.default_preset- Preset used when the model omits bothagent_typeandinstructions.instructions- Authority mode for the instructions axis.tools- Authority mode for the tools axis.model- Authority mode for the model axis.max_nodes- Upper bound on nodes per invocation.max_edges- Upper bound on edges per invocation.max_node_executions- Maximum total node executions across the graph.Nonefor no limit.execution_timeout- Total timeout in seconds.Nonefor no limit.node_timeout- Per-node timeout in seconds.Nonefor no limit.
Returns:
A decorated tool that builds and runs a :class:~strands.multiagent.graph.Graph.
Raises:
ValueError- If a count limit is not a positive integer, a timeout is not a positive number, max_nodes < 2, or aChoiceaxis violates its constraints (empty options,multiple=Falsefor tools).
Default graph tool. Children inherit the caller’s model.