Repository navigation
fix(openai): guard truncation loop from emptying the user slot on token-dense standups #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
detail-app
wants to merge
1
commit into
main
Choose a base branch
from
detail/bug-fix/fix-openai-guard-truncation-loop-from-emptying-the-927afb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a single whitespace-free value whose token count exceeds
MODEL_MAX_TOKENS,nextequals the original count, so thisbreakreturns that still-oversized value.getTrainingExampleserializes it directly into the fine-tuning JSONL, so this reintroduces an invalid over-budget training example (and similarly lets scoring requests exceed the function's documented limit).Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked
src/openai/format.ts:82-91and the PR's owntestSingleOverBudgetWordTerminatesAndStaysNonEmpty(src/openai/format.test.ts:154-167), which deliberately asserts an unsplittable over-budget single word ispreserved verbatimand stays overMODEL_MAX_TOKENS(the comment states "the whole word is preserved since it cannot be split, even though it remains over the model's token budget").I attempted to fix this by hard-truncating to the token budget once word-splitting can no longer reduce the count (sub-word cut via
decode(encode(text).slice(0, MODEL_MAX_TOKENS))). That brings the over-budget single word underMODEL_MAX_TOKENS, but it directly fails the PR'sassertEqual(userContent, text, '... preserved verbatim ...')contract, so landing it would rewrite that test and change the PR's stated purpose. For a single whitespace-free over-budget token, "non-empty" and "under budget" are mutually exclusive under word-based truncation; getting under budget requires sub-word splitting, which the PR deliberately rejects.Leaving the code unchanged pending a human decision: (a) keep the current behavior — preserve non-empty verbatim and accept that an unsplittable over-budget input exceeds
MODEL_MAX_TOKENSingetTrainingExample/scoring, or (b) change the PR's purpose to hard-truncate unsplittable over-budget input to the token budget (which rewritestestSingleOverBudgetWordTerminatesAndStaysNonEmpty).