agentflow4j
agentflow4j copied to clipboard
AgentListener: add onCheckpoint and onApprovalRequest lifecycle events
Problem
AgentListener currently covers node enter/exit/error and graph complete. Two production-critical events are missing:
onCheckpoint(String graphName, String nodeName, AgentContext context)— fired each time the runtime persists a checkpoint. Useful for audit logging and observability.onApprovalRequest(String graphName, String nodeName, ApprovalRequest request)— fired when anApprovalGatepauses execution. Needed to trigger downstream notifications (Slack, email, webhook) without coupling gate logic to notification code.
Current state
public interface AgentListener {
default void onNodeEnter(...) {}
default void onNodeExit(...) {}
default void onNodeError(...) {}
default void onTransition(...) {}
default void onGraphComplete(...) {}
}
No hook for checkpoint or approval events.
Proposed addition
default void onCheckpoint(String graphName, String nodeName, AgentContext context) {}
default void onApprovalRequest(String graphName, String nodeName, ApprovalRequest request) {}
Acceptance criteria
- Both methods have default no-op implementations (non-breaking)
MicrometerAgentListenerrecords a checkpoint counter metric- At least one test verifies the hooks fire at the right moment
- Javadoc explains when each fires and what the parameters contain