nxnodex
Search docsv0.1.0GitHub

API

API reference

The reference is organized around the objects developers import and call directly.

Class

Agent

The main entry point for a Nodex graph. Create one agent, register nodes with decorators, then call run().

Agent(name: str = "agent", debug: bool = False)
nameName shown in terminal output and execution traces.
debugPrints richer failure details when available.

Decorator

app.node()

Registers a Python function as a graph node. The function receives state and must return a non-empty dictionary.

@app.node(next="end", retry=0, on_fail="raise", timeout=30.0, human_review=False)
nextNext node name, or "end" to finish.
retryNumber of retry attempts before failure handling.
on_failFailure behavior. Use "raise" or a fallback node name.
timeoutMaximum seconds allowed for the node function.
human_reviewPrompts for terminal approval before continuing.

Decorator

app.route()

Adds conditional routing to a node. Use it when the next step depends on state produced by earlier nodes.

@app.route(condition, if_true="publish", if_false="review")

State

NodexState

A small wrapper around user data. It keeps internal execution fields separate from the dictionary your nodes read and update.

get(key, default)Read a value from the current state.
set(key, value)Set one state value.
update(dict)Merge multiple values without overwriting internal fields.

Testing

Testing utilities

from nodex.testing import test_node

result = test_node(research, {"query": "AI trends"})
assert result.success

Errors

Exceptions

NodexNodeErrorRaised when a node fails after retry and failure handling.
NodexStateErrorRaised when a node returns invalid state output.
NodexMiddlewareErrorRaised when middleware fails.
NodexConfigErrorRaised for invalid app or graph configuration.
NodexTimeoutErrorRaised when a node exceeds its timeout.