Creates a commit action handler that executes actions and modifies system state (WRITE pattern).
Execution flow:
If validation, action execution, commit, or execution operations fail
// Create payment handler with error handlingconst handlePayment = createCommitAction({ fallback: (error, clientId, agentName) => { logger.error("Payment execution failed", { error, clientId, agentName }); }, validateParams: async ({ params, clientId, agentName, toolCalls }) => { if (!params.amount) return "Amount is required"; return null; }, executeAction: async (params, clientId) => { await commitAppAction(clientId, "payment", params); return "Payment processed successfully"; }, emptyContent: () => "Payment failed - no result", successMessage: "Check your balance", failureMessage: "Payment validation failed",});// Usage: called internally by addCommitActionawait handlePayment("tool-123", "client-456", "PaymentAgent", "pay", { amount: 100 }, [], true); Copy
// Create payment handler with error handlingconst handlePayment = createCommitAction({ fallback: (error, clientId, agentName) => { logger.error("Payment execution failed", { error, clientId, agentName }); }, validateParams: async ({ params, clientId, agentName, toolCalls }) => { if (!params.amount) return "Amount is required"; return null; }, executeAction: async (params, clientId) => { await commitAppAction(clientId, "payment", params); return "Payment processed successfully"; }, emptyContent: () => "Payment failed - no result", successMessage: "Check your balance", failureMessage: "Payment validation failed",});// Usage: called internally by addCommitActionawait handlePayment("tool-123", "client-456", "PaymentAgent", "pay", { amount: 100 }, [], true);
The type of parameters expected by the action
Configuration object
Handler function that executes the action with validation
Creates a commit action handler that executes actions and modifies system state (WRITE pattern).
Execution flow:
Throws
If validation, action execution, commit, or execution operations fail
Example