langchain-ai/deepagents · error · ValueError
ReadResult.no_lines_requested describes an uninspected windo
Error message
ReadResult.no_lines_requested describes an uninspected window; it cannot be combined with error or pagination fields
What it means
no_lines_requested marks a ReadResult as describing an uninspected window (e.g. an offset beyond EOF) and is mutually exclusive with error and pagination fields. __post_init__ raises ValueError if it is combined with error, start_line, next_offset, or total_lines, since such a result would be ambiguous.
Source
Thrown at libs/deepagents/deepagents/backends/protocol.py:255
The window fields are not independent: `start_line`/`end_line` are a
pair, and neither `next_offset` nor `total_lines` describes anything
without the window it refers to. Beyond co-presence, the values must
agree numerically: a window runs forward (`1 <= start_line <=
end_line`), the file is at least as long as the window
(`total_lines >= end_line`), and the resume point is the 0-indexed line
immediately after the last one shown (`next_offset == end_line`, since
`end_line` is 1-indexed). Fail loudly here to keep a backend from
emitting a `next_offset` that would silently skip unshown source lines
once it reaches the middleware.
"""
if (self.start_line is None) != (self.end_line is None):
msg = "ReadResult.start_line and end_line must be set together or both left unset"
raise ValueError(msg)
if self.no_lines_requested and (
self.error is not None or self.start_line is not None or self.next_offset is not None or self.total_lines is not None
):
msg = "ReadResult.no_lines_requested describes an uninspected window; it cannot be combined with error or pagination fields"
raise ValueError(msg)
if self.next_offset is not None and self.start_line is None:
msg = "ReadResult.next_offset requires start_line and end_line to be set"
raise ValueError(msg)
if self.total_lines is not None and self.start_line is None:
msg = "ReadResult.total_lines requires start_line and end_line to be set"
raise ValueError(msg)
# Numeric consistency of a present window. `start_line`/`end_line` are
# bound together above, so testing `start_line` covers both.
if self.start_line is not None and self.end_line is not None:
if self.start_line < 1 or self.end_line < self.start_line:
msg = f"ReadResult window must satisfy 1 <= start_line <= end_line, got start_line={self.start_line}, end_line={self.end_line}"
raise ValueError(msg)
if self.total_lines is not None and self.total_lines < self.end_line:
msg = f"ReadResult.total_lines ({self.total_lines}) cannot be less than end_line ({self.end_line})"
raise ValueError(msg)
if self.next_offset is not None and self.next_offset != self.end_line:
msg = f"ReadResult.next_offset ({self.next_offset}) must equal end_line ({self.end_line}), the 0-indexed line after the last shown"View on GitHub (pinned to a1af029e6e)
Solutions
- Return either no_lines_requested=True OR error/pagination fields, never both
- If there is an error, drop no_lines_requested and set error instead
- For a valid empty window at EOF, use no_lines_requested=True with all other fields None
Example fix
# before return ReadResult(no_lines_requested=True, error="file too large") # after return ReadResult(error="file too large")
Defensive patterns
Strategy: type-guard
Validate before calling
if no_lines:
assert error is None and start_line is None and next_offset is None and total_lines is None Type guard
def is_uninspected(r: ReadResult) -> bool:
return r.no_lines_requested and r.error is None and r.start_line is None and r.next_offset is None and r.total_lines is None Try / catch
try:
return ReadResult(no_lines_requested=no_lines, error=error)
except ValueError:
return ReadResult(error=error) if error else ReadResult(no_lines_requested=True) Prevention
- Pick one representation per result: uninspected window, error, or window+pagination
- Construct ReadResult via a single helper that enforces exclusivity
When it happens
Trigger: Constructing ReadResult(no_lines_requested=True, ...) while also passing error=..., or any of start_line/next_offset/total_lines.
Common situations: A backend wanting to report 'no lines' plus an error message — it must pick one representation — or copy-pasting constructor kwargs from a normal-window code path.
Related errors
- ReadResult.start_line and end_line must be set together or b
- ReadResult.next_offset requires start_line and end_line to b
- modes can only be provided when agent is a factory
- models can only be provided when agent is a factory
- -32601
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/c1023277057e1d3b.
Report an issue: GitHub.