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 query

View on GitHub (pinned to 9690622007)

Solutions

  1. Remove the `offset`/`limit` arguments and use only `query`.
  2. Remove `query` and use only `offset`/`limit` for line windowing.
  3. 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

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


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/578684f5d26d14f8. Report an issue: GitHub.