/context commands in the terminal to show, compact, or budget the active session.
How It Works
Quick Start
Interactive Commands
Use these commands inpraisonai chat or praisonai code interactive mode.
/context
Show context summary and statistics./context show
Alias for/context. Shows summary view.
/context stats
Show detailed token ledger by segment./context budget
Show budget allocation details./context dump
Write context snapshot to disk immediately./context on
Enable context monitoring./context off
Disable context monitoring./context path <path>
Set monitor output path./context format <human|json>
Set monitor output format./context frequency <turn|tool_call|manual|overflow>
Set monitor update frequency.| Frequency | Description |
|---|---|
turn | Write after each turn (default) |
tool_call | Write after each tool call |
manual | Only write on /context dump |
overflow | Write when approaching limit |
/context compact
Trigger manual context optimization./context history
Show optimization event history./context config
Show resolved configuration with precedence info.CLI Flags
Use these flags when startingpraisonai chat or praisonai code.
Auto-Compaction
Strategy
smart, truncate, sliding_window, summarize, prune_tools
Threshold
Monitoring
Redaction
Output Reserve
Estimation Mode
heuristic, accurate, validated
Mismatch Logging
Snapshot Timing
pre_optimization, post_optimization, both
Write Mode
sync, async
Show Config
Environment Variables
config.yaml
Precedence
Configuration is resolved in this order (highest to lowest):- CLI flags -
--context-*flags - Environment variables -
PRAISONAI_CONTEXT_* - config.yaml -
context:section - Defaults - Built-in defaults
Troubleshooting
Context overflow errors
Monitor not updating
Sensitive data in snapshots
Best Practices
Monitor Context Usage Regularly
Monitor Context Usage Regularly
Run
/context stats at the start of long sessions to understand your token budget before it fills up. Proactive monitoring prevents unexpected compaction mid-task.Set Threshold Below 90%
Set Threshold Below 90%
Use
--context-threshold 0.8 (80%) rather than the default. This leaves enough headroom for the compaction response itself without triggering at the very last moment.Use Compact Strategy for Long Sessions
Use Compact Strategy for Long Sessions
The
compact strategy summarizes old turns intelligently. Use truncate only when you need to preserve exact recent messages and can afford to lose early conversation history.Enable Redaction for Sensitive Data
Enable Redaction for Sensitive Data
Always pass
--context-redact when your conversations may contain API keys, passwords, or PII. Redaction patterns are applied before any snapshot is written to disk.Related
Context Compression
Automatic context window management and compaction
Context Budgeter
Configure token budget allocation per segment

