fix(core): clarify the read tool's offset validation error - #48160
Open
holny wants to merge 1 commit into
Open
Conversation
Models occasionally hallucinate a negative value for the optional read offset (for example offset: -1), and the validation failure only said the value should be >= 0 without acknowledging that line and entry numbers are 1-based. Annotate the input schema so the failure carries the 1-based guidance and nudges the model toward omitting the offset or using 1. Offset 0 remains valid and normalizes to the first line.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
6 tasks
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PR Found:
The search confirms that PR #48160 (the current PR) is a re-filing of #47175 (head fork was deleted), which is clearly stated in the description. No other duplicate PRs were found. |
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.
Issue for this PR
Fixes #46807
Type of change
What does this PR do?
Models occasionally hallucinate a negative value for the optional read
offset(for exampleoffset: -1), and the validation failure only said the value should be>= 0without acknowledging that line and entry numbers are 1-based. Annotate the input schema so the failure carries the 1-based guidance and nudges the model toward omitting the offset or using1.Offset
0remains valid and still normalizes to the first line, matching the existing zero-offset normalization behavior.How did you verify your code works?
test/tool-read.test.ts: invoking read withoffset: -1surfaces the 1-based guidancebun typecheckinpackages/core;bun test test/tool-read.test.ts(27 passing, including the zero-offset normalization case)Checklist
Supersedes #47175 — the PR head fork was accidentally deleted on 2026-09-09 (not intentional, see the notification comment there); re-filing so the review can continue. Original conversation: #47175