Repository navigation
fix: enforce tiny skills token budgets - #4415
Merged
Merged
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
⚙️ Agent run details
|
IsmaelMartinez
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @utsab345 for spotting that the truncation marker can overshoot a 1 to 3 token budget. Rather than a clipped marker like "\n\n[t", which is no use in a prompt, the docstring already promises an empty string when nothing fits. One ask: replace the new block with the guard below, and update the test to expect "".
Comment on lines
+279
to
+283
| if max_tokens < marker_tokens: | ||
| marker = clip_tokens(truncate_marker, max_tokens, add_three_dots=False) | ||
| while marker and _count_tokens(marker) > max_tokens: | ||
| marker = marker[:-1] | ||
| return marker |
Collaborator
There was a problem hiding this comment.
Suggested change
| if max_tokens < marker_tokens: | |
| marker = clip_tokens(truncate_marker, max_tokens, add_three_dots=False) | |
| while marker and _count_tokens(marker) > max_tokens: | |
| marker = marker[:-1] | |
| return marker | |
| if max_tokens < marker_tokens: | |
| return "" |
utsab345
force-pushed
the
hunt/fresh-defect
branch
from
October 27, 2026 14:21
562d3a0 to
5b3109d
Compare
IsmaelMartinez
approved these changes
Oct 27, 2026
IsmaelMartinez
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @utsab345 for switching to the empty-string guard so a tiny budget no longer emits a clipped marker. Output now stays within budget for every value from 0 to 20, and the new test fails without the fix. Approving and merging.
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.
User description
A skills token budget smaller than the truncation marker currently produces output above the configured limit, which can overflow prompts even when the setting is valid. This change returns a safely clipped marker for tiny budgets and adds regression coverage to keep the formatted context within the requested token limit.
PR Type
Bug fix, Tests
Description
Clip truncation markers to tiny token budgets.
Add regression coverage for one-token skill contexts.
File Walkthrough
skills_loader.py
Keep truncated skills context within tiny budgetspr_agent/algo/skills_loader.py
early.
test_skills_context_budget.py
Test skills context against one-token budgetstests/unittest/test_skills_context_budget.py
⚙️ Agent run details