can1357/oh-my-pi · error · ArgumentError
query cannot be combined with offset/limit
Error message
query cannot be combined with offset/limit
What it means
The Ruby eval prelude's `output` helper reads agent output artifacts (.md files) from the session's artifacts directory. It supports two mutually exclusive paging modes: a `query` (JSON-path into the artifact contents) and `offset`/`limit` (line-range paging). Because these modes are semantically incompatible — query selects parsed JSON values while offset/limit slices raw lines — the prelude raises ArgumentError up front when both are supplied.
Source
Thrown at packages/coding-agent/src/eval/rb/prelude.rb:185
def output(*ids, format: "raw", query: nil, offset: nil, limit: nil)
artifacts_dir = ENV["PI_ARTIFACTS_DIR"]
if artifacts_dir.nil? || artifacts_dir.empty?
session_file = ENV["PI_SESSION_FILE"]
if session_file.nil? || session_file.empty?
__omp_emit_status("output", "error" => "No session file available")
raise "No session - output artifacts unavailable"
end
artifacts_dir = session_file.sub(/\.[^.]*\z/, "")
end
unless File.directory?(artifacts_dir)
__omp_emit_status("output", "error" => "Artifacts directory not found", "path" => artifacts_dir)
raise "No artifacts directory found: #{artifacts_dir}"
end
raise ArgumentError, "At least one output ID is required" if ids.empty?
if query && (!offset.nil? || !limit.nil?)
__omp_emit_status("output", "error" => "query cannot be combined with offset/limit")
raise ArgumentError, "query cannot be combined with offset/limit"
end
results = []
not_found = []
ids.each do |output_id|
path = File.join(artifacts_dir, "#{output_id}.md")
unless File.exist?(path)
not_found << output_id
next
end
raw = File.read(path, encoding: Encoding::UTF_8)
raw_lines = raw.split("\n", -1)
total_lines = raw_lines.length
selected = raw
range_info = nil
if query
json_value =View on GitHub (pinned to 9690622007)
Solutions
- Remove the offset/limit keyword arguments when using query (the query already selects only the matching subvalue).
- Drop the query argument if you actually want raw line paging via offset/limit.
- Fetch with query first, then paginate the returned JSON string yourself if both narrowing steps are required.
Example fix
// before
result = output('result_1', query: '$.rows', limit: 20)
// after
result = output('result_1', query: '$.rows') # query selects the rows; no limit needed Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, 'query cannot be combined with offset/limit' if query && (!offset.nil? || !limit.nil?)
Try / catch
begin result = output(id, query: q) rescue ArgumentError => e # fall back to unpaged fetch result = output(id) end
Prevention
- Treat query and offset/limit as two separate access modes and never set both in shared helper wrappers.
- Wrap the output helper in your own function exposing either `query` or `page` params, not both.
When it happens
Trigger: Calling `output('some_id', query: '$.items')` with either `offset:` or `limit:` also set, e.g. `output('x', query: 'items', offset: 5)` or `output('x', query: 'name', limit: 10)`.
Common situations: Developers wanting to narrow output with a JSON query also add a limit to reduce context size; scripts generated by copying an example that used offset/limit then appending a query parameter.
Related errors
- tool.#{name}(...) expects a Hash of arguments (got #{positio
- At least one output ID is required
- Output #{output_id} is not valid JSON: #{e.message}
- Offset #{start_line} is beyond end of output (#{total_lines}
- tool bridge is unavailable in this kernel
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/3267c8a7008190f3.
Report an issue: GitHub.