WebSocket subscriptions
Shipped in v3-alpha (Beta) at GET /v1/memory/ws. Interfaces may still change
before 3.0 stable.
Endpoint
ws://your-host/v1/memory/wsAuthentication
Pass the API key as a token query parameter on the upgrade request:
ws://your-host/v1/memory/ws?token=mns_live_xxxSubscription protocol
interface WsSubscription {
subscribe: {
channel:
| "facts.*" // all fact events
| "facts.created" // new facts only
| "tasks.*" // task state changes
| "events.*" // new events
| "session.{id}" // session updates
| "agent.{id}.recall" // what an agent is recalling
| "health" // health metric updates
| "federation.sync"; // cross-instance syncs
filter?: {
entityId?: string;
agentId?: string;
memoryType?: string;
};
};
}Server-pushed events
interface WsEvent {
channel: string;
type:
| "fact.created" | "fact.updated" | "fact.archived"
| "task.created" | "task.transitioned" | "task.completed"
| "event.recorded" | "recall.hit" | "session.collapsed"
| "health.alert" | "federation.conflict";
payload: unknown;
timestamp: string;
traceId: string;
}Use cases
- Agent B watches for tasks delegated to it —
tasks.*filtered byassignedTo - Plugin reacts to new facts —
facts.created - Dashboard shows real-time recall latency —
agent.*.recall - Federation peer sync —
federation.sync
Backpressure & rate limiting
- Per-connection: max 100 subscriptions
- Ring buffer drops the oldest events under load; a slow consumer is closed
with code
1013 - Disconnect check runs every 30s
See also
- Tasks & events — produces most ws events
- Federation — uses ws for peer sync
- gRPC streaming — alternative bidirectional transport