Skip to content

batch: scan trace dirs recursively so --continue actually resumes - #14

Merged
icexiaoche merged 1 commit into
LiberCoders:mainfrom
saikrishnarallabandi:fix-continue-rglob
Jul 31, 2026
Merged

batch: scan trace dirs recursively so --continue actually resumes#14
icexiaoche merged 1 commit into
LiberCoders:mainfrom
saikrishnarallabandi:fix-continue-rglob

Conversation

@saikrishnarallabandi

Copy link
Copy Markdown
Contributor

Problem

Two functions scan a trace directory with a non-recursive glob:

  • cli.py#L1082_scan_completed_trials, which backs --continue
  • cli.py#L1112_load_trial_results, whose docstring says "This allows merging with new results when using --continue"
for f in trace_dir.glob("*.jsonl"):

But a benchmark-suite run (--cli-only, or any --tasks-dir run through _run_benchmark_suite) writes traces two levels down:

<trace_dir>/<phase>/<task>_<hash>/<task>_<hash>.jsonl

so trace_dir.glob("*.jsonl") matches nothing.

Consequences

  1. --continue silently re-runs the entire suite. It finds zero completed trials and concludes nothing was ever done. There is no error — from the outside it is indistinguishable from normal progress.

  2. batch_results.json / batch_summary.json come out empty for the same runs, since _load_trial_results uses the same glob.

The first one is expensive with a metered model. Resuming a 150-task run that was 110 done re-ran 67 already-finished tasks against a paid API before we noticed — roughly 12M input tokens for nothing. We only caught it because unique task_ids stayed at 110 while grading_result events climbed past 170.

Reproduce

claw-anything batch --cli-only --benchmark-root ./benchmark \
  --model <m> --agent loop --parallel 4 --trace-dir /tmp/run
# let it finish some tasks, kill it, then:
claw-anything batch --cli-only --benchmark-root ./benchmark \
  --model <m> --agent loop --parallel 4 --continue /tmp/run/<subdir>

Before: Running 100 tasks ... — the full suite again.
After: Running 2 tasks ... / Running 38 tasks ... — only what is actually left.

Direct check:

python -c "
from pathlib import Path
d = Path('/tmp/run/<subdir>')
print('glob :', len(list(d.glob('*.jsonl'))))   # 0
print('rglob:', len(list(d.rglob('*.jsonl'))))  # 150
"

Fix

rglob at both call sites. For a flat trace dir (single run output) rglob is equivalent, so the single-task path is unaffected.

Environment

OS Ubuntu 22.04.5 LTS, kernel 6.8.0-124
Python 3.12.10
Docker 29.1.3 (--trial-in-container)
Invocation batch --cli-only --benchmark-root ./benchmark
Base commit verified on f9a0f63 and current main (e19dce2)

_scan_completed_trials and _load_trial_results glob <trace_dir>/*.jsonl, but
--cli-only writes traces two levels down at <trace_dir>/<phase>/<task>/<trace>.jsonl.
The scan finds nothing, so --continue concludes no trial ever completed and
silently re-runs the entire suite, and batch_results.json / batch_summary.json
come out empty. Both call sites use rglob.
@icexiaoche
icexiaoche merged commit 79ddab7 into LiberCoders:main Jul 31, 2026
@icexiaoche

Copy link
Copy Markdown
Collaborator

Thank you so much for your interest in our project and for taking the time to debug these!

We sincerely apologize that our codebase wasn't as polished as it should have been, and we're especially sorry for the 12M tokens you had to burn through because of this bug! We are actively working on optimizing the code to improve efficiency and reliability moving forward.

Thanks again for your valuable contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants