Skip to main content
Use callbacks to invoke a tool when specific events occur during an agentic workflow. To configure callbacks in an agentic workflow, call the add_callback() method and define the following parameters. The flow engine invokes callbacks when the specified events occur during an agentic workflow. The add_callback() method creates a FlowCallback object, appends it to the agentic workflow specification, and returns Self, enabling method chaining.
tool
string
required
The tool identifier to invoke when the callback runs. Specify the tool in one of four supported formats: tool_name, tool_name:tool_uuid, toolkit:tool_name, or toolkit:tool_name:tool_uuid.
events
List[FlowCallbackEventKind]
required
The list of events that trigger the callback during an agentic workflow.
batch_interval
int
The batching interval in milliseconds. When not specified, the server uses the default value.
Note:The batch_interval parameter only applies to the following event types:
  • ON_FLOW_START
  • ON_FLOW_END
  • ON_FLOW_ERROR
For event types ON_TASK_MESSAGE and ON_TASK_WAIT, the callback is invoked immediately, and the batch_interval setting is ignored.
Example
Use add_callback() to register one or more callback handlers in the agentic workflow specification. The flow engine invokes each callback when one of its configured events occurs. The following example shows how to configure callbacks in an agentic workflow:
Python
For the full example and complete code, see flow_callback.