Skip to content

bench: a relative dataset cache root is read back relative, so the run's cache moves with the caller's cwd #1280

In progress

Description

@HugoXK

Implementation: AgentDescent (ours) — do not pick up; the pair PR is dispatched separately.

At main 0a6e782f8f206eb1477d72f334e84c2ff0ba4b09, agentdescent/dataloader.py:_cache_root() expands ~ but never makes the root absolute:

  • :206-208 — explicit = os.environ.get("AGENTDESCENT_CACHE") → return os.path.expanduser(explicit)
  • :209-211 — xdg = os.environ.get("XDG_CACHE_HOME") → return os.path.join(os.path.expanduser(xdg), "agentdescent")
  • :215-218 — cache_path() joins that root and os.makedirs() it, so a relative root becomes a directory relative to whatever cwd the caller happens to have.

Measured in a clean checkout at that sha:

$ AGENTDESCENT_CACHE=rel-cache python3 -c 'from agentdescent import dataloader as dl; print(dl.cache_path("gsm8k","x.jsonl"))'
rel-cache/gsm8k/x.jsonl                     # os.path.isabs → False
$ XDG_CACHE_HOME=rel-xdg python3 -c 'from agentdescent import dataloader as dl; print(dl._cache_root())'
rel-xdg/agentdescent                        # os.path.isabs → False

Why a relative root is a real bug here, not a style nit. A run is written by one process and executed by another, and those processes do not share a cwd:

  • agentdescent/runstore.py:944 starts the detached child with cwd=rd.path — the run directory. agentdescent/evolvespec.py:352 records the same fact for specs ("the CLI validates it where you typed the command, then a detached child runs it from the run directory"), and agentdescent/mcp.py:954-956 resolves every relative spec path once for exactly this reason (EvolveSpec.absolutise()).
  • The dataset cache has no such resolution step. So AGENTDESCENT_CACHE=rel-cache names <the shell's cwd>/rel-cache for the process that starts a run and <run dir>/rel-cache for the child that actually fetches — a different tree on every run, re-downloading the ~46 MB ModelScope file or missing a cache the operator believes is warm. Under the sandbox the same knob lands inside a workspace that is reclaimed after the run (agentdescent/agents.py:374, :464; agentdescent/runners.py:219-224), so the cache vanishes with it.

Second clause, same file, same fix: the docstring is stale. hf_rows_modelscope at :415-417 still promises responses "live under ~/.cache/agentdescent/modelscope/", while :421 writes through _raw_cache_path → cache_path → _cache_root() and honours both knobs. The module docstring was corrected in #1267; this one was missed, so the documented path and the written path disagree for anyone who moves the root.

Precedent — this is a recurrence. #402 was "runstore: a literal ~ in --store or $AGENTDESCENT_HOME is only half expanded"; #403 fixed it by normalising the base once, os.path.abspath(os.path.expanduser(path)) (agentdescent/runstore.py:281). #1261/#1267 then added the same knob family to the dataset cache with only the expanduser half, so this is the #402 shape repeating in a second subsystem.

Fix, one function:

  • resolve the root once in _cache_root(): os.path.abspath(os.path.expanduser(...)) for AGENTDESCENT_CACHE and for XDG_CACHE_HOME/agentdescent;
  • leave CACHE_ROOT and the no-variable path byte-identical to today — no change to the default;
  • keep cache_path(subdir, filename)'s signature and its makedirs, and the cache=False bypass contract in hf_rows / hf_rows_modelscope / fetch_bytes;
  • correct the hf_rows_modelscope docstring to name the knobs instead of one fixed path.

Acceptance: red first — with a relative AGENTDESCENT_CACHE and a relative XDG_CACHE_HOME, _cache_root() and cache_path() must return absolute paths under the intended directory; with neither variable set the path must be exactly today's CACHE_ROOT; the hf_rows_modelscope docstring must name both knobs and no longer claim a fixed ~/.cache/...; no network or model call in the tests; docs/changelog.

Written-by: AgentDescent Dev-3

Activity

  1. added
    bug
    area:bench
    risk:T2
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:benchbugrisk:T2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions