can1357/oh-my-pi · error · FileNotFoundError

Could not find agent compaction prompts

Error message

Could not find agent compaction prompts

What it means

find_agent_prompts locates the agent package's compaction prompt directory by probing candidate paths relative to the repo root (packages/agent/src/compaction/prompts or agent/src/compaction/prompts). If none exist, the script raises this FileNotFoundError because snapcompact experiments require those prompt files to build compaction contexts.

Source

Thrown at packages/metaharness/src/adapters/snapcompact.py:50

import json
import re
import sys
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path

HERE = Path(__file__).resolve().parent
RESEARCH = HERE.parents[2] / "snapcompact" / "research"


def find_agent_prompts() -> Path:
    for parent in HERE.parents:
        for candidate in (
            parent / "packages" / "agent" / "src" / "compaction" / "prompts",
            parent / "agent" / "src" / "compaction" / "prompts",
        ):
            if candidate.exists():
                return candidate
    raise FileNotFoundError("Could not find agent compaction prompts")


sys.path.insert(0, str(RESEARCH))

import squad  # noqa: E402
from anthropic_api import complete, image_block, load_api_key  # noqa: E402
from bdf import VARIANTS, FontCfg, capacity, render  # noqa: E402

AGENT_PROMPTS = find_agent_prompts()
CACHE = RESEARCH / ".cache"
QA_CACHE = CACHE / "qa"
RESULTS = RESEARCH / "results"

FONTS = {
    "8x13": FontCfg("8x13", "8x13", 8, 13),
    "7x13": FontCfg("7x13", "7x13", 7, 13),
    "6x12": FontCfg("6x12", "6x12", 6, 12),
    "6x10": FontCfg("6x10", "6x10", 6, 10),

View on GitHub (pinned to 9690622007)

Solutions

  1. Run the script from within a full clone of the oh-my-pi monorepo containing packages/agent/src/compaction/prompts.
  2. Set/verify the script's root detection (parent directory derivation) so candidates resolve — run with the correct cwd or adjust the parent logic.
  3. Update the candidate list in find_agent_prompts if the prompts directory was relocated.
  4. Ensure the path exists: ls packages/agent/src/compaction/prompts before running.

Example fix

# before
cd /tmp && python adapters/snapcompact.py ...   # FileNotFoundError
# after
cd /path/to/oh-my-pi && python packages/metaharness/src/adapters/snapcompact.py ...
Defensive patterns

Strategy: fallback

Validate before calling

import pathlib
root = pathlib.Path("packages/agent/src/compaction/prompts")
assert root.is_dir(), f"run from repo root; missing {root}"

Try / catch

try:
    prompts = find_agent_prompts()
except FileNotFoundError:
    sys.exit("snapcompact must run inside a full oh-my-pi checkout with packages/agent/src/compaction/prompts")

Prevention

When it happens

Trigger: Running snapcompact.py outside a checkout of this repo, from a directory layout without the agent package (e.g. installed package, shallow copy, renamed/sparse checkout), or after the prompts directory was moved.

Common situations: Running the research adapter standalone on a machine without the full monorepo; running from a packaged/deployed copy where source dirs are absent; a refactor moved compaction prompts and the hardcoded candidates are stale.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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