feat: naive token estimation via tiktoken#2031
Open
lizradway wants to merge 1 commit intostrands-agents:mainfrom
Open
feat: naive token estimation via tiktoken#2031lizradway wants to merge 1 commit intostrands-agents:mainfrom
lizradway wants to merge 1 commit intostrands-agents:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
6c2c1c5 to
55bd572
Compare
Review Summary (Round 2)Assessment: Approve ✅ All previously identified blocking issues have been addressed in this update. Changes Verified
Additional Improvements
Note: Codecov shows 92.85% patch coverage with 4 partial lines - these are likely error handling branches ( Good implementation with clean code structure, appropriate error handling, and thorough test coverage. 👍 |
7 tasks
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.
Description
_estimate_tokens()method to theModelbase class for estimating input token count before sending to the model, enabling proactive context management (e.g., triggering compression at a threshold)cl100k_baseencoding) as a universal fallback for all 11 providers — individual providers can override with native counting APIs latertiktokenas a hard dependencyRelated Issues
#1294
Documentation PR
This should be internally facing, documentation not required
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.