Documentation
¶
Overview ¶
Context Guard Example
This example shows the three ways to configure the ContextGuard plugin:
- CrushRegistry — automatic context window detection from Crush's provider.json (refreshes every 6h, zero config).
- WithMaxTokens — manual context window override, useful when using beta features like Anthropic's 1M context window.
- WithSlidingWindow — turn-count-based compaction instead of token-threshold-based.
The example uses the CrushRegistry with the threshold strategy by default. Set STRATEGY=sliding_window to try the sliding window, or set MAX_TOKENS to override the context window manually.
Environment variables:
ANTHROPIC_API_KEY - Anthropic API key (required) MODEL_NAME - Model to use (default: claude-sonnet-4-5-20250929) STRATEGY - "threshold" (default) or "sliding_window" MAX_TOKENS - Manual context window override in tokens (threshold only) MAX_TURNS - Max turns before compaction (sliding_window only, default: 20)
Click to show internal directories.
Click to hide internal directories.