Building a Multi-Platform AI Assistant: Architecture and Engineering Practices
This article explains how to evolve a single-entry conversational assistant into one instance that serves multiple platforms and multiple users. It covers a five-layer architecture, message normalization, context isolation using tenant, channel, and conversation namespaces, layered memory and preference design, and unified governance for security, compliance, and observability. It also outlines cloud deployment options, common pitfalls, and an acceptance checklist for adding new channels safely.
1. Why a Single Instance Must Serve Multiple Platforms and Users
Early conversational assistants were usually tied to a single entry point: one deployment mapped to one chat window. As usage expanded from work collaboration to daily household routines, the single-entry model exposed three problems. Fragmented entry points raised the barrier to adoption; contexts from different scenarios mixed together, so response styles contaminated one another; and when family members shared one entry point, individual preferences were overwritten. The fix is to decouple the entry point from the capabilities, letting one assistant instance handle multiple platforms while maintaining logically separate conversation spaces.
2. Abstracting the Required Capabilities
Setting aside specific products, this type of system generally needs four common capabilities:
- Multi-channel access: an adapter pattern hides protocol differences across platforms.
- Session isolation: contexts never leak between platforms or between conversation parties.
- Long-term memory and preferences: persisted per subject, and searchable, updatable, and deletable.
- Unified governance: authentication, permissions, rate limiting, auditing, and observability managed centrally.
3. Layered Architecture
A five-layer design is recommended. The access layer handles protocol adaptation and message normalization. The gateway layer handles authentication, rate limiting, deduplication, and routing. The session layer maintains short-term context and the state machine. The capability layer hosts model calls, retrieval, and tool execution. The data layer stores sessions, memories, and audit logs. The key benefit of layering is that adding a platform requires only a new adapter, with no changes to the capability layer.
An example of a normalized message structure:
{"channel": "chat","tenant_id": "family_member_a","conversation_id": "c-10231","sender_id": "u-88","content_type": "text","payload": {"text": "Summarize this document for me"},"timestamp": 1730000000}
4. Engineering Key Points for Multi-Platform Access
Platforms differ significantly in message formats, authentication methods, callback retries, and rich media support. Three practices matter most. First, define a minimal capability set such as send, edit, reply, and upload, and fall back to plain text when a capability is missing. Second, make every callback idempotent, deduplicating by the platform’s unique message identifier so retries do not produce duplicate responses. Third, keep platform-side keys in a configuration center or a key management service, never in the code repository. Maintain an integration matrix in a table that lists the message types and rate-limit thresholds supported by each channel.
5. Context Isolation Strategy
Isolation belongs in the session layer, not in the prompt. Use a tenant + platform + conversation triple as the namespace key, store and retrieve short-term context by that key, and enforce a turn limit plus timeout-based eviction. Knowledge shared across subjects enters a public knowledge area only through explicit authorization, not by default. The example below shows reading and writing context by namespace:
def ns_key(tenant, channel, conversation):return f"{tenant}:{channel}:{conversation}"def load_context(store, key, max_turns=20, ttl=1800):ctx = store.get(key) or []return ctx[-max_turns:] if store.alive(key, ttl) else []
6. Layered Memory and Preference Design
Split memory into three layers: short-term session memory, long-term subject preferences, and public knowledge. Store long-term preferences with a hybrid of structured fields and vector retrieval. Writes must go through confirmation, and reads must be filtered by subject identifier. The system must provide forgetting and export capabilities to satisfy data subject rights, and sensitive fields must be masked and stored encrypted. When preferences conflict, explicit configuration takes priority over automatic inference.
7. Security, Compliance, and Observability
Perform identity verification and permission checks at the gateway, and set data boundaries per subject. Record audit logs across the full chain, including the subject, channel, session, and tool calls. Execute external tools with a whitelist and least privilege. Build a unified observability system combining metrics, logs, and traces, with alerts on response latency, failure rate, and rate-limit triggers.
8. Cloud Deployment Recommendations
General cloud services can carry the workload: a message queue for peak shaving and asynchronous retries, object storage for rich media, a container platform for stateless adapters, log services and monitoring alerts for operations, and a key management service for credentials. If you use the relevant general capabilities from Baidu AI Cloud, the same layering and isolation principles apply.
9. Common Pitfalls and an Acceptance Checklist
Common pitfalls include relying on prompts for isolation, sharing a single memory store, skipping callback idempotency, and logging full response bodies. The acceptance checklist: adding a platform requires zero changes to the capability layer; cross-subject questions cannot retrieve another subject’s preferences; a deletion request completely removes the memory; and rate limiting and fallback can be drilled. Following this approach, a multi-platform, multi-member assistant can run stably at a controlled cost.
