Sessions & Memory
Trace An Answer Back To Its Source
- Open Memory.
- Search for the decision, customer, project, or result.
- Open a matching source to see the cited evidence.
- Open Sessions when you need the full conversation and tool history.

Sessions
How Sessions Work
Every conversation with an agent happens in a session. Sessions are identified by keys that encode the context, which agent, which channel, which chat.
Sessions maintain a complete transcript (append-only JSONL) of all messages, tool calls, and results. This transcript is what gives agents context about the ongoing conversation.
Session Keys
Sessions are routed automatically based on context:
| Pattern | Meaning |
|---|
agent:main:main | Main direct conversation |
agent:<id>:<channel>:group:<id> | Group chat on a specific channel |
agent:<id>:<channel>:channel:<id> | Channel/room conversation |
cron:<jobId> | Scheduled job execution |
hook:<uuid> | Webhook-triggered execution |
Session Lifecycle
- Your conversations keep going: A conversation with a person (a direct chat, a group or a channel) never resets on a timer unless you set one up. It continues until you start over or delete it.
- Optional daily or idle reset: If you choose, you can configure a daily hour or a period without activity as a boundary. When a chat in the app crosses it, Neotask compacts the chat in place after your next message, so the thread stays. Other conversations start a fresh session at the boundary, and the old transcript is archived.
- Background sessions reset daily: Sessions the system runs for itself, such as scheduled jobs, approvals and planners, start a fresh session each day at 4 AM local time by default.
- Manual reset: Start fresh anytime with a
/new or /reset command.
Token Tracking
Sessions track cumulative token usage (input, output, cache read, cache write) for cost monitoring and context window management.
Compaction
What Is Compaction?
When a conversation approaches the model's context window limit, Neotask compacts it, summarizing older messages into a condensed overview and continuing with that summary plus recent messages.
How It Works
- Detection: Neotask keeps a reserve of free room in the context window for the reply and tool output. The reserve is 20,000 tokens by default, or a larger reserve if one is configured. Compaction starts when the conversation fills the window to within the reserve plus a 4,000-token margin. On a small window, Neotask lowers the reserve and the margin so that at least 8,000 tokens, or half the window if that is smaller, stay available for the conversation.
- Summarization: Older messages are summarized into a compaction entry
- Recent messages kept: The conversation continues from the summary plus its most recent part, kept word for word (about 20,000 tokens by default)
- Preservation: Old transcripts are preserved for history but no longer loaded into context
Configuration
- Reserve: Tokens kept free for the reply and tool output, 20,000 by default. A larger reserve makes compaction start earlier
- Recent tokens kept: How much of the latest conversation stays word for word after compaction
- Summary instructions and model: Extra instructions for the summary, and an optional separate model to write it
Manual Compaction
You can trigger compaction manually at any time with the /compact command. This is useful when you want to reset context without losing important information.
Memory
Agent Memory
Each agent has a memory system for persisting important information across sessions:
- MEMORY.md: A markdown file in the agent's workspace where important facts, preferences, and context are stored
- Memory directory: Additional files in
memory/ for structured knowledge
Vector Search
The results table lists the evidence returned for a memory search. Open a result to inspect its source before relying on it in a session.

Neotask supports vector similarity search over agent memory:
- Indexing: Memory files are indexed using embeddings
- Search: Agents query memory with natural language ("What did the user say about their API preferences?")
- Recall: Relevant memories are returned ranked by similarity
Memory Plugin (LanceDB)
The LanceDB memory plugin provides advanced vector storage:
- Persistent vector database
- Configurable chunk size and overlap
- Efficient similarity search
- Automatic re-indexing when memory files change
Automatic Recall
At session start, relevant memories can be automatically recalled and injected into the agent's context. This gives agents continuity across sessions without loading entire conversation histories.
Session Persistence
All session data is stored locally:
- Session metadata:
sessions.json tracks active sessions, last activity, token counts, and config
- Transcripts: Individual session transcripts stored as
.jsonl files
- Recovery: Sessions survive Gateway restarts without data loss
Cleanup
- Your conversations with people are never removed by cleanup
- Background sessions not updated for a configurable period (default 30 days) are removed, and at most 500 of them are kept by default
- Manual session management is available through the UI or API
- Compacted transcripts are archived but can be reviewed