Interface ICommitActionParams<T>

Configuration parameters for creating a commit action handler (WRITE pattern). Defines validation, action execution, and response messages for state-modifying operations.

The name of the current agent

  • Called when executeAction throws an exception
  • Error message is automatically committed as tool output and failureMessage is executed

Error message if validation fails, null if valid

Result string to commit as tool output (empty string if action produced no result)

"Action executed but produced no result"
// Payment action with validation and error handling
const paymentAction = createCommitAction({
fallback: (error, clientId, agentName) => {
console.error(`Payment action failed for ${clientId} (${agentName}):`, error);
},
validateParams: async ({ params, clientId, agentName, toolCalls }) => {
if (!params.bank_name) return "Bank name is required";
if (!params.amount) return "Amount is required";
return null; // Valid
},
executeAction: async (params, clientId) => {
await commitAppAction(clientId, "credit-payment", params);
return "Payment page opened successfully";
},
successMessage: "what is this page about",
failureMessage: "Could not open payment page",
});
interface ICommitActionParams<T = Record<string, any>> {
    emptyContent?: (
        params: T,
        clientId: string,
        agentName: string,
    ) => string | Promise<string>;
    executeAction: (
        params: T,
        clientId: string,
        agentName: string,
    ) => string | Promise<string>;
    failureMessage?:
        | string
        | (
            params: T,
            clientId: string,
            agentName: string,
        ) => string | Promise<string>;
    fallback?: (error: Error, clientId: string, agentName: string) => void;
    successMessage:
        | string
        | (
            params: T,
            clientId: string,
            agentName: string,
        ) => string | Promise<string>;
    validateParams?: (
        dto: {
            agentName: string;
            clientId: string;
            params: T;
            toolCalls: IToolCall[];
        },
    ) => string
    | Promise<string>;
}

Type Parameters

  • T = Record<string, any>

    The type of parameters expected by the action ICommitActionParams

Properties

emptyContent?: (
    params: T,
    clientId: string,
    agentName: string,
) => string | Promise<string>
executeAction: (
    params: T,
    clientId: string,
    agentName: string,
) => string | Promise<string>
failureMessage?:
    | string
    | (
        params: T,
        clientId: string,
        agentName: string,
    ) => string | Promise<string>

Optional message to execute using executeForce when validation fails

  • Can be static string or function that returns string
  • If function: receives (params, clientId, agentName) as arguments
  • If not provided: uses the validation error message instead
fallback?: (error: Error, clientId: string, agentName: string) => void
successMessage:
    | string
    | (
        params: T,
        clientId: string,
        agentName: string,
    ) => string | Promise<string>

Message to execute using executeForce after successful action

  • Can be static string or function that returns string
  • If function: receives (params, clientId, agentName) as arguments
validateParams?: (
    dto: {
        agentName: string;
        clientId: string;
        params: T;
        toolCalls: IToolCall[];
    },
) => string
| Promise<string>