Skip to content

fix(core): clarify the read tool's offset validation error - #48160

Open
holny wants to merge 1 commit into
anomalyco:v2from
holny:read-offset-message
Open

fix(core): clarify the read tool's offset validation error#48160
holny wants to merge 1 commit into
anomalyco:v2from
holny:read-offset-message

Conversation

@holny

@holny holny commented Sep 9, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #46807

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

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 still normalizes to the first line, matching the existing zero-offset normalization behavior.

How did you verify your code works?

  • New case in test/tool-read.test.ts: invoking read with offset: -1 surfaces the 1-based guidance
  • bun typecheck in packages/core; bun test test/tool-read.test.ts (27 passing, including the zero-offset normalization case)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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

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.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant