feat: token-threshold strategies, shared utilities, and docs update (v2.1.0)#7
Merged
feat: token-threshold strategies, shared utilities, and docs update (v2.1.0)#7
Conversation
…dated; version 2.2.0
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR migrates slimcontext from message-count based compression to token-threshold based compression strategies and updates to version 2.1.0. The key changes focus on making compression decisions based on estimated token usage relative to the model's context window rather than fixed message counts.
- Refactored
TrimCompressorandSummarizeCompressorto use token thresholds with configurable max tokens and threshold percentages - Added shared token budget utilities and a default token estimator in
src/strategies/common.ts - Updated all tests, examples, and documentation to reflect the new token-based configuration approach
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/trim.test.ts | Updated test to use token-threshold configuration with deterministic estimator |
| tests/summarize.test.ts | Simplified tests to focus on token-threshold behavior, removed complex alignment tests |
| tests/langchain.test.ts | Updated LangChain adapter tests to use new token-based configuration |
| src/strategies/trim.ts | Complete rewrite to implement token-threshold trimming logic |
| src/strategies/summarize.ts | Refactored to use token budgets and simplified summarization logic |
| src/strategies/common.ts | New file with shared token budget utilities and default estimator |
| src/interfaces.ts | Added TokenBudgetConfig interface and TokenEstimator type |
| src/adapters/langchain.ts | Updated adapter documentation and type definitions for token-based options |
| package.json | Version bump to 2.1.0 and prepare script change |
| examples/*.md | Updated all examples to show new token-based configuration |
| README.md | Comprehensive documentation update reflecting token-threshold approach |
| CHANGELOG.md | Added v2.1.0 entry with breaking changes and migration guide |
| .github/copilot-instructions.md | Updated internal documentation to reflect new architecture |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR migrates slimcontext strategies to token-threshold logic and updates docs, tests, and examples accordingly.
Summary
Migration notes
Validation
Closes: n/a