{"record":{"id":"578684f5d26d14f8","repo":"can1357/oh-my-pi","slug":"query-cannot-be-combined-with-offset-limit","errorCode":null,"errorMessage":"query cannot be combined with offset/limit","messagePattern":"query cannot be combined with offset/limit","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/py/prelude.py","lineNumber":195,"sourceCode":"        if not artifacts_dir:\n            session_file = os.environ.get(\"PI_SESSION_FILE\")\n            if not session_file:\n                _emit_status(\"output\", error=\"No session file available\")\n                raise RuntimeError(\"No session - output artifacts unavailable\")\n            artifacts_dir = session_file.rsplit(\".\", 1)[0]  # Strip .jsonl extension\n        if not Path(artifacts_dir).exists():\n            _emit_status(\n                \"output\", error=\"Artifacts directory not found\", path=artifacts_dir\n            )\n            raise RuntimeError(f\"No artifacts directory found: {artifacts_dir}\")\n\n        if not ids:\n            _emit_status(\"output\", error=\"No IDs provided\")\n            raise ValueError(\"At least one output ID is required\")\n\n        if query and (offset is not None or limit is not None):\n            _emit_status(\"output\", error=\"query cannot be combined with offset/limit\")\n            raise ValueError(\"query cannot be combined with offset/limit\")\n\n        results: list[dict] = []\n        not_found: list[str] = []\n\n        for output_id in ids:\n            output_path = Path(artifacts_dir) / f\"{output_id}.md\"\n            if not output_path.exists():\n                not_found.append(output_id)\n                continue\n\n            raw_content = output_path.read_text(encoding=\"utf-8\")\n            raw_lines = raw_content.splitlines()\n            total_lines = len(raw_lines)\n\n            selected_content = raw_content\n            range_info: dict | None = None\n\n            # Handle query","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/py/prelude.py#L177-L213","documentation":"The `output()` helper supports two mutually exclusive ways to narrow what you get back: a jq-like `query` (applied to the artifact parsed as JSON) and `offset`/`limit` (line-windowing of the raw text). It throws this ValueError when both are supplied, because they cannot be meaningfully combined.","triggerScenarios":"Calling `output(ids=[\"x\"], query=\".result\", offset=10)`, `output(ids=[\"x\"], query=\".a\", limit=5)`, or any call where `query` is truthy while `offset` or `limit` is not None.","commonSituations":"Wrapping `output()` in a helper that always passes default pagination args (`offset=1, limit=100`) and then adding a query; incrementally editing a call to add a query without removing leftover windowing args.","solutions":["Remove the `offset`/`limit` arguments and use only `query`.","Remove `query` and use only `offset`/`limit` for line windowing.","If you need both, call `output` twice: first with `query` to extract JSON, then post-process the returned string yourself."],"exampleFix":"// before\ncontent = output([\"tool_1\"], query=\".result\", offset=1, limit=50)\n\n// after\ncontent = output([\"tool_1\"], query=\".result\")","handlingStrategy":"validation","validationCode":"if query and (offset is not None or limit is not None):\n    raise SystemExit(\"use query OR offset/limit, not both\")","typeGuard":null,"tryCatchPattern":"try:\n    result = output(ids, query=q, offset=o, limit=l)\nexcept ValueError as e:\n    if \"query cannot be combined\" in str(e):\n        result = output(ids, query=q)  # drop windowing","preventionTips":["Pick one narrowing mode per call and document which in wrapper helpers.","Don't set default offset/limit values in wrappers around output().","Remember: query = JSON extraction, offset/limit = raw line windowing — different modes."],"tags":["python","validation","conflicting-arguments","eval"],"backgroundTag":"incompatible-arguments","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}