explain-error

A command that explains a PayPal API error, meaning a response from PayPal that says a request could not be completed.

In plain words
What is it for?
It helps interpret PayPal errors, add language-appropriate error handling, show a user-friendly message, decide whether retrying makes sense, and review related known errors.
Why use it?
It turns an error code or message into likely causes and concrete next steps, while warning when the error is unknown instead of presenting an unsupported explanation.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/paypal/ai-toolkit/explain-error
Clone the repo
git clone --depth 1 https://github.com/paypal/AI-Toolkit
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 702 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00013 $0.00702
Opus 5 $0.00006 $0.00351
Sonnet 5 $0.00003 $0.00140
Haiku 4.5 $0.00001 $0.00070

Measured 2d ago against content hash d35183b3f68a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

explain-error scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/explain-error.md · 37 lines

What it actually says

If "$ARGUMENTS" is empty, respond only with: "Please provide a PayPal error code or message. Example: /paypal:explain-error INSTRUMENT_DECLINED" and stop.

If "$ARGUMENTS" does not match any known PayPal error code or message pattern, respond with: "Unknown error code or message: $ARGUMENTS. This may be a typo, a third-party error, or a new PayPal error not yet in this reference. Check https://developer.paypal.com/api/rest/reference/orders/v2/errors/ for the full list." Then do your best to explain what the error string suggests based on its name, and stop — do not fabricate retry behavior or related errors.

Otherwise, explain the PayPal error "$ARGUMENTS". Provide:

  1. What it means — plain-language explanation
  2. Common causes — most likely reasons this occurs
  3. How to fix it — specific, actionable steps
  4. Code example — detect the user's programming language by scanning any open files with Read/Grep; default to Node.js if no language is found. Show proper error handling including how to catch the error, display a user-friendly message, and whether to retry.
  5. Related errors — only list errors from the Key error reference below that are meaningfully related (same HTTP status, same flow, or must be handled together). Do not suggest errors outside this list.

Key error reference:

  • INVALID_REQUEST (400) — malformed body or missing fields; inspect the details[] array for the specific field and issue
  • UNAUTHORIZED (401) — expired or missing access token; refresh via POST /v1/oauth2/token
  • NOT_AUTHORIZED (401) — valid token but missing scope for this operation
  • PERMISSION_DENIED (403) — account not eligible for this API; check Developer Dashboard feature eligibility
  • RESOURCE_NOT_FOUND (404) — resource ID does not exist or belongs to a different account
  • DUPLICATE_TRANSACTION (409) — idempotency key already succeeded; retrieve the existing resource instead
  • INSTRUMENT_DECLINED (422) — buyer's payment method declined; ask for a different payment method, do not retry the same instrument
  • TRANSACTION_REFUSED (422) — risk engine decline; do not retry automatically
  • ORDER_ALREADY_COMPLETED (422) — cannot capture/authorize an already-completed order
  • AMOUNT_MISMATCH (422) — captured amount doesn't match authorized amount
  • RATE_LIMIT_REACHED (429) — back off with exponential retry; honor the Retry-After header
  • INTERNAL_SERVER_ERROR (500) — retry with the same PayPal-Request-Id idempotency key; log debug_id
  • PLAN_STATUS_INVALID — plan must be ACTIVE before creating subscriptions
  • SUBSCRIPTION_STATUS_INVALID — subscription is not in a state that allows this operation

Always include the full error response body and debug_id when contacting PayPal support at https://developer.paypal.com/support/.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 37 lines · 13 tokens per session scan A d35183b3f68a

Subscribe to this mod's changes

explain-error is a command published in the GitHub repository paypal/AI-Toolkit (12 stars, last pushed 13d ago), licensed Apache-2.0. It adds 13 tokens to every session and 702 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.