Repository navigation
hf_rows_modelscope(cache=False) still returns cached data #229
Description
Bug and scenario
Verified on merged main 8585b3fee5841ebe3389371838f8c9ccb0fd4bc6 (Python 3.12.14). A caller explicitly requesting fresh ModelScope rows with hf_rows_modelscope(cache=False) can receive old cached bytes instead. This is a public loader contract issue, independent of the A/B CLI.
Deterministic offline reproduction
Run from the repository root with the project dependencies installed. The URL reader is fully mocked and the cache is temporary; no provider or dataset endpoint is contacted.
PYTHONPATH=. python - <<'PY'
import json
import tempfile
import agentdescent.dataloader as dl
with tempfile.TemporaryDirectory(prefix="hf-modelscope-repro-") as root:
dl.CACHE_ROOT = root
state = {"answer": "old"}
calls = []
def fake_read(url, timeout):
calls.append(url)
return json.dumps([{
"question": "Q",
"answer": state["answer"],
"context": [["T", ["S"]]],
}]).encode()
dl._read_url = fake_read
first = dl.hf_rows_modelscope(
url="https://example.invalid/hotpotqa.json", limit=1, cache=True
)
state["answer"] = "fresh"
bypass = dl.hf_rows_modelscope(
url="https://example.invalid/hotpotqa.json", limit=1, cache=False
)
print(
"first_answer=", first[0]["answer"],
"cache_false_answer=", bypass[0]["answer"],
"mock_fetches=", len(calls),
"expected_fresh_fetches=2",
)
PYObserved:
first_answer= old cache_false_answer= old mock_fetches= 1 expected_fresh_fetches=2
Expected: first_answer=old, cache_false_answer=fresh, and two reads of the mocked source. The explicit bypass should not silently reuse a populated cache.
Source
hf_rows_modelscope accepts cache but unconditionally calls fetch_bytes; that helper reads an existing cache entry. The default-cache regression test_modelscope_rows_are_cached passes but does not cover bypass.
Acceptance criteria
cache=Falsebypasses previously cached bytes and fetches the current response.- Repeated uncached calls observe changing mocked responses.
- Preserve default
cache=Truereuse and context normalization. - Add offline regressions for both a prepopulated stale cache and repeated bypass calls, with no real network access.
- Keep bypass behavior consistent with the existing loader conventions; document any intended cache-write behavior explicitly.
Dependencies and prior evidence
Introduced with merged #204; no provider account, live dataset, or other feature is required to repair it. Scope: agentdescent/dataloader.py and loader tests. The separate A/B pairing and seed-wiring issues are tracked in #228.
Previously reported in the cache-bypass review comment and the final exact-head follow-up. Reproduced again on actual merged production code without overlaying a fix.
Dedup: current open work and all-state ModelScope/cache-bypass issue and PR searches found no separate tracking issue or repair PR.
Activity