Skip to content

Commit 96fd502

Browse files
sjarmakclaude
andcommitted
feat: add --skip-existing and --missing-only flags to context retrieval agent
Enables efficient batch runs: --skip-existing: skip tasks with oracle_answer_agent.json / ground_truth_agent.json --missing-only: only process tasks with NO ground truth at all Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dfe1bde commit 96fd502

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

scripts/context_retrieval_agent.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,14 @@ def main() -> int:
13861386
"--max-tasks", type=int, default=0,
13871387
help="Process at most N tasks (0 = all). Useful for pilot runs.",
13881388
)
1389+
parser.add_argument(
1390+
"--skip-existing", action="store_true",
1391+
help="Skip tasks that already have an agent-generated oracle",
1392+
)
1393+
parser.add_argument(
1394+
"--missing-only", action="store_true",
1395+
help="Only process tasks that have NO ground truth at all (no oracle_answer.json, no ground_truth.json)",
1396+
)
13891397
parser.add_argument(
13901398
"--dry-run", action="store_true",
13911399
help="Show tasks without running agent",
@@ -1421,6 +1429,34 @@ def main() -> int:
14211429
log.error("No tasks found")
14221430
return 1
14231431

1432+
# Filter tasks based on flags
1433+
original_count = len(tasks)
1434+
if args.skip_existing or args.missing_only:
1435+
filtered = []
1436+
for t in tasks:
1437+
tests_dir = t / "tests"
1438+
suite = t.parent.name
1439+
# Check for agent-generated oracle
1440+
if args.skip_existing:
1441+
if suite.startswith("ccb_mcp_"):
1442+
if (tests_dir / "oracle_answer_agent.json").exists():
1443+
continue
1444+
else:
1445+
if (tests_dir / "ground_truth_agent.json").exists():
1446+
continue
1447+
# Check for ANY ground truth
1448+
if args.missing_only:
1449+
has_any = (
1450+
(tests_dir / "oracle_answer.json").exists()
1451+
or (tests_dir / "ground_truth.json").exists()
1452+
)
1453+
if has_any:
1454+
continue
1455+
filtered.append(t)
1456+
tasks = filtered
1457+
log.info("Filtered %d -> %d tasks (skip_existing=%s, missing_only=%s)",
1458+
original_count, len(tasks), args.skip_existing, args.missing_only)
1459+
14241460
if args.max_tasks > 0:
14251461
tasks = tasks[:args.max_tasks]
14261462

0 commit comments

Comments
 (0)