diff --git a/scripts/evaluation/codex.py b/scripts/evaluation/codex.py index f9b3b55b8..f31de08c1 100644 --- a/scripts/evaluation/codex.py +++ b/scripts/evaluation/codex.py @@ -364,7 +364,7 @@ async def _execute_app_server( if not stderr_reader.done(): stderr_reader.cancel() reader_result = (await asyncio.gather(stderr_reader, return_exceptions=True))[0] - if isinstance(reader_result, BaseException): + if isinstance(reader_result, BaseException) and not isinstance(reader_result, asyncio.CancelledError): failure = failure or type(reader_result).__name__ return { "returncode": process.returncode, diff --git a/tests/test_agent_evaluation_codex.py b/tests/test_agent_evaluation_codex.py index 6c0963cf3..4bd7aa16b 100644 --- a/tests/test_agent_evaluation_codex.py +++ b/tests/test_agent_evaluation_codex.py @@ -71,8 +71,16 @@ async def test_execute_sends_exact_prompt_and_preserves_nonzero_exit_output(tmp_ @pytest.mark.asyncio -async def test_execute_app_server_preserves_streamed_terminal_evidence(tmp_path: Path) -> None: +async def test_execute_app_server_preserves_streamed_terminal_evidence( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: """app-server 的终端增量和同一进程输入事件应归一化为可评分的原生轨迹。""" + async def hold_stderr_reader(stream: asyncio.StreamReader, result: bytearray) -> None: + """让测试覆盖正常收尾时主动取消 stderr 读取任务的路径。""" + del stream, result + await asyncio.Future() + + monkeypatch.setattr(codex, "_read_output", hold_stderr_reader) command = _program(tmp_path, """ import json import sys