context-guard

command
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Context Guard Example

This example shows the three ways to configure the ContextGuard plugin:

  1. CrushRegistry — automatic context window detection from Crush's provider.json (refreshes every 6h, zero config).
  2. WithMaxTokens — manual context window override, useful when using beta features like Anthropic's 1M context window.
  3. 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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL