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.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, your install includes the ASCII-safe error sanitizer (originally PraisonAI PR #1754; extended in PR #3430 to strip box-drawing frame characters).
How It Works
The gateway processes exceptions in three stages:- Root-cause extraction โ identifies the underlying API error
- Unicode sanitization โ converts symbols to ASCII-safe equivalents
- Safe reply โ sends clean message to user via bot
Related Helpers
Theunicode_utils module exports two sibling helpers alongside safe_error_message.
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
Thehello 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.
Structured turn-failure error (wire)
The Unicode sanitiser protects chat-reply text; the typedoutcome.error on the final response frame protects programmatic clients (operator UIs, OpenAI-compat consumers, custom bots).
The end-user text comes from a fixed per-code table (_TURN_ERROR_MESSAGES), never str(e). See Gateway Turn Error Codes for the full code vocabulary.
Reconnect After Disconnect
Pending inbox messages and in-flight executions are preserved when a WebSocket disconnects. On reconnect with the samesession_id, the client receives a status frame:
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):? placeholders around the frame on Windows cp1252):
Best Practices
Monitor Gateway Logs
Monitor Gateway Logs
Full Unicode exception details are preserved in gateway logs for debugging while users see clean ASCII-safe messages.
Handle API Quota Limits
Handle API Quota Limits
Set up billing alerts and monitor usage to prevent quota exceeded errors:
Test Cross-Platform Compatibility
Test Cross-Platform Compatibility
The Unicode-safe error handling works on Windows, macOS, and Linux:
Upgrade Legacy Environments
Upgrade Legacy Environments
No workaround needed on supported versions. Previously recommended environment variables (
PYTHONUTF8=1) are no longer required for the bot reply path.Related
Gateway Troubleshooting
Troubleshoot Windows charmap errors and other gateway issues
Bot Gateway
Configure multiple bots with the gateway server
Turn Error Codes
Typed
outcome.error on failed turnsUser-facing reply for a failed agent turn, keyed by failure class

