Docs / Developers / Memory model

Memory model

CloudyBot keeps context in layers so integrators can reason about what persists, what summarizes, and what resets. Memory is scoped to thread_id — not global per user. User guide: threads & memory. System context: architecture.

Three storage layers

Billing (AI credits, browser minutes) is per userId; conversation memory is per threadId.

What the model sees each turn

Typical prompt assembly order:

  1. Base system instructions and model identity hint.
  2. Pinned block (if any keys exist for the thread).
  3. Specialist persona / duty instructions (when applicable).
  4. Conversation summary (if present).
  5. Browser and session-rotation hints when relevant.
  6. Recent message list — last five turns from messages, trimmed under MAX_CONTEXT with the system block.

Saved browser credentials are appended to the system prompt at chat time; they are not stored in the visible message transcript.

Summarization

After an assistant reply, if stored messages.length >= 10, the API summarizes older turns and keeps only the last 5 in messages. Older content moves into summary. Summarization itself consumes AI credits like any other turn.

The UI still reads display_messages for full scrollback until plan retention purges the thread row. See data & privacy for retention days by tier.

Session rotation (OpenClaw)

The gateway session file may be cleared when:

Rotation does not delete SQLite rolling memory — only the OpenClaw-side tool state. rotateSessionIfNeeded(userId, threadId) runs before outbound agent calls.

Integrator implications

Instruction layers (product vs user data)

Related: API reference · repo docs/CONVERSATION-MEMORY-BIG-PICTURE.md · api/features/conversation/conversation-store.js