Skip to content

Errors ​

Mistakes in the graph itself (an unknown node name, a node nothing leads to, two nodes that return a whole state in the same step without a reducer) are reported by compile(), before anything runs. Everything the library throws extends TelarException:

ExceptionWhen
GraphValidationExceptionThe graph or GraphConfig is invalid. Thrown by compile() or when a run starts, and when a node calls interrupt in a run without a checkpointer.
NodeExecutionExceptionA node threw, or a withTimeout inside it expired. nodeName and the original cause are available, and attempts says how often the node ran. Every exception is wrapped, also one of this table that a graph inside the node threw.
NodeTimeoutExceptionA try of a node took longer than the timeout of the node. A run reports it as the cause of a NodeExecutionException.
EdgeConditionExceptionThe function of a conditional edge threw. from and the original cause are available.
ReducerExceptionThe reducer threw. nodes (the nodes whose states it was merging) and the original cause are available.
InvalidRouteExceptionA conditional edge returned a node that does not exist or is not a declared target.
MaxIterationsExceededExceptionThe run took more steps than GraphConfig.maxIterations (default 25).
CheckpointNotFoundException, GraphAlreadyCompletedExceptionresume had nothing to continue.
ThreadAlreadyExistsExceptionfork was given a thread that already has a checkpoint.
CheckpointCorruptedExceptionA stored checkpoint could not be read.
LocalStorageExceptionThe browser refused to read or write localStorage: it is full, or the page may not use it. From telar-checkpoint-browser.
ChatModelExceptionA call to a ChatModel failed, or the model declined to answer. From telar-agent. A run reports it as the cause of a NodeExecutionException.

A node that fails ends the run, unless it has a retry: see Retries and time limits. A run with a checkpointer that failed is continued with resume, which runs the failed step again.

What counts as a failure ​

A node, a conditional edge, a reducer and a tool fail with whatever they throw. Three things are no failure and pass through the library as they are:

  • A cancellation of the run. It arrives as a CancellationException.
  • A pause. interrupt stops the node with a signal of its own, which the engine turns into a paused run.
  • An error of the program or of its machine. That is a subclass of Error, such as OutOfMemoryError, the AssertionError of a test that asserts inside a node, or the NotImplementedError of TODO(). A retry would not help with any of them.

In a browser not every failure is an Exception. Ktor reports a request that got no response as a plain Error that says Fail to fetch, and an error that JavaScript throws is not an Exception in Kotlin either. Both are failures like any other: a node that runs into one fails with a NodeExecutionException, and a tool returns an error result that the model can react to.

Released under the Apache License 2.0.