Skip to content

read_file should indicate when the model tries to read out of bounds #274120

@alexdima

Description

@alexdima

The model tried to read from a line number that doesn't exist twice:

Image

The file only had 498 lines. Here is the first tool call:

# Tool Call - toolu_01EPA3tz4EK5HHFca39CDWfh__vscode-1761817999475

## Request
~~~
id   : toolu_01EPA3tz4EK5HHFca39CDWfh__vscode-1761817999475
tool : read_file
args : {
  "filePath": "/Users/alex/src/vscode/src/vs/editor/test/common/model/tokensStore.test.ts",
  "offset": 535,
  "limit": 50
}
~~~
## Response
~~~
```typescript

```
~~~

Notice how we don't communicate to the model that this file doesn't have 535 lines at all. Then the model goes and tries again:

# Tool Call - toolu_01XFdtzdCYw5ViMycduyhJon__vscode-1761817999476

## Request
~~~
id   : toolu_01XFdtzdCYw5ViMycduyhJon__vscode-1761817999476
tool : read_file
args : {
  "filePath": "/Users/alex/src/vscode/src/vs/editor/test/common/model/tokensStore.test.ts",
  "limit": 20,
  "offset": 525
}
~~~
## Response
~~~
```typescript

```
~~~

The model is just trying to guess its way to the file size. IMHO we should report an error when the offset is > the line count in the file and explain in the error the actual file's line count. This should help the model recover faster and avoid doing two invalid read file tool calls in a row.

Image

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable bugchat-agent

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions