can1357/oh-my-pi · error · RuntimeError
No artifacts directory found: #{artifacts_dir}
Error message
No artifacts directory found: #{artifacts_dir} What it means
`output(*ids)` locates the artifacts directory from PI_ARTIFACTS_DIR or by stripping the extension off PI_SESSION_FILE. When that directory does not exist on disk (`File.directory?` fails), it emits an error status naming the path and raises this error — artifacts were expected there but nothing was created or the path points elsewhere.
Source
Thrown at packages/coding-agent/src/eval/rb/prelude.rb:180
current = current[value]
end
end
current
end
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.lengthView on GitHub (pinned to 9690622007)
Solutions
- Print/inspect the path in the message and create or correct PI_ARTIFACTS_DIR to point at the real artifacts directory before calling `output`
- Confirm the session actually produced artifacts (list the derived directory from PI_SESSION_FILE minus extension); if the producing task hasn't run or failed, rerun it first
- Set PI_ARTIFACTS_DIR explicitly to the correct absolute directory instead of relying on the session-file derivation
Example fix
// before
ENV["PI_ARTIFACTS_DIR"] = "artifacts"
output("step1")
// after
ENV["PI_ARTIFACTS_DIR"] = File.expand_path("~/.omp/sessions/abc123")
output("step1") Defensive patterns
Strategy: validation
Validate before calling
dir = ENV["PI_ARTIFACTS_DIR"]
dir ||= ENV["PI_SESSION_FILE"].to_s.sub(/\.[^.]*\z/, "")
raise "artifacts dir missing: #{dir}" unless dir.to_s.nonempty? && File.directory?(dir)
results = output("step1") Try / catch
begin
artifacts = output("step1")
rescue RuntimeError => e
raise unless e.message.start_with?("No artifacts directory found: ")
artifacts = nil
end Prevention
- Use absolute paths for PI_ARTIFACTS_DIR; relative paths break if cwd differs
- Confirm the producing task completed before reading its outputs
- Check the directory exists (File.directory?) before relying on session-file derivation
When it happens
Trigger: Calling `output("some-id")` when PI_ARTIFACTS_DIR points to a nonexistent/removed directory, or PI_SESSION_FILE is set but the sibling directory (session path minus extension) was never created — e.g. artifacts from a completed/deleted session, or a session file path passed manually that does not match the real layout.
Common situations: Re-running an eval against an old session file whose artifacts dir was cleaned up; setting PI_ARTIFACTS_DIR to a typo'd or relative path from a different working directory; artifacts not yet written because the sub-agent/task producing them has not finished (or failed).
Related errors
- No session - output artifacts unavailable
- No artifacts directory found: {artifacts_dir}
- Output #{output_id} is not valid JSON: #{e.message}
- Failed to move artifacts and rollback: ${rollbackErr instanc
- unknown filetype: {ft_debug}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/db2ce44a69001f40.
Report an issue: GitHub.