Skip to content

The agent that grows with you

test: native provider suites: KNOWN xfails fail only on their symptom; codex orphan released without a foreign kill

teknium1229d13bc9335
diff --git a/tests/e2e/core/providers/_native_helpers.py b/tests/e2e/core/providers/_native_helpers.py
index 36cb3dbbd80..c6fa61ccad0 100644
--- a/tests/e2e/core/providers/_native_helpers.py
+++ b/tests/e2e/core/providers/_native_helpers.py
@@ -169,15 +169,24 @@ def tool_calls_of(row: dict[str, Any]) -> list[dict[str, Any]]:
return json.loads(raw) if raw else []
-def wait_until(predicate: Callable[[], Any], timeout: float, what: str, interval: float = 0.05) -> Any:
- """Poll ``predicate`` until truthy or raise with ``what`` (no bare sleeps as synchronization)."""
+class KnownSymptom(AssertionError):
+ """Raised ONLY at a tracked bug's exact symptom.
+
+ Every KNOWN strict xfail uses ``raises=KnownSymptom`` so a harness failure (process death, timeout,
+ precondition assert, fixture teardown error) fails for real instead of counting as the known bug.
+ """
+
+
+def wait_until(predicate: Callable[[], Any], timeout: float, what: str, interval: float = 0.05,
+ error: type[AssertionError] = AssertionError) -> Any:
+ """Poll ``predicate`` until truthy or raise ``error`` naming ``what`` (no bare sleeps as synchronization)."""
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
value = predicate()
if value:
return value
time.sleep(interval)
- raise AssertionError(f"timed out after {timeout}s waiting for {what}")
+ raise error(f"timed out after {timeout}s waiting for {what}")
def assert_no_duplicate_assistant_text(rows: list[dict[str, Any]], needle: str) -> None:
diff --git a/tests/e2e/core/providers/test_native_bedrock_converse_faults.py b/tests/e2e/core/providers/test_native_bedrock_converse_faults.py
index a201a8548e0..c822abe0117 100644
--- a/tests/e2e/core/providers/test_native_bedrock_converse_faults.py
+++ b/tests/e2e/core/providers/test_native_bedrock_converse_faults.py
@@ -19,7 +19,7 @@ import pytest
pytest.importorskip("botocore")
from tests.e2e.core.providers._native_helpers import ( # noqa: E402
- ChatResult, NativeHome, assert_no_duplicate_assistant_text, make_home, messages, run_chat,
+ ChatResult, KnownSymptom, NativeHome, assert_no_duplicate_assistant_text, make_home, messages, run_chat,
)
from tests.fakes.providers.bedrock_converse import ( # noqa: E402
ACCESS_KEY, REGION, SECRET_KEY, Drop, FakeBedrock, HttpError, Reasoning, Reply, StreamException, Text,
@@ -132,23 +132,28 @@ def test_mid_stream_drop_retries_without_duplicated_persisted_content(runs: dict
assert run["requests"][0]["reply"] == "Drop", run["requests"][0]
[email protected](strict=True, reason=KNOWN["eof_before_message_stop"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["eof_before_message_stop"])
def test_stream_ending_before_message_stop_is_not_accepted(runs: dict[str, Any]) -> None:
run = runs["eof_before_message_stop"]
assert run["result"].returncode == 0, run["result"].describe()
+ assert run["requests"] and run["requests"][0]["reply"] == "Drop", run["requests"]
rows = [r["content"] for r in _assistant_rows(run["nh"])]
sent = len(run["requests"])
# Symptom: the truncated first stream is persisted as the final answer and never retried.
- assert (sent, rows) == (2, [FINAL]), f"{KNOWN['eof_before_message_stop']}: requests={sent} rows={rows}"
+ if sent == 1 and rows and FINAL.startswith(rows[-1]) and rows[-1] != FINAL:
+ raise KnownSymptom(f"{KNOWN['eof_before_message_stop']}: requests={sent} rows={rows}")
+ assert (sent, rows) == (2, [FINAL]), f"requests={sent} rows={rows}"
[email protected](strict=True, reason=KNOWN["validation_retried"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["validation_retried"])
def test_validation_exception_is_surfaced_once_without_retry(runs: dict[str, Any]) -> None:
run = runs["validation"]
result: ChatResult = run["result"]
- # Symptom: the 400 is retried (the scripted success behind it is reached).
sent = len(run["requests"])
- assert sent == 1, f"{KNOWN['validation_retried']}: fake saw {sent} requests"
+ assert sent >= 1 and run["requests"][0]["reply"] == "HttpError", run["requests"]
+ # Symptom: the 400 is retried (the scripted success behind it is reached).
+ if sent > 1:
+ raise KnownSymptom(f"{KNOWN['validation_retried']}: fake saw {sent} requests")
shown = result.stdout + result.stderr
assert result.returncode != 0 and FINAL not in shown, result.describe()
assert VALIDATION_MARK in shown and "ValidationException" in shown, result.describe()
diff --git a/tests/e2e/core/providers/test_native_bedrock_converse_turns.py b/tests/e2e/core/providers/test_native_bedrock_converse_turns.py
index fd3c2411588..6e291e97bd2 100644
--- a/tests/e2e/core/providers/test_native_bedrock_converse_turns.py
+++ b/tests/e2e/core/providers/test_native_bedrock_converse_turns.py
@@ -21,7 +21,7 @@ import pytest
pytest.importorskip("botocore")
from tests.e2e.core.providers._native_helpers import ( # noqa: E402
- ChatResult, NativeHome, latest_session, make_home, messages, run_chat, session_ids, tool_calls_of,
+ ChatResult, KnownSymptom, NativeHome, latest_session, make_home, messages, run_chat, session_ids, tool_calls_of,
)
from tests.fakes.providers.bedrock_converse import ( # noqa: E402
ACCESS_KEY, REGION, SECRET_KEY, FakeBedrock, Reasoning, Text, ToolUse, Turn, seq,
@@ -225,11 +225,13 @@ def _reasoning_rows(nh: NativeHome) -> list[str]:
return [r["reasoning_content"] for r in messages(nh) if r["role"] == "assistant" and r["reasoning_content"]]
[email protected](strict=True, reason=KNOWN["reasoning_shredded"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["reasoning_shredded"])
def test_persisted_reasoning_equals_the_streamed_reasoning_text(runs: dict[str, Any]) -> None:
+ _ok(runs["tools"]["result"])
persisted = _reasoning_rows(runs["tools"]["nh"])
assert [p.replace("\n\n", "") for p in persisted] == [R_A1, R_A2, R_A3], persisted
- assert persisted == [R_A1, R_A2, R_A3], f"{KNOWN['reasoning_shredded']}: {persisted}"
+ if persisted != [R_A1, R_A2, R_A3]: # same text once the blank lines are removed: exactly the bug
+ raise KnownSymptom(f"{KNOWN['reasoning_shredded']}: {persisted}")
# --------------------------------------------------------------------------------------------------
@@ -256,15 +258,22 @@ def test_resume_in_new_process_replays_tool_history_valid_for_converse(runs: dic
assert rows[-1]["content"] == FINAL_B2
[email protected](strict=True, reason=KNOWN["resume_drops_reasoning"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["resume_drops_reasoning"])
def test_resume_replays_signed_reasoning_verbatim(runs: dict[str, Any]) -> None:
- requests = runs["resume"]["requests"]
+ run = runs["resume"]
+ _ok(run["first"])
+ _ok(run["second"])
+ requests = run["requests"]
+ assert len(requests) == 3, f"expected 2 turn-1 calls + 1 resumed call, fake saw {len(requests)}"
signed = [b for b in requests[0]["emitted"] if "reasoningContent" in b]
+ assert signed, requests[0]["emitted"]
# In-process the tool-use turn goes back with its signed reasoning ...
assert requests[1]["body"]["messages"][1]["content"][0] == signed[0]
# ... and after --resume (new process) it must be identical.
resumed = requests[2]["body"]["messages"]
- assert resumed[1]["content"][0] == signed[0], f"{KNOWN['resume_drops_reasoning']}: {resumed[1]['content']}"
+ if not [b for b in resumed[1]["content"] if "reasoningContent" in b]:
+ raise KnownSymptom(f"{KNOWN['resume_drops_reasoning']}: {resumed[1]['content']}")
+ assert resumed[1]["content"][0] == signed[0], resumed[1]["content"]
assert [b for b in resumed[3]["content"] if "reasoningContent" in b] == [
b for b in requests[1]["emitted"] if "reasoningContent" in b]
diff --git a/tests/e2e/core/providers/test_native_codex_app_server.py b/tests/e2e/core/providers/test_native_codex_app_server.py
index cebe74c6ee2..6e6fdfd3f9b 100644
--- a/tests/e2e/core/providers/test_native_codex_app_server.py
+++ b/tests/e2e/core/providers/test_native_codex_app_server.py
@@ -19,10 +19,14 @@ from concurrent.futures import ThreadPoolExecutor
import pytest
-from tests.e2e.core.providers._native_helpers import messages, tool_calls_of
+from tests.e2e.core.providers._native_helpers import KnownSymptom, messages, tool_calls_of
from tests.fakes.providers.codex_app_server import CodexRun, run_codex_scenario
-pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="POSIX sh wrapper for the fake codex binary")
+pytestmark = [
+ pytest.mark.skipif(sys.platform == "win32", reason="POSIX sh wrapper for the fake codex binary"),
+ # CodexRun.cleanup() SIGKILLs any app-server that outlived its CLI (reparented to init by then).
+ pytest.mark.live_system_guard_bypass,
+]
KNOWN = {
"compaction_row": "#121301 native contextCompaction item persisted as a raw-JSON assistant message",
@@ -191,8 +195,12 @@ def test_native_compaction_keeps_thread_and_transcript(runs):
assert texts == ["C-ONE", "C-TWO", "C-THREE"], f"transcript rewritten or duplicated: {rows}"
[email protected](strict=True, reason=KNOWN["compaction_row"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["compaction_row"])
def test_native_compaction_is_not_persisted_as_assistant_text(runs):
- rows = _rows(runs["compact"])
+ run = runs["compact"]
+ assert [r.returncode for r in run.results] == [0, 0], "\n".join(r.describe() for r in run.results)
+ rows = _rows(run)
+ assert any(r["content"] == "C-TWO" for r in rows), f"post-compaction answer not persisted: {rows}"
leaked = [r["content"] for r in rows if "contextCompaction" in (r.get("content") or "")]
- assert not leaked, f"compaction boundary persisted as assistant content: {leaked}"
+ if leaked:
+ raise KnownSymptom(f"compaction boundary persisted as assistant content: {leaked}")
diff --git a/tests/e2e/core/providers/test_native_codex_app_server_faults.py b/tests/e2e/core/providers/test_native_codex_app_server_faults.py
index 0f1d4d545f9..0629e06f25b 100644
--- a/tests/e2e/core/providers/test_native_codex_app_server_faults.py
+++ b/tests/e2e/core/providers/test_native_codex_app_server_faults.py
@@ -13,10 +13,15 @@ from concurrent.futures import ThreadPoolExecutor
import pytest
-from tests.e2e.core.providers._native_helpers import messages, wait_until
+from tests.e2e.core.providers._native_helpers import KnownSymptom, messages, wait_until
from tests.fakes.providers.codex_app_server import CodexRun, pid_alive, run_codex_scenario
-pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="POSIX sh wrapper + /proc PID checks")
+pytestmark = [
+ pytest.mark.skipif(sys.platform == "win32", reason="POSIX sh wrapper + /proc PID checks"),
+ # The orphaned own-session grandchild (#121298) is released cooperatively by CodexRun.cleanup(); the
+ # bypass covers its SIGKILL fallback for anything still alive (reparented to init by then).
+ pytest.mark.live_system_guard_bypass,
+]
KNOWN = {
"q_approval": "#121296 approval in `chat -q` waits the full approvals.timeout instead of single_query_mode",
@@ -98,36 +103,45 @@ def test_will_retry_error_notification_is_not_terminal(runs):
assert _assistant_texts(run) == ["RETRY-OK"]
[email protected](strict=True, reason=KNOWN["failed_hidden"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["failed_hidden"])
def test_failed_turn_after_agent_message_surfaces_reason(runs):
run = runs["failed_hidden"]
assert run.results[0].returncode != 0 and "PARTIAL-B" in run.results[0].stdout, run.results[0].describe()
- assert "FAIL-MARKER-89" in run.output, "turn failure reason never shown to the user"
+ if "FAIL-MARKER-89" not in run.output:
+ raise KnownSymptom(f"turn failure reason never shown to the user: {run.output!r}")
[email protected](strict=True, reason=KNOWN["q_approval"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["q_approval"])
def test_single_query_approval_resolves_without_waiting_for_a_human(runs):
run = runs["q_approval"]
entries = run.fake.entries()
- sent = next(e for e in entries if e.get("dir") == "out"
- and e["msg"].get("method") == "item/commandExecution/requestApproval")
- reply = next(e for e in entries if e.get("reply_to") == "item/commandExecution/requestApproval")
- assert reply["msg"]["id"] == sent["msg"]["id"] and not reply.get("violation"), reply
- waited = reply["t"] - sent["t"]
- assert waited < APPROVAL_TIMEOUT_S / 2, f"approval parked {waited:.1f}s on a prompt nobody can answer in -q"
-
-
[email protected](strict=True, reason=KNOWN["permissions"])
+ sent = [e for e in entries if e.get("dir") == "out"
+ and e["msg"].get("method") == "item/commandExecution/requestApproval"]
+ replies = [e for e in entries if e.get("reply_to") == "item/commandExecution/requestApproval"]
+ assert len(sent) == 1 and len(replies) == 1, f"approval request/reply not exchanged once: {sent} {replies}"
+ reply = replies[0]
+ assert reply["msg"]["id"] == sent[0]["msg"]["id"] and not reply.get("violation"), reply
+ waited = reply["t"] - sent[0]["t"]
+ if waited >= APPROVAL_TIMEOUT_S / 2:
+ raise KnownSymptom(f"approval parked {waited:.1f}s on a prompt nobody can answer in -q")
+
+
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["permissions"])
def test_permissions_request_reply_matches_protocol(runs):
run = runs["permissions"]
replies = run.fake.replies_to("item/permissions/requestApproval")
assert len(replies) == 1, f"permissions request unanswered: {replies}"
- assert not replies[0].get("violation"), f"invalid PermissionsRequestApprovalResponse: {replies[0]}"
+ violation = replies[0].get("violation") or ""
+ if "permissions" in violation:
+ raise KnownSymptom(f"PermissionsRequestApprovalResponse without `permissions`: {replies[0]}")
+ assert not violation, f"invalid PermissionsRequestApprovalResponse: {replies[0]}"
[email protected](strict=True, reason=KNOWN["orphan"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["orphan"])
def test_cli_exit_reaps_app_server_descendants(runs):
run = runs["orphan"]
assert run.results[0].returncode == 0 and "REAP-DONE" in run.results[0].stdout, run.results[0].describe()
- (child,) = run.fake.grandchild_pids()
- wait_until(lambda: not pid_alive(child), 3.0, f"app-server descendant {child} to be reaped after CLI exit")
+ children = run.fake.grandchild_pids()
+ assert len(children) == 1, f"the fake must have spawned exactly one descendant: {children}"
+ wait_until(lambda: not pid_alive(children[0]), 3.0,
+ f"app-server descendant {children[0]} to be reaped after CLI exit", error=KnownSymptom)
diff --git a/tests/e2e/core/providers/test_native_copilot_acp.py b/tests/e2e/core/providers/test_native_copilot_acp.py
index 91ebfb4f67c..ac0bdbbf62e 100644
--- a/tests/e2e/core/providers/test_native_copilot_acp.py
+++ b/tests/e2e/core/providers/test_native_copilot_acp.py
@@ -14,8 +14,8 @@ Contract under test (documented in ``agent/copilot_acp_client.py`` and the ACP s
schema-valid;
* ACP has no tools channel: Hermes' tools travel in the prompt text, a ``<tool_call>`` block in the
agent's message runs a REAL Hermes tool, and the result is in the next call's prompt;
-* ``--resume`` in a new process does NOT use ``session/load`` (even when the agent advertises it): it
- opens a new ACP session whose prompt carries the persisted history;
+* ``--resume`` in a new process runs in a new agent process whose prompt carries the persisted history
+ (turn 1 in order, then the new question), with nothing duplicated;
* agent-side ``session/request_permission`` is never granted (Hermes has no human channel there) and
``fs/read_text_file`` is confined to the session cwd;
* no agent process outlives the CLI, including one that ignores SIGTERM and stdin EOF.
@@ -23,6 +23,7 @@ Contract under test (documented in ``agent/copilot_acp_client.py`` and the ACP s
from __future__ import annotations
+import contextlib
import os
import signal
import sys
@@ -35,6 +36,7 @@ import pytest
from tests.e2e.core.providers._native_helpers import (
ChatResult,
+ KnownSymptom,
NativeHome,
assert_no_duplicate_assistant_text,
latest_session,
@@ -72,10 +74,6 @@ SUMMARY = "SUMMARY-ACP-7f3: files f1..fN were read; each is lorem ipsum filler."
FINAL_COMPACT = "All eight files read (FINAL-COMPACT)."
-class KnownSymptom(AssertionError):
- """Raised ONLY for a tracked bug's exact symptom, so a strict xfail cannot hide an unrelated failure."""
-
-
KNOWN: dict[str, str] = {
"late_chunk": "#65788 agent_message_chunk emitted after the session/prompt result is dropped",
}
@@ -108,7 +106,8 @@ def _reap(fake: acp.AcpFake) -> None:
"""Teardown: SIGKILL any fake agent this scenario spawned that is still alive (by recorded pid)."""
for pid in fake.pids():
if _alive(pid):
- os.kill(pid, signal.SIGKILL)
+ with contextlib.suppress(ProcessLookupError): # exited between the check and the kill
+ os.kill(pid, signal.SIGKILL)
# ── scenarios (independent; run concurrently in the module fixture) ──────────────────────────
@@ -247,14 +246,14 @@ def test_agent_permission_is_never_granted_and_fs_reads_stay_in_cwd(outcomes):
assert "error" in outside and SECRET not in str(outside), f"fs read escaped the session cwd: {outside}"
-def test_resume_opens_a_fresh_acp_session_seeded_with_persisted_history(outcomes):
- """``--resume`` in a new CLI process: a new agent process, ``session/new`` (never ``session/load``,
- although the agent advertises loadSession), and a prompt carrying turn 1 then the new question."""
+def test_resume_reaches_the_agent_with_persisted_history_in_order(outcomes):
+ """``--resume`` in a new CLI process: a new agent process whose prompt carries turn 1 (question, tool
+ result, answer) in order and then the new question; one session, nothing persisted twice. How the
+ ACP session is opened (seeded ``session/new`` or ``session/load``) is not part of the contract."""
sc = _flow_ok(outcomes)
assert FINAL_TWO in sc.runs[1].stdout, sc.runs[1].describe()
resumed_pids = [pid for pid in _calls(sc.fake) if pid not in sc.extra["turn1_pids"]]
assert len(resumed_pids) == 1, "the resumed turn must run in its own agent process"
- assert sc.fake.inbound("session/load") == [], "Hermes sent session/load; the contract is a seeded session/new"
text = acp.prompt_text(sc.fake.main_prompts()[-1])
order = [text.find(s) for s in (Q1, CANARY, FINAL_ONE, Q2)]
assert -1 not in order and order == sorted(order), f"resumed prompt lost or reordered history: {order}"
diff --git a/tests/e2e/core/providers/test_native_copilot_acp_errors.py b/tests/e2e/core/providers/test_native_copilot_acp_errors.py
index 08626575c19..ff7c65d9288 100644
--- a/tests/e2e/core/providers/test_native_copilot_acp_errors.py
+++ b/tests/e2e/core/providers/test_native_copilot_acp_errors.py
@@ -14,6 +14,7 @@ asserts the retry semantics the user sees:
from __future__ import annotations
+import contextlib
import os
import re
import signal
@@ -28,6 +29,7 @@ import pytest
from tests.e2e.core.providers._native_helpers import (
ChatResult,
+ KnownSymptom,
NativeHome,
latest_session,
make_home,
@@ -50,10 +52,6 @@ PARTIAL = "PARTIAL-BEFORE-CRASH "
CRASH_STDERR = "fatal: agent segfaulted (fake)"
-class KnownSymptom(AssertionError):
- """Raised ONLY for a tracked bug's exact symptom, so a strict xfail cannot hide an unrelated failure."""
-
-
KNOWN: dict[str, str] = {
"auth_remedy": "#121290 copilot-acp auth failure tells the user to run a hermes command that is not implemented",
}
@@ -119,7 +117,8 @@ def outcomes(tmp_path_factory: pytest.TempPathFactory):
for out in done.values():
for pid in out.fake.pids():
if _alive(pid):
- os.kill(pid, signal.SIGKILL)
+ with contextlib.suppress(ProcessLookupError): # exited between the check and the kill
+ os.kill(pid, signal.SIGKILL)
@pytest.mark.parametrize("name", list(ROWS))
diff --git a/tests/e2e/core/providers/test_native_copilot_acp_streaming.py b/tests/e2e/core/providers/test_native_copilot_acp_streaming.py
index 9483039bb47..0d5894c8f9c 100644
--- a/tests/e2e/core/providers/test_native_copilot_acp_streaming.py
+++ b/tests/e2e/core/providers/test_native_copilot_acp_streaming.py
@@ -33,7 +33,7 @@ from typing import Any, Callable
import pytest
-from tests.e2e.core.providers._native_helpers import TURN_TIMEOUT, NativeHome, make_home
+from tests.e2e.core.providers._native_helpers import TURN_TIMEOUT, KnownSymptom, NativeHome, make_home
from tests.fakes.providers import copilot_acp as acp
pytest.importorskip("acp.schema", reason="the fake validates against the agent-client-protocol package (acp extra)")
@@ -49,10 +49,6 @@ MIN_SPAN_S = THOUGHT_STEPS * STEP_S * 0.75 # vacuity: the agent really spent se
MARKERS = (HEAD.strip(), THOUGHT, ANSWER)
-class KnownSymptom(AssertionError):
- """Raised ONLY for a tracked bug's exact symptom, so a strict xfail cannot hide an unrelated failure."""
-
-
KNOWN: dict[str, str] = {
"tui_stream": "#120550 copilot-acp buffers the whole turn: no reasoning/message delta reaches the UI in flight",
"nested_acp": "#101507 hermes acp over copilot-acp forwards inner ACP chunks only after the inner turn ends",
diff --git a/tests/e2e/core/providers/test_native_gemini_errors.py b/tests/e2e/core/providers/test_native_gemini_errors.py
index 4f8e97506d8..94807db1f81 100644
--- a/tests/e2e/core/providers/test_native_gemini_errors.py
+++ b/tests/e2e/core/providers/test_native_gemini_errors.py
@@ -127,14 +127,18 @@ TERMINAL = { # case -> a word the surfaced error must carry (None: any visible
def _terminal_param(name: str):
- marks = [pytest.mark.xfail(strict=True, reason=KNOWN[name])] if name in KNOWN else []
+ marks = [pytest.mark.xfail(strict=True, raises=nh.KnownSymptom, reason=KNOWN[name])] if name in KNOWN else []
return pytest.param(name, marks=marks, id=name)
@pytest.mark.parametrize("name", [_terminal_param(n) for n in TERMINAL])
def test_non_retryable_surfaced_once(outcomes: dict[str, Outcome], name: str) -> None:
o = outcomes[name]
- assert len(o.calls) == 1, f"terminal Google response was re-sent {len(o.calls)}x\n{o.describe()}"
+ assert o.calls, f"no request reached the fake\n{o.describe()}"
+ if len(o.calls) != 1:
+ # The tracked bug's symptom for KNOWN cases; a plain failure for every other terminal case.
+ failure = nh.KnownSymptom if name in KNOWN else AssertionError
+ raise failure(f"terminal Google response was re-sent {len(o.calls)}x\n{o.describe()}")
assert o.result.returncode != 0, o.describe()
word = TERMINAL[name]
lines = [ln.strip() for ln in o.result.stdout.splitlines() if ln.strip()]
diff --git a/tests/e2e/core/providers/test_native_gemini_schema.py b/tests/e2e/core/providers/test_native_gemini_schema.py
index 3ec97ec9e74..1fec461b2b0 100644
--- a/tests/e2e/core/providers/test_native_gemini_schema.py
+++ b/tests/e2e/core/providers/test_native_gemini_schema.py
@@ -169,15 +169,19 @@ def test_v1_proto_schema_declaration_is_accepted(outcomes: dict[str, Outcome]) -
assert params["required"] == ["query"], params
[email protected](strict=True, reason=KNOWN["ref_dropped_v1"])
[email protected](strict=True, raises=nh.KnownSymptom, reason=KNOWN["ref_dropped_v1"])
def test_v1_ref_parameter_keeps_its_shape(outcomes: dict[str, Outcome]) -> None:
- params = outcomes["v1"].declaration()["parameters"]
- assert params["properties"]["mode"].get("enum") == ["fast", "slow"], (
- f"$ref-typed parameter lost its shape on the v1 wire: {params['properties']['mode']}")
+ _assert_round_trip(outcomes["v1"], "v1")
+ mode = outcomes["v1"].declaration()["parameters"]["properties"]["mode"]
+ if mode == {}:
+ raise nh.KnownSymptom(f"$ref-typed parameter lost its shape on the v1 wire: {mode}")
+ assert mode.get("enum") == ["fast", "slow"], mode
[email protected](strict=True, reason=KNOWN["array_items_v1"])
[email protected](strict=True, raises=nh.KnownSymptom, reason=KNOWN["array_items_v1"])
def test_v1_array_without_items_is_accepted(outcomes: dict[str, Outcome]) -> None:
o = outcomes["v1_itemless"]
- assert not any("items: missing field" in r for r in o.rejections), o.rejections
+ assert o.calls, o.result.describe()
+ if any("items: missing field" in r for r in o.rejections):
+ raise nh.KnownSymptom(f"Google rejected the item-less array: {o.rejections}")
_assert_round_trip(o, "v1")
diff --git a/tests/e2e/core/providers/test_native_vertex_errors.py b/tests/e2e/core/providers/test_native_vertex_errors.py
index 43fac257ff6..5f8087458fe 100644
--- a/tests/e2e/core/providers/test_native_vertex_errors.py
+++ b/tests/e2e/core/providers/test_native_vertex_errors.py
@@ -21,7 +21,7 @@ import pytest
pytest.importorskip("google.auth", reason="Vertex minting needs google-auth (CI installs it)")
-from tests.e2e.core.providers._native_helpers import ChatResult, make_home, run_chat # noqa: E402
+from tests.e2e.core.providers._native_helpers import ChatResult, KnownSymptom, make_home, run_chat # noqa: E402
from tests.fakes.providers.vertex import ( # noqa: E402
PROJECT,
REGION,
@@ -137,7 +137,7 @@ def test_oauth_invalid_grant_sends_nothing_and_names_the_credential(results: dic
def _guidance_param(name: str) -> Any:
- return pytest.param(name, marks=pytest.mark.xfail(strict=True, raises=AssertionError, reason=KNOWN[f"guidance:{name}"]))
+ return pytest.param(name, marks=pytest.mark.xfail(strict=True, raises=KnownSymptom, reason=KNOWN[f"guidance:{name}"]))
@pytest.mark.parametrize("name", [_guidance_param("permission_denied"), _guidance_param("unauthenticated")])
@@ -149,4 +149,5 @@ def test_auth_failure_guidance_is_vertex_specific(results: dict[str, Any], name:
if not (res["fake"].requests and turn.returncode != 0):
raise RuntimeError(f"{name}: the auth failure never happened:\n{turn.describe()}")
guidance = _output(turn).split("Provider said:")[0].lower()
- assert "api key" not in guidance, f"Vertex auth failure blamed on an API key:\n{turn.stdout}"
+ if "api key" in guidance:
+ raise KnownSymptom(f"Vertex auth failure blamed on an API key:\n{turn.stdout}")
diff --git a/tests/e2e/core/providers/test_native_vertex_tools.py b/tests/e2e/core/providers/test_native_vertex_tools.py
index f00f340e960..d63048d83d8 100644
--- a/tests/e2e/core/providers/test_native_vertex_tools.py
+++ b/tests/e2e/core/providers/test_native_vertex_tools.py
@@ -27,6 +27,7 @@ pytest.importorskip("google.auth", reason="Vertex minting needs google-auth (CI
from tests.e2e.core.providers._native_helpers import ( # noqa: E402
ChatResult,
+ KnownSymptom,
NativeHome,
latest_session,
make_home,
@@ -234,12 +235,13 @@ def test_expired_token_is_reminted_and_request_retried(results: dict[str, Any])
assert [r["role"] for r in rows] == ["user", "assistant", "tool", "assistant"], rows
[email protected](strict=True, raises=AssertionError, reason=KNOWN["default_toolset"])
[email protected](strict=True, raises=KnownSymptom, reason=KNOWN["default_toolset"])
def test_default_toolset_schemas_accepted_by_vertex(results: dict[str, Any]) -> None:
"""With Hermes' default toolsets every tool declaration must survive Vertex's translation."""
res = results["default_toolset"]
fake = res["fake"]
require(fake.requests and fake.requests[0]["auth"].startswith("Bearer ya29."), "turn never reached Vertex")
schema_rejects = [r["rejected"] for r in fake.rejected() if "schema type should be ARRAY" in (r["rejected"] or "")]
- assert not schema_rejects, f"Vertex rejected the tool declarations: {schema_rejects[0]}"
+ if schema_rejects:
+ raise KnownSymptom(f"Vertex rejected the tool declarations: {schema_rejects[0]}")
assert "Default toolset answer." in res["turn"].stdout, res["turn"].describe()
diff --git a/tests/fakes/providers/codex_app_server.py b/tests/fakes/providers/codex_app_server.py
index ca3b7cacf01..2f756027256 100644
--- a/tests/fakes/providers/codex_app_server.py
+++ b/tests/fakes/providers/codex_app_server.py
@@ -34,6 +34,7 @@ from typing import Any, Callable, Optional
CLI_VERSION = "0.147.0"
INVALID_REQUEST = -32600
+GRANDCHILD_RELEASE = "release-grandchildren"
# ---------------------------------------------------------------------------------------------------
@@ -579,10 +580,19 @@ def _step_permissions(ctx: _TurnCtx, step: dict) -> None:
permissions={"network": {"enabled": True}}))
+# The descendant lives until the harness drops the release file (or 600 s pass), so the test side can
+# retire an orphan without signalling a process that is no longer in its own subtree.
+_GRANDCHILD = ("import os, sys, time\n"
+ "deadline = time.monotonic() + 600\n"
+ "while time.monotonic() < deadline and not os.path.exists(sys.argv[1]):\n"
+ " time.sleep(0.2)\n")
+
+
def _step_grandchild(ctx: _TurnCtx, step: dict) -> None:
"""A descendant in its own session (like codex's stdio MCP servers)."""
- child = subprocess.Popen([sys.executable, "-c", "import time; time.sleep(600)"], stdin=subprocess.DEVNULL,
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True)
+ child = subprocess.Popen([sys.executable, "-c", _GRANDCHILD, str(ctx.server.state_dir / GRANDCHILD_RELEASE)],
+ stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
+ start_new_session=True)
ctx.server.record({"event": "grandchild", "child_pid": child.pid})
@@ -695,7 +705,14 @@ class CodexRun:
if e.get("dir") == "in" and e.get("msg", {}).get("method") == method and "id" in e["msg"]]
def cleanup(self) -> None:
- """Kill anything the fake spawned that is still alive (orphan scenarios)."""
+ """Retire anything the fake spawned that is still alive (orphan scenarios).
+
+ Orphaned descendants are released cooperatively first: by teardown they are reparented to init,
+ outside the test's process subtree, where a live-system guard (rightly) refuses to signal them."""
+ (self.fake.state_dir / GRANDCHILD_RELEASE).touch()
+ deadline = time.monotonic() + 10
+ while time.monotonic() < deadline and any(pid_alive(p) for p in self.fake.grandchild_pids()):
+ time.sleep(0.05)
for pid in self.fake.spawned_pids() + self.fake.grandchild_pids():
if pid_alive(pid):
with contextlib.suppress(OSError):