Adds a globalContextLimit setting that overrides every model's contextWindow, so all models behave as if they have the configured limit regardless of their native context size.
Different models have different context windows (Claude: 200K, GPT-4o: 128K, MiniMax M3: 1M). If you want consistent behavior across all models, or want to limit token usage, this extension caps all models to a single limit.
Add to ~/.pi/agent/settings.json:
{
"globalContextLimit": 200000
}- On model selection, the extension caps
model.contextWindowto the configured limit - On session start, the current model is capped
- The
/context-limitcommand lets you view or change the limit at runtime
| Command | Description |
|---|---|
/context-limit |
Show current limit |
/context-limit 100000 |
Set limit to 100K tokens |
Compaction triggers when contextTokens > contextWindow - reserveTokens. With a global limit:
- 200K model capped to 200K → compaction at ~168K tokens (no change)
- 1M model capped to 200K → compaction at ~168K tokens (instead of ~984K)
- 128K model capped to 200K → compaction at ~112K tokens (no change, already under limit)
index.ts- Extension sourceREADME.md- This fileLICENSE- MIT license
pi install git:github.com/DraconDev/pi-global-context-limit