From 47dc1a6569ebae7200407039e7d855f73d89d9aa Mon Sep 17 00:00:00 2001 From: houguokun Date: Wed, 15 Apr 2026 09:24:38 +0800 Subject: [PATCH] fix: mark discarded no-reasoning prompts completed on resume --- batch_runner.py | 1 + tests/test_batch_runner_checkpoint.py | 31 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/batch_runner.py b/batch_runner.py index 195452c0ae0c..2e1623c9eebf 100644 --- a/batch_runner.py +++ b/batch_runner.py @@ -444,6 +444,7 @@ def _process_batch_worker(args: Tuple) -> Dict[str, Any]: if not reasoning.get("has_any_reasoning", True): print(f" 🚫 Prompt {prompt_index} discarded (no reasoning in any turn)") discarded_no_reasoning += 1 + completed_in_batch.append(prompt_index) continue # Get and normalize tool stats for consistent schema across all entries diff --git a/tests/test_batch_runner_checkpoint.py b/tests/test_batch_runner_checkpoint.py index 4ce105d75dec..440e421cc507 100644 --- a/tests/test_batch_runner_checkpoint.py +++ b/tests/test_batch_runner_checkpoint.py @@ -12,7 +12,7 @@ import sys sys.path.insert(0, str(Path(__file__).parent.parent)) -from batch_runner import BatchRunner +from batch_runner import BatchRunner, _process_batch_worker @pytest.fixture @@ -157,3 +157,32 @@ def test_different_run_name_starts_fresh(self, runner): assert checkpoint_data["completed_prompts"] == [] assert checkpoint_data["run_name"] == "test_run" + + +class TestBatchWorkerResumeBehavior: + def test_discarded_no_reasoning_prompts_are_marked_completed(self, tmp_path, monkeypatch): + batch_file = tmp_path / "batch_1.jsonl" + prompt_result = { + "success": True, + "trajectory": [{"role": "assistant", "content": "x"}], + "reasoning_stats": {"has_any_reasoning": False}, + "tool_stats": {}, + "metadata": {}, + "completed": True, + "api_calls": 1, + "toolsets_used": [], + } + + monkeypatch.setattr("batch_runner._process_single_prompt", lambda *args, **kwargs: prompt_result) + + result = _process_batch_worker(( + 1, + [(0, {"prompt": "hi"})], + tmp_path, + set(), + {"verbose": False}, + )) + + assert result["discarded_no_reasoning"] == 1 + assert result["completed_prompts"] == [0] + assert not batch_file.exists() or batch_file.read_text() == ""