Skip to content

Context Configuration Context

Configure conversation context management.

Overview

Context determines how much conversation history AI remembers.

Basic Configuration

yaml
context:
  maxMessages: 20          # Max messages in context
  maxTokens: 8000          # Max tokens in context
  cleaningStrategy: sliding # sliding, truncate, smart

Configuration Options

OptionTypeDefaultDescription
maxMessagesnumber20Max messages kept
maxTokensnumber8000Max tokens in context
cleaningStrategystringslidingHow to trim context
includeSystemPromptbooleantrueInclude system prompt
summarizeOldbooleanfalseSummarize old messages

Cleaning Strategies

sliding

Removes oldest messages when limit reached.

[msg1, msg2, msg3, msg4, msg5] + new_msg
→ [msg2, msg3, msg4, msg5, new_msg]

truncate

Clears all context when limit reached.

[msg1, msg2, msg3, msg4, msg5] + new_msg (limit reached)
→ [new_msg]

smart

Summarizes old messages instead of removing.

[msg1, msg2, msg3, msg4, msg5] + new_msg
→ [summary_of_1-3, msg4, msg5, new_msg]

Per-Group Context

yaml
groups:
  123456789:
    context:
      maxMessages: 50      # Higher limit for this group
      cleaningStrategy: smart

Context Commands

txt
#结束对话     # Clear current context
#上下文       # View context status

Token Optimization

Reduce Token Usage

  • Lower maxMessages for less context
  • Use shorter system prompts
  • Enable summarizeOld for long conversations
yaml
context:
  maxMessages: 10
  summarizeOld: true
  summaryMaxTokens: 500

API Access

javascript
// Get context
const ctx = await fetch('/api/conversations/123/context')

// Clear context
await fetch('/api/conversations/123/clear', { method: 'POST' })

Next Steps

Released under the MIT License