From d22fa746fd0a3ed4c834bf9f95f57db490db8091 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 11 Sep 2026 18:57:03 +0800 Subject: [PATCH] fix(agent): ignore expected app-server reader cancellation --- scripts/evaluation/codex.py | 2 +- tests/test_agent_evaluation_codex.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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