agentflow4j
agentflow4j copied to clipboard
Per-node execution timeout on AgentGraph
Problem
There is currently no way to cap how long a single node may run. A slow LLM call or a hanging tool can block the graph indefinitely. RetryPolicy handles failures after the fact, but a timeout is needed to bound the wait.
Proposed API
AgentGraph graph = AgentGraph.builder()
.addNode("analyse", analyst)
.nodeTimeout("analyse", Duration.ofSeconds(30)) // per-node
.defaultNodeTimeout(Duration.ofSeconds(15)) // graph-wide fallback
.build();
When the timeout fires, the node fails with a NodeTimeoutException which the FailureClassifier can classify as TRANSIENT (retry) or PERMANENT (abort).
Acceptance criteria
AgentGraph.BuilderacceptsnodeTimeout(String, Duration)anddefaultNodeTimeout(Duration)- Timeout fires a
NodeTimeoutException extends RuntimeException DefaultFailureClassifierclassifiesNodeTimeoutExceptionasTRANSIENTonNodeErrorlistener fires with the timeout exception- Unit test: node that sleeps beyond its timeout is aborted and classified correctly