Action
uncanny-automator
automator_llm_action_error
Fires when an error occurs during an Automator LLM action, providing error message, action data, and user ID.
add_action( 'automator_llm_action_error', $callback, 10, 3 );
Description
Fires when an error occurs during an LLM-driven action within Automator recipes. Developers can use this hook to log errors, trigger notifications, or perform alternative error handling for LLM-generated actions, bypassing standard recipe logging. It provides the error message, action data, and user ID involved.
Usage
add_action( 'automator_llm_action_error', 'your_function_name', 10, 3 );
Parameters
-
$error_message(mixed) - This parameter contains the error message string generated during an action's execution within the Automator plugin, specifically when an error occurs during an LLM or agent-related process.
-
$action_data(mixed) - This parameter contains the error message generated during the execution of an action within the Automator plugin.
-
$user_id(mixed) - This parameter contains the data associated with the action that encountered the error.
Examples
<?php
/**
* Handles errors originating from LLM/Agent actions within the Automator plugin.
*
* This function logs the error message and related action data to the WordPress
* debug log, helping developers identify and resolve issues with LLM integrations.
*
* @param mixed $error_message The specific error message encountered.
* @param mixed $action_data An array containing data about the action that failed.
* @param mixed $user_id The ID of the user associated with the action.
*/
function my_automator_llm_action_error_handler( $error_message, $action_data, $user_id ) {
// Ensure WP_DEBUG is enabled to see these logs.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( sprintf(
'Automator LLM Action Error: %s. Action Data: %s. User ID: %s',
print_r( $error_message, true ),
print_r( $action_data, true ),
$user_id
) );
}
// In a real-world scenario, you might want to trigger a notification
// to an administrator or queue a retry mechanism for the action.
// For this example, we're just logging the error.
}
add_action( 'automator_llm_action_error', 'my_automator_llm_action_error_handler', 10, 3 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/lib/process/class-automator-recipe-process-complete.php:540
if ( is_null( $user_id ) ) {
$user_id = get_current_user_id();
}
// LLM/Agent mode - skip recipe logging, just capture error.
if ( ! empty( $action_data['from_llm'] ) ) {
if ( ! empty( $error_message ) ) {
do_action( 'automator_llm_action_error', $error_message, $action_data, $user_id );
}
return ! empty( $error_message ) ? false : true;
}
$action_id = (int) $action_data['ID'];
if ( null === $action_id || ! is_numeric( $action_id ) ) {
Internal Usage
Found in src/api/application/sub_tooling/class-action-executor.php:438:
add_action( 'automator_llm_action_error', $error_capture, 10, 2 );