Skip to content

LLMNode (base)

nae.nodes.llm_node.LLMNode

LLMNode(name: Optional[str] = None, llm: Optional[Any] = None, node_prompt: str = '', tools: Optional[list] = None, max_tool_iterations: int = 25, cache_ttl: Optional[int] = None, retry: bool = False)

Bases: Node

Base for LLM-backed nodes.

Holds the model, the normalized tool list / lookup, the tool-loop cap, and the prompt-cache fields, and provides _run_tool_loop — the shared tool-call loop that both AgentNode (free-form) and DecisionNode (two-phase, to gather context before routing) run.

Subclasses decide how tools bind to the model: AgentNode binds them onto self.llm; DecisionNode keeps the base model and binds a separate _tool_llm so tools never share a call with structured output.

Initialize the shared LLM-node plumbing.

Parameters:

Name Type Description Default
name Optional[str]

Unique identifier for the node (inferred from the assignment target when omitted; see Node).

None
llm Optional[Any]

Language model instance this node calls.

None
node_prompt str

System prompt prepended to the history on each call.

''
tools Optional[list]

Tools the node may call. Each is normalized to a LangChain tool (StructuredTool/BaseTool as-is; a plain callable via StructuredTool.from_function) and stored with a name lookup for the tool-call loop. Subclasses decide how they bind to the model.

None
max_tool_iterations int

Safety cap on the tool-call loop in _run_tool_loop; exceeding it raises RuntimeError.

25
cache_ttl Optional[int]

see Node — node-level result caching.

None
retry bool

see Node — node-level retry on exception.

False