@sisu-ai/mw-context-compressor
v9.0.0
Published
Reduce token costs by compressing long conversations while preserving useful recent context.
Maintainers
Readme
@sisu-ai/mw-context-compressor
Reduce token costs by compressing long conversations while preserving useful recent context.
- Wraps
ctx.model.generateto summarize older messages when the context grows beyond a size threshold. - Preserves the last
keepRecentmessages unmodified. - Keeps essential facts and URLs; emits a compact assistant summary message that replaces older history.
Usage
import { contextCompressor } from '@sisu-ai/mw-context-compressor';
agent.use(contextCompressor({ maxChars: 200_000, keepRecent: 8, summaryMaxChars: 12_000 }));Options
maxChars(default 200k): approximate character budget before compressing.keepRecent(default 8): number of most recent messages to retain verbatim.summaryMaxChars(default 12k): target maximum size of the generated summary message.
Note: This is a best-effort char-based heuristic; exact token accounting varies by model.
Community & Support
Discover what you can do through examples or documentation. Check it out at https://github.com/finger-gun/sisu. Example projects live under examples/ in the repo.
Documentation
Core — Package docs · Error types
Adapters — OpenAI · Anthropic · Ollama
- @sisu-ai/mw-agent-run-api
- @sisu-ai/mw-context-compressor
- @sisu-ai/mw-control-flow
- @sisu-ai/mw-conversation-buffer
- @sisu-ai/mw-cors
- @sisu-ai/mw-error-boundary
- @sisu-ai/mw-guardrails
- @sisu-ai/mw-invariants
- @sisu-ai/mw-orchestration
- @sisu-ai/mw-rag
- @sisu-ai/mw-react-parser
- @sisu-ai/mw-register-tools
- @sisu-ai/mw-tool-calling
- @sisu-ai/mw-trace-viewer
- @sisu-ai/mw-usage-tracker
- @sisu-ai/tool-aws-s3
- @sisu-ai/tool-azure-blob
- @sisu-ai/tool-extract-urls
- @sisu-ai/tool-github-projects
- @sisu-ai/tool-rag
- @sisu-ai/tool-summarize-text
- @sisu-ai/tool-terminal
- @sisu-ai/tool-web-fetch
- @sisu-ai/tool-web-search-duckduckgo
- @sisu-ai/tool-web-search-google
- @sisu-ai/tool-web-search-openai
- @sisu-ai/tool-wikipedia
Anthropic — hello · control-flow · stream · weather
Ollama — hello · stream · vision · weather · web-search
OpenAI — hello · weather · stream · vision · reasoning · react · control-flow · branch · parallel · graph · orchestration · orchestration-adaptive · guardrails · error-handling · rag-chroma · web-search · web-fetch · wikipedia · terminal · github-projects · server · aws-s3 · azure-blob
Contributing
We build Sisu in the open. Contributions welcome.
Contributing Guide · Report a Bug · Request a Feature · Code of Conduct
Star on GitHub if Sisu helps you build better agents.
Quiet, determined, relentlessly useful.
