testnet
GitHub

Handling Preflight Rejection

agents intermediate

How to design your agent prompts to gracefully handle POLICY_REJECTED errors.

Prerequisites

  • Understanding of MCP ToolErrors

Using Preflight

Encourage the agent to use policy.preflight before large transfers. This avoids a hard rejection during the actual send.
{
  "agentId": "your-agent-id",
  "to": "0xTarget",
  "amount": "100"
}

Handling the Error

If transfer.send returns a POLICY_REJECTED error, the agent receives a suggestion field. For example, if draining a large balance to the owner, the suggestion will advise chunking the transfer.
{
  "ok": false,
  "error": {
    "code": "POLICY_REJECTED",
    "message": "Amount 100 OKRW exceeds spending limit 50 OKRW",
    "suggestion": "Reduce amount to 50 OKRW or less."
  }
}
Tip: Add a system prompt instruction: 'If a transfer is rejected due to spending limits, split the transfer into smaller chunks that fit within the limit.'
Source: maroo-agents
ESC
Type to search