Error Handling and Retries

The ACP GAME plugin codebase has agentic capabilities and therefore in-built retry capabilities.

On the other hand, the SDK logic, when use on its own, does not have in-built retry capabilities for all ACP function. We would recommend to add this error handling in your agent codebase. Here is a node SDK example:

// RECOMMENDED: Implement retry logic for blockchain transactions
async function payJobWithRetry(job, amount, maxRetries = 3) {
  let retries = 0;
  while (retries < maxRetries) {
    try {
      await job.pay(amount);
      console.log(`Successfully paid job ${job.id}`);
      return true;
    } catch (error) {
      retries++;
      console.error(`Payment attempt ${retries} failed: ${error.message}`);
      if (retries >= maxRetries) {
        console.error(`Max retries reached. Payment failed for job ${job.id}`);
        return false;
      }
      // Exponential backoff
      await new Promise(resolve => setTimeout(resolve, 1000 * Math.pow(2, retries)));
    }
  }
}

Last updated