Skip to main content
The gateway now ships in the praisonai-bot package. praisonai serve gateway still works exactly as documented here; for a standalone install see praisonai-bot Migration.
Gateway error handling automatically sanitises exception text to prevent encoding crashes while preserving meaningful error information for users.
The user sends a message that triggers an internal error; the gateway sanitises the exception to ASCII-safe text in the reply while logging full detail.

Quick Start

1

Simple Usage

Error handling is automatic โ€” no configuration needed. When agents throw exceptions containing Unicode characters, the gateway safely converts them for bot replies.
2

Test Error Handling

Verify your version includes Unicode-safe error handling:
If this runs without error, you have the fix from PR #1754.

How It Works

The gateway processes exceptions in three stages:
  1. Root-cause extraction โ€” identifies the underlying API error
  2. Unicode sanitization โ€” converts symbols to ASCII-safe equivalents
  3. Safe reply โ€” sends clean message to user via bot

Configuration Options

Error handling is automatic with no required configuration. The feature is included in PraisonAI versions containing PR #1754.

Gateway Error Handling Reference

Source implementation details in PraisonAI PR #1754

Structured Connection Errors

The hello handshake returns machine-readable ConnectErrorCode values (auth_required, auth_unauthorized, protocol_unsupported, pairing_required, agent_not_found) with optional next_action hints โ€” instead of free-text-only connection failures. Codes fall into two client-side classes: transient (rate_limited โ€” back off and retry) and terminal (auth_required, auth_unauthorized, pairing_required, protocol_unsupported, agent_not_found, origin_not_allowed, configuration_error โ€” reconnect loop stops until an operator intervenes). See Gateway Client โ†’ Terminal vs Transient Connect Errors for how GatewayClient handles each class and the on_reconnect_paused callback. See Gateway Handshake Protocol for the full error matrix and capability negotiation.

Reconnect After Disconnect

Pending inbox messages and in-flight executions are preserved when a WebSocket disconnects. On reconnect with the same session_id, the client receives a status frame:
Queued messages are processed in FIFO order. See Gateway Session Continuity for drain behaviour and persisted session shape.

Common Patterns

Recognized Error Types

The gateway automatically recognizes and formats these error patterns:

Symbol Replacements

Unicode symbols are replaced with ASCII equivalents: Accented letters (รก, รฉ, รฑ, etc.) are converted to their base forms (a, e, n).

Before vs After

Before PR #1754 (broken on Windows):
After PR #1754 (safe on all platforms):

Best Practices

Full Unicode exception details are preserved in gateway logs for debugging while users see clean ASCII-safe messages.
Set up billing alerts and monitor usage to prevent quota exceeded errors:
The Unicode-safe error handling works on Windows, macOS, and Linux:
No workaround needed on supported versions. Previously recommended environment variables (PYTHONUTF8=1) are no longer required for the bot reply path.

Gateway Troubleshooting

Troubleshoot Windows charmap errors and other gateway issues

Bot Gateway

Configure multiple bots with the gateway server