Skip to main content

Session Guide

Back to Guides

PicoClaw sessions decide which messages share the same conversation history. If your bot "remembers too much" or "forgets too much", the first thing to check is the session configuration.

This guide is for users configuring session behavior in config.json. For implementation details, see the architecture docs instead.

The optional seahorse context manager adds a SQLite index, multi-level summaries, and retrieval tools on top of the JSONL history. Its behavior, configuration, and limits are documented in Seahorse Memory.

What Sessions Control​

A session controls:

  • which previous messages are visible to the agent
  • when summarization starts for that conversation
  • whether two users in the same group share context
  • whether different chats, threads, or spaces stay isolated

Session data is stored under your workspace, typically:

~/.picoclaw/workspace/sessions/

Quick Start​

Default: one context per chat​

This is the default and is the right choice for most bots.

{
"session": {
"dimensions": ["chat"]
}
}

Use this when:

  • each group/channel should have its own shared memory
  • each direct message should have its own separate memory

Separate each user inside a group​

If users in the same group should not share memory, add sender:

{
"session": {
"dimensions": ["chat", "sender"]
}
}

Use this when:

  • one shared assistant sits in a busy group
  • each user should keep a private thread of context even inside the same room

Share one context across multiple rooms in the same workspace or guild​

If your channel exposes a space value, you can route by workspace or guild instead of by room:

{
"session": {
"dimensions": ["space"]
}
}

Use this when:

  • a Slack workspace assistant should share context across channels
  • a Discord guild assistant should share context across channels

Split by thread or forum topic​

If your channel exposes topic, you can isolate per thread:

{
"session": {
"dimensions": ["chat", "topic"]
}
}

Use this when:

  • each forum topic should keep its own history
  • each threaded discussion should stay separate

Available Dimensions​

DimensionWhat it meansGood for
spaceWorkspace, guild, or similar top-level containerOne shared assistant across many rooms
chatDirect chat, group, or channelDefault per-room isolation
topicThread, topic, or forum sub-channelKeep threaded discussions separate
senderThe message sender after normalizationPer-user context inside shared rooms

Not every channel provides every field. If a channel does not supply space or topic, those dimensions simply have no effect for that message.

Important Behavior​

Sessions are always separated by agent​

Even if two agents receive messages from the same chat, they do not share one session.

Sessions are still separated by channel and account​

session.dimensions adds finer-grained isolation, but PicoClaw still keeps a baseline separation by:

  • agent
  • channel
  • account

That means an empty or very small dimensions list does not create one global memory across every platform.

Telegram forum topics already stay isolated in the default chat mode​

Telegram forum messages keep topic isolation by default even when dimensions only contains chat. You usually do not need a special workaround for Telegram forums.

Summaries happen per session​

summarize_token_percent applies inside each session independently: summarization starts once the prompt (system prompt, summary, history and tool definitions) reaches that percentage of the usable context window (context_window - max_tokens). The number of messages does not matter. The check runs right before every LLM call, including in the middle of a long tool loop, and the turn waits for the summary before continuing from the compacted context. If you create smaller sessions, each one stays further from the threshold. summarize_message_threshold is deprecated and ignored.

The legacy context manager also protects a head and a tail instead of keeping only the last four messages:

  • protect_first_n (default 1) keeps the first conversation messages verbatim; the opening user instruction is never summarized. 0 disables head protection.
  • protect_last_n (default 4) is the minimum number of trailing messages kept verbatim. The token budget can keep more. 0 disables the count floor.
  • min_tail_user_messages (default 1) guarantees at least that many real user messages in the tail. 0 disables the guarantee.
  • tail_token_budget (default auto) walks the tail backwards by estimated tokens. Auto is 10% of the usable window (context_window - max_tokens), clamped to 2,000-32,000 and to half the window. Set an explicit token count to override it, or 0 to disable the token budget and keep only the message/user-message floors.

These values live under agents.defaults and can also be set with the matching PICOCLAW_AGENTS_DEFAULTS_* environment variables. A larger head/tail keeps more context verbatim and leaves less to summarize; a too-large tail can prevent compaction on short sessions. The cut is always aligned to a Turn boundary, so when the only safe boundary is later than the target the kept tail can be shorter than protect_last_n. If the protected tail itself is over budget, old tool outputs inside it are archived under <workspace>/.artifacts/evicted/ and replaced by a stub pointing at the file, so a single huge tool result does not force the whole conversation to be dropped. This is best effort: only tool results large enough to prune are candidates, and a tail made of user/assistant messages can stay above the budget.

Compact a session on demand​

Summarization normally starts by itself, but you can trigger it from any chat channel with /compact:

/compact
/compact --force
/compact focus on database migration
/compact --force focus on database migration

/compact summarizes the older part of the current session right away and keeps the most recent messages. Any text after the command is passed to the summarizer as a hint about which details to preserve. The command works with both the legacy and seahorse context managers and only affects the session it is sent in. With Seahorse, /compact runs one leaf pass and the condensed loop synchronously; see Seahorse Memory for the exact sequence and its edge cases.

By default the manual command is budget-aware: if the session is already within the compaction target, PicoClaw replies with the measured history tokens and target, for example Context already within the compaction target (3300/3327 history tokens). No new summary was needed. Use /compact --force to compact anyway. Replies are specific for a conversation that is too short, no compactable history, or a compaction already running. Use /compact --force to ignore the target and run leaf plus condensed compaction anyway. On success the reply reports the created summaries and the history-token change when available. With the legacy manager, if an automatic summarization of the same session is already running, /compact reports that instead of starting a second one. With Seahorse, a running background condensed loop is reported as A compaction is already running. Try again shortly.

Common Recipes​

One shared assistant per group or direct chat​

{
"session": {
"dimensions": ["chat"]
}
}

One context per user inside each chat​

{
"session": {
"dimensions": ["chat", "sender"]
}
}

One context per sender across one workspace or guild​

{
"session": {
"dimensions": ["space", "sender"]
}
}

This is useful for workspace-wide assistants where each user should keep their own memory while moving across rooms in the same workspace.

Use a different session policy for one routed agent only​

You can keep the global default and override it for one dispatch rule:

{
"agents": {
"list": [
{ "id": "main", "default": true },
{ "id": "support" }
],
"dispatch": {
"rules": [
{
"name": "support group",
"agent": "support",
"when": {
"channel": "telegram",
"chat": "group:-1001234567890"
},
"session_dimensions": ["chat", "sender"]
}
]
}
},
"session": {
"dimensions": ["chat"]
}
}

In this example:

  • most traffic uses one shared context per chat
  • the support group uses one context per user inside that chat

session.identity_links helps when the same user may appear under multiple raw sender IDs and you want PicoClaw to treat them as one sender identity.

Example:

{
"session": {
"dimensions": ["chat", "sender"],
"identity_links": {
"john": ["slack:u123", "u123", "legacy-user-42"]
}
}
}

This is mainly useful for:

  • migrated sender IDs
  • platform-specific ID aliases
  • cleanup after changing channel adapters or account naming

Current limitation:

  • identity_links does not make one user share memory across different channels automatically
  • channel and account remain part of the baseline session scope

Troubleshooting​

Users in one group are sharing memory​

Your current session is probably keyed only by chat. Switch to:

{
"session": {
"dimensions": ["chat", "sender"]
}
}

The same user does not share memory across Slack and Telegram​

That is expected. PicoClaw still separates sessions by channel even if you use sender.

Threads are mixing together​

Add topic when the channel provides one:

{
"session": {
"dimensions": ["chat", "topic"]
}
}

Old sessions seem to use legacy keys​

That is normal during migration. PicoClaw keeps compatibility with older agent:... session keys while moving runtime storage to opaque canonical keys.