{"record":{"id":"761a0d4e8bd9bd3e","repo":"can1357/oh-my-pi","slug":"no-session-output-artifacts-unavailable-761a0d","errorCode":null,"errorMessage":"No session - output artifacts unavailable","messagePattern":"No session - output artifacts unavailable","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/rb/prelude.rb","lineNumber":174,"sourceCode":"    tokens.each do |kind, value|\n      if kind == :index\n        return nil unless current.is_a?(Array) && value < current.length\n        current = current[value]\n      else\n        return nil unless current.is_a?(Hash) && current.key?(value)\n        current = current[value]\n      end\n    end\n    current\n  end\n\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)","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/rb/prelude.rb#L156-L192","documentation":"The prelude's `output(*ids)` helper reads sub-agent/task artifacts (`<id>.md`) from a artifacts directory taken from PI_ARTIFACTS_DIR, or derived from PI_SESSION_FILE by stripping its extension. If neither env var is set (both nil or empty), there is no way to locate artifacts, so it emits an error status and raises this plain RuntimeError. It means the eval script is running without a session context.","triggerScenarios":"Calling `output` (with any or no arguments) inside an eval/run script when neither PI_ARTIFACTS_DIR nor PI_SESSION_FILE is present in the process environment — e.g. running the script standalone via the Ruby runner without the coding-agent host session wiring, or a host bug that failed to pass the env through the tool bridge.","commonSituations":"Executing the prelude-backed script outside `omp` (raw `ruby`/runner invocation); CI jobs that sanitize the environment; a version change where the host stopped exporting PI_SESSION_FILE to eval workers.","solutions":["Ensure the script is launched through the omp eval host so PI_SESSION_FILE is set; verify with `env['PI_SESSION_FILE']` at the top of the script","Set PI_ARTIFACTS_DIR explicitly to the directory containing `<id>.md` artifacts before calling `output`","If running standalone intentionally, skip `output` and read the artifact files directly with `read`/`File.read`"],"exampleFix":"// before\nsummary = output(\"step1\")\n// after\ndir = env[\"PI_ARTIFACTS_DIR\"]\nraise \"set PI_ARTIFACTS_DIR\" if dir.nil? || dir.empty?\nsummary = output(\"step1\")","handlingStrategy":"validation","validationCode":"raise \"output() requires PI_ARTIFACTS_DIR or PI_SESSION_FILE\" if ENV[\"PI_ARTIFACTS_DIR\"].to_s.empty? && ENV[\"PI_SESSION_FILE\"].to_s.empty?\nresults = output(\"step1\")","typeGuard":null,"tryCatchPattern":"begin\n  artifacts = output(\"step1\")\nrescue RuntimeError => e\n  raise unless e.message == \"No session - output artifacts unavailable\"\n  artifacts = nil # run without artifact lookup\nend","preventionTips":["Always run eval scripts through the omp host so session env vars are injected","Verify ENV['PI_SESSION_FILE'] at script start when artifacts are expected","Prefer setting PI_ARTIFACTS_DIR explicitly in CI where sessions do not exist"],"tags":["ruby","env","session","artifacts"],"backgroundTag":"missing-env-var","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}