Base Platform Adapter • AI Agent SDK
BasePlatformAdapter: Inheritable base class for gateway platform/channel adapters.
BasePlatformAdapter
Defined in the base module.
AI Agent
Inheritable base class for gateway platform/channel adapters.
Subclasses implement a minimal abstract contract (four methods) and inherit capability-driven default behaviour (chunking, retry/backoff, typing heartbeat, edit/delete fallbacks, formatting). Override any default only when the platform can do better.
The base also satisfies the runtime surface `Bot/BotOS drive (start / stop / send_message / probe / health) with defaults built on those primitives, so a minimal subclass runs under the gateway as-is. Bot builds adapters with token= / agent= / config= keyword arguments, so a subclass __init__` should accept them.
Declare platform features by setting the class attribute :attr:capabilities to a :class:PlatformCapabilities instance. The default delivery path reads capabilities via `getattr` so it degrades gracefully when a flag is absent.
Properties
PlatformCapabilitiesNo description available.
intNo description available.
floatNo description available.
boolNo description available.
Methods
Establish the platform connection.
disconnect()Tear down the platform connection and release resources.
send()Send a single message to chat_id (one API call, no chunking).
get_chat_info()Return metadata about a chat/channel (at least an `id` key).
Establish the connection and run the inbound loop until stopped.
stop()Signal the inbound loop to stop and tear down the connection.
send_message()Runtime send entry point (`Bot.send_message`).
Check connectivity/credentials without processing messages.
health()Report health. Default reflects the default run state and uptime.
canonicalize()Map a raw, potentially-volatile platform id to a stable canonical id.
max_message_length()Platform max message length (0 = unlimited).
supports_edit()Whether the platform supports in-place message edits.
supports_typing()Whether the platform supports typing indicators.
supports_delete()Whether the platform supports deleting a sent message.
format_message()Render text for the platform’s declared `markdown_dialect`.
Split text to respect the platform max length.
send_typing()Send a typing indicator. Default no-op unless capability set.
edit_message()Edit an existing message.
delete_message()Delete a previously sent message.
classify_error()Map a native send exception into a classified :class:SendResult.
Robustly deliver content, inheriting all shared machinery.
Source
View on GitHubpraisonaiagents/bots/base.py at line 466