Skip to content

teff.node.node

teff.node.node

Abstract base for all graph nodes.

Classes:

Name Description
Node

Abstract base class for all graph nodes.

Node

Bases: ABC

Abstract base class for all graph nodes.

Subclasses must set type and implement execute.

Attributes:

Name Type Description
type str

Unique node type identifier used for registry lookups.

config

Configuration dict (merged from constructor kwargs).

Methods:

Name Description
execute

Execute the node's logic.

Source code in teff/node/node.py
 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
class Node(ABC):
    """Abstract base class for all graph nodes.

    Subclasses must set *type* and implement *execute*.

    Attributes:
        type: Unique node type identifier used for registry lookups.
        config: Configuration dict (merged from constructor kwargs).
    """

    type: str = ""

    def __init__(self, config: dict | None = None, **kwargs):
        self.config = {**(config or {}), **kwargs}

    @abstractmethod
    async def execute(self, ctx: typing.Any, state: dict) -> "dict | Command":
        """Execute the node's logic.

        Args:
            ctx: Execution context providing tool/LLM access.
            state: Current workflow state dict (shallow-merge in/out).

        Returns:
            State updates to shallow-merge into the workflow state, or a
            :class:`~teff.node.Command` that additionally routes the graph
            to a specific next node.
        """

execute abstractmethod async

execute(ctx, state)

Execute the node's logic.

Parameters:

Name Type Description Default
ctx Any

Execution context providing tool/LLM access.

required
state dict

Current workflow state dict (shallow-merge in/out).

required

Returns:

Type Description
dict | Command

State updates to shallow-merge into the workflow state, or a

dict | Command

class:~teff.node.Command that additionally routes the graph

dict | Command

to a specific next node.

Source code in teff/node/node.py
24
25
26
27
28
29
30
31
32
33
34
35
36
@abstractmethod
async def execute(self, ctx: typing.Any, state: dict) -> "dict | Command":
    """Execute the node's logic.

    Args:
        ctx: Execution context providing tool/LLM access.
        state: Current workflow state dict (shallow-merge in/out).

    Returns:
        State updates to shallow-merge into the workflow state, or a
        :class:`~teff.node.Command` that additionally routes the graph
        to a specific next node.
    """