Repository navigation
Description
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 andos.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:944starts the detached child withcwd=rd.path— the run directory.agentdescent/evolvespec.py:352records the same fact for specs ("the CLI validates it where you typed the command, then a detached child runs it from the run directory"), andagentdescent/mcp.py:954-956resolves every relative spec path once for exactly this reason (EvolveSpec.absolutise()).- The dataset cache has no such resolution step. So
AGENTDESCENT_CACHE=rel-cachenames<the shell's cwd>/rel-cachefor the process that starts a run and<run dir>/rel-cachefor 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(...))forAGENTDESCENT_CACHEand forXDG_CACHE_HOME/agentdescent; - leave
CACHE_ROOTand the no-variable path byte-identical to today — no change to the default; - keep
cache_path(subdir, filename)'s signature and itsmakedirs, and thecache=Falsebypass contract inhf_rows/hf_rows_modelscope/fetch_bytes; - correct the
hf_rows_modelscopedocstring 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
fix(runstore): hand the detached child an absolute dataset cache root
docs(changelog): stop promising one spelled cache root for every caller