can1357/oh-my-pi · error · ValueError
query cannot be combined with offset/limit
Error message
query cannot be combined with offset/limit
What it means
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.
Source
Thrown at packages/coding-agent/src/eval/py/prelude.py:195
if not artifacts_dir:
session_file = os.environ.get("PI_SESSION_FILE")
if not session_file:
_emit_status("output", error="No session file available")
raise RuntimeError("No session - output artifacts unavailable")
artifacts_dir = session_file.rsplit(".", 1)[0] # Strip .jsonl extension
if not Path(artifacts_dir).exists():
_emit_status(
"output", error="Artifacts directory not found", path=artifacts_dir
)
raise RuntimeError(f"No artifacts directory found: {artifacts_dir}")
if not ids:
_emit_status("output", error="No IDs provided")
raise ValueError("At least one output ID is required")
if query and (offset is not None or limit is not None):
_emit_status("output", error="query cannot be combined with offset/limit")
raise ValueError("query cannot be combined with offset/limit")
results: list[dict] = []
not_found: list[str] = []
for output_id in ids:
output_path = Path(artifacts_dir) / f"{output_id}.md"
if not output_path.exists():
not_found.append(output_id)
continue
raw_content = output_path.read_text(encoding="utf-8")
raw_lines = raw_content.splitlines()
total_lines = len(raw_lines)
selected_content = raw_content
range_info: dict | None = None
# Handle queryView on GitHub (pinned to 9690622007)
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.
Example fix
// before content = output(["tool_1"], query=".result", offset=1, limit=50) // after content = output(["tool_1"], query=".result")
Defensive patterns
Strategy: validation
Validate before calling
if query and (offset is not None or limit is not None):
raise SystemExit("use query OR offset/limit, not both") Try / catch
try:
result = output(ids, query=q, offset=o, limit=l)
except ValueError as e:
if "query cannot be combined" in str(e):
result = output(ids, query=q) # drop windowing Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- At least one output ID is required
- Offset {start_line} is beyond end of output ({total_lines} l
- agent() received invalid arguments: ${result.summary}
- completion() received invalid arguments: ${parsed.summary}
- Output {output_id} is not valid JSON: {e}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/578684f5d26d14f8.
Report an issue: GitHub.