{"record":{"id":"c1023277057e1d3b","repo":"langchain-ai/deepagents","slug":"readresult-no-lines-requested-describes-an-uninspe","errorCode":null,"errorMessage":"ReadResult.no_lines_requested describes an uninspected window; it cannot be combined with error or pagination fields","messagePattern":"ReadResult\\.no_lines_requested describes an uninspected window; it cannot be combined with error or pagination fields","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/backends/protocol.py","lineNumber":255,"sourceCode":"        The window fields are not independent: `start_line`/`end_line` are a\n        pair, and neither `next_offset` nor `total_lines` describes anything\n        without the window it refers to. Beyond co-presence, the values must\n        agree numerically: a window runs forward (`1 <= start_line <=\n        end_line`), the file is at least as long as the window\n        (`total_lines >= end_line`), and the resume point is the 0-indexed line\n        immediately after the last one shown (`next_offset == end_line`, since\n        `end_line` is 1-indexed). Fail loudly here to keep a backend from\n        emitting a `next_offset` that would silently skip unshown source lines\n        once it reaches the middleware.\n        \"\"\"\n        if (self.start_line is None) != (self.end_line is None):\n            msg = \"ReadResult.start_line and end_line must be set together or both left unset\"\n            raise ValueError(msg)\n        if self.no_lines_requested and (\n            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\n        ):\n            msg = \"ReadResult.no_lines_requested describes an uninspected window; it cannot be combined with error or pagination fields\"\n            raise ValueError(msg)\n        if self.next_offset is not None and self.start_line is None:\n            msg = \"ReadResult.next_offset requires start_line and end_line to be set\"\n            raise ValueError(msg)\n        if self.total_lines is not None and self.start_line is None:\n            msg = \"ReadResult.total_lines requires start_line and end_line to be set\"\n            raise ValueError(msg)\n\n        # Numeric consistency of a present window. `start_line`/`end_line` are\n        # bound together above, so testing `start_line` covers both.\n        if self.start_line is not None and self.end_line is not None:\n            if self.start_line < 1 or self.end_line < self.start_line:\n                msg = f\"ReadResult window must satisfy 1 <= start_line <= end_line, got start_line={self.start_line}, end_line={self.end_line}\"\n                raise ValueError(msg)\n            if self.total_lines is not None and self.total_lines < self.end_line:\n                msg = f\"ReadResult.total_lines ({self.total_lines}) cannot be less than end_line ({self.end_line})\"\n                raise ValueError(msg)\n            if self.next_offset is not None and self.next_offset != self.end_line:\n                msg = f\"ReadResult.next_offset ({self.next_offset}) must equal end_line ({self.end_line}), the 0-indexed line after the last shown\"","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/backends/protocol.py#L237-L273","documentation":"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.","triggerScenarios":"Constructing ReadResult(no_lines_requested=True, ...) while also passing error=..., or any of start_line/next_offset/total_lines.","commonSituations":"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.","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"],"exampleFix":"# before\nreturn ReadResult(no_lines_requested=True, error=\"file too large\")\n# after\nreturn ReadResult(error=\"file too large\")","handlingStrategy":"type-guard","validationCode":"if no_lines:\n    assert error is None and start_line is None and next_offset is None and total_lines is None","typeGuard":"def is_uninspected(r: ReadResult) -> bool:\n    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","tryCatchPattern":"try:\n    return ReadResult(no_lines_requested=no_lines, error=error)\nexcept ValueError:\n    return ReadResult(error=error) if error else ReadResult(no_lines_requested=True)","preventionTips":["Pick one representation per result: uninspected window, error, or window+pagination","Construct ReadResult via a single helper that enforces exclusivity"],"tags":["python","dataclass-invariant","protocol"],"backgroundTag":"invariant-violation","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}