Sessions & Memory

Sessions

Sessions कैसे काम करते हैं

एक agent के साथ हर conversation एक session में होती है। Sessions keys द्वारा identified होती हैं जो context encode करती हैं, कौन सा agent, कौन सा channel, कौन सा chat।

Sessions सभी messages, tool calls, और results का एक complete transcript (append-only JSONL) maintain करती हैं। यह transcript ही है जो agents को ongoing conversation के बारे में context देता है।

Session Keys

Sessions context के आधार पर automatically route होती हैं:

Pattern अर्थ
agent:main:main Main direct conversation
agent:<id>:<channel>:group:<id> Specific channel पर Group chat
agent:<id>:<channel>:channel:<id> Channel/room conversation
cron:<jobId> Scheduled job execution
hook:<uuid> Webhook-triggered execution

Session Lifecycle

Token Tracking

Sessions cumulative token usage (input, output, cache read, cache write) cost monitoring और context window management के लिए track करती हैं।


Compaction

Compaction क्या है?

जब एक conversation model के context window limit के करीब पहुंचती है, Neotask इसे compact करता है, पुराने messages को एक condensed overview में summarize करता है और उस summary plus recent messages के साथ एक new session शुरू करता है।

यह कैसे काम करता है

  1. Detection, Context usage monitor करें (default trigger: context window का 80%)
  2. Summarization, Older messages को एक compaction entry में summarize किया जाता है
  3. New session, Top पर summary inject के साथ एक fresh session शुरू होती है
  4. Preservation, Old transcripts history के लिए preserved हैं लेकिन अब context में load नहीं होते

Configuration

Manual Compaction

आप /compact command के साथ किसी भी समय compaction manually trigger कर सकते हैं। यह तब useful है जब आप important information खोए बिना context reset करना चाहते हैं।


Memory

Agent Memory

प्रत्येक agent के पास sessions में important information persist करने के लिए एक memory system है:

Neotask agent memory पर vector similarity search support करता है:

  1. Indexing, Memory files embeddings का उपयोग करके indexed होती हैं
  2. Search, Agents natural language के साथ memory query करते हैं ("User ने अपनी API preferences के बारे में क्या कहा था?")
  3. Recall, Relevant memories similarity द्वारा ranked return होती हैं

Memory Plugin (LanceDB)

LanceDB memory plugin advanced vector storage provide करता है:

Automatic Recall

Session start पर, relevant memories automatically recalled और agent के context में inject की जा सकती हैं। यह agents को entire conversation histories load किए बिना sessions में continuity देता है।


Session Persistence

सभी session data locally stored होता है:

Cleanup