{"record":{"id":"3267c8a7008190f3","repo":"can1357/oh-my-pi","slug":"query-cannot-be-combined-with-offset-limit-3267c8","errorCode":null,"errorMessage":"query cannot be combined with offset/limit","messagePattern":"query cannot be combined with offset/limit","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/rb/prelude.rb","lineNumber":185,"sourceCode":"\n  def output(*ids, format: \"raw\", query: nil, offset: nil, limit: nil)\n    artifacts_dir = ENV[\"PI_ARTIFACTS_DIR\"]\n    if artifacts_dir.nil? || artifacts_dir.empty?\n      session_file = ENV[\"PI_SESSION_FILE\"]\n      if session_file.nil? || session_file.empty?\n        __omp_emit_status(\"output\", \"error\" => \"No session file available\")\n        raise \"No session - output artifacts unavailable\"\n      end\n      artifacts_dir = session_file.sub(/\\.[^.]*\\z/, \"\")\n    end\n    unless File.directory?(artifacts_dir)\n      __omp_emit_status(\"output\", \"error\" => \"Artifacts directory not found\", \"path\" => artifacts_dir)\n      raise \"No artifacts directory found: #{artifacts_dir}\"\n    end\n    raise ArgumentError, \"At least one output ID is required\" if ids.empty?\n    if query && (!offset.nil? || !limit.nil?)\n      __omp_emit_status(\"output\", \"error\" => \"query cannot be combined with offset/limit\")\n      raise ArgumentError, \"query cannot be combined with offset/limit\"\n    end\n\n    results = []\n    not_found = []\n    ids.each do |output_id|\n      path = File.join(artifacts_dir, \"#{output_id}.md\")\n      unless File.exist?(path)\n        not_found << output_id\n        next\n      end\n      raw = File.read(path, encoding: Encoding::UTF_8)\n      raw_lines = raw.split(\"\\n\", -1)\n      total_lines = raw_lines.length\n      selected = raw\n      range_info = nil\n\n      if query\n        json_value =","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/rb/prelude.rb#L167-L203","documentation":"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.","triggerScenarios":"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)`.","commonSituations":"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.","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."],"exampleFix":"// before\nresult = output('result_1', query: '$.rows', limit: 20)\n// after\nresult = output('result_1', query: '$.rows')  # query selects the rows; no limit needed","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'query cannot be combined with offset/limit' if query && (!offset.nil? || !limit.nil?)","typeGuard":null,"tryCatchPattern":"begin\n  result = output(id, query: q)\nrescue ArgumentError => e\n  # fall back to unpaged fetch\n  result = output(id)\nend","preventionTips":["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."],"tags":["ruby","argument-error","api-misuse","eval-prelude"],"backgroundTag":"mutually-exclusive-parameters","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}