Skip to main content

Overview

When a charge fails, the SDK returns an error to the agent instead of executing the tool. You can customize these messages to help agents resolve issues.

Error Types

Error Verbosity

Control how detailed error messages are:

Detailed Errors (default)

Concise Errors

Provider Name

Set providerName to identify your service in error messages:
Error message:
Without providerName, errors say “The provider has enabled…”.

Fail Open vs Fail Closed

What happens when Payo is unavailable?

Fail Closed (default)

If Payo is down, tools return PLATFORM_UNAVAILABLE. Agents can’t use paid tools, but you don’t give away free calls.

Fail Open

If Payo is down, tools execute without charging. Agents can still use your tools, but you lose revenue during outages.
failOpen: true means you provide free service during Payo outages. Only use this if availability is more important than revenue.

Catching Errors in Your Tools

The SDK handles payment errors before your tool runs. But if your tool itself throws an error, it passes through normally:

Custom Error Handling

For advanced use cases, catch PaymentError in your server:

Logging Errors

Enable debug logging to see error details:
Log levels:
  • DEBUG - Everything
  • INFO - Charges and important events
  • WARN - Warnings (missing tokens with failOpen)
  • ERROR - Errors only
  • NONE - Silent

Example: Complete Configuration

Agent Experience

Design your error handling with agents in mind:
Errors should tell agents exactly what to do: “Get a token at…”, “Deposit funds at…”.
Always mention the tool’s price so agents know the cost.
Include how to get help for persistent issues.
Error messages shouldn’t expose your implementation details or API key status.