Skip to content

Official Codebase of 3DCodeVerse

Python

tracks: RoundFailed carries typed transient/quota flags — the round loop stops reading messages

gaoypeng9c28e26f5968
diff --git a/harness/codeverse3d/contracts/agent.py b/harness/codeverse3d/contracts/agent.py
index 9c972202..228e6ef8 100644
--- a/harness/codeverse3d/contracts/agent.py
+++ b/harness/codeverse3d/contracts/agent.py
@@ -83,7 +83,11 @@ class AgentResult(BaseModel):
description="seconds of ``duration_s`` the session lost to provider errors — 503 / 429 / "
"overloaded / token-limit retries and their back-off inside the CLI — read from the CLI's "
"own log; 0.0 when none were seen or the CLI does not expose them. A step's effective "
- "time is ``duration_s - provider_wait_s`` (owner, 2026-09-22)",
+ "time is ``duration_s - provider_wait_s`` (owner, 2026-09-22). Sources "
+ "(cli_common.provider_wait): gemini-cli its stderr retry lines against its chat record — a "
+ "lower bound, its 5xx back-off is unannounced — plus the key rotation between attempts; "
+ "claude-code its stream-json ``api_retry`` events; agy the retry lines of its ``--log-file``; "
+ "codex none (its HTTP client retries without an event)",
)
tool_calls: int = 0
turns: int = Field(
@@ -93,8 +97,15 @@ class AgentResult(BaseModel):
errors: list[str] = Field(default_factory=list)
transient: bool = Field(
default=False,
- description="the session died on a transient-failure streak (503 / UNAVAILABLE / 429 in the CLI's "
- "own retry loop) and produced nothing — a 503 storm, not the task; the cheap single-shot "
- "path, hedged across keys, may still get through (measured 2026-09-07: 23 of 24 gemini-cli "
- "sessions in one evening)",
+ description="the session died of a provider failure a retry may get through — 5xx / UNAVAILABLE / "
+ "overloaded / a 429 rate limit / a dropped connection, as the CLI itself reported it — not of "
+ "the task: the round loop re-runs such a round once, and a session that also wrote nothing falls "
+ "back to the cheap single-shot path, hedged across keys (measured 2026-09-07: 23 of 24 gemini-cli "
+ "sessions of one evening died in a 503 storm)",
+ )
+ quota: bool = Field(
+ default=False,
+ description="the vendor's usage limit or credits are spent (codex 'You've hit your usage limit', "
+ "claude 'usage limit reached', an OpenAI insufficient_quota): nothing gets through until it "
+ "resets, so the round loop stops the run as agent_quota instead of retrying the round",
)
diff --git a/harness/codeverse3d/tracks/candidates.py b/harness/codeverse3d/tracks/candidates.py
index ca684582..b5775d1a 100644
--- a/harness/codeverse3d/tracks/candidates.py
+++ b/harness/codeverse3d/tracks/candidates.py
@@ -32,7 +32,7 @@ from codeverse3d.conventions import OBJECT_VIEWS_QUICK
from codeverse3d.orchestrator import BudgetExceeded, gate_error_count
from codeverse3d.proc import EventLog, fan_out
from codeverse3d.tracks.common import RunContext
-from codeverse3d.tracks.generation import GenerationTask
+from codeverse3d.tracks.generation import GenerationTask, is_model_outage
from codeverse3d.tracks.steps import (
RoundFailed,
RoundPipeline,
@@ -101,7 +101,10 @@ def run_best_of_n(track: Any, ctx: RunContext, tasks: Sequence[GenerationTask],
if not any(r.commit for r in records):
if budget_stop is not None:
raise budget_stop # nothing usable survived: the budget stop stands
- raise RoundFailed("; ".join(f"{r.label}: {r.notes}" for r in records) or "every candidate failed")
+ died = [r for r in results if isinstance(r, Exception)]
+ raise RoundFailed("; ".join(f"{r.label}: {r.notes}" for r in records) or "every candidate failed",
+ transient=any(e.transient if isinstance(e, RoundFailed) else is_model_outage(e) for e in died),
+ quota=any(isinstance(e, RoundFailed) and e.quota for e in died))
best = rank_candidates(records)[0]
records[best].selected = True
usage = sum((r.usage for r in records), Usage())
diff --git a/harness/codeverse3d/tracks/common.py b/harness/codeverse3d/tracks/common.py
index af426e53..8cda99ff 100644
--- a/harness/codeverse3d/tracks/common.py
+++ b/harness/codeverse3d/tracks/common.py
@@ -239,4 +239,7 @@ def generate_for(ctx: RunContext, task: GenerationTask) -> GenerationResult:
budget=sub.budget, events=sub.events)
again.usage = res.usage + again.usage
again.notes = f"agent session died in a 503 storm ({res.notes[:120]}) → single-shot: {again.notes}"
+ # the cheap route did not get through either: the task still died of the storm (the round
+ # loop's one retry keys on it — RoundFailed.transient)
+ again.transient = again.transient or not again.ok
return again
diff --git a/harness/codeverse3d/tracks/generation.py b/harness/codeverse3d/tracks/generation.py
index 04a210c7..67b7a30f 100644
--- a/harness/codeverse3d/tracks/generation.py
+++ b/harness/codeverse3d/tracks/generation.py
@@ -330,8 +330,14 @@ class GenerationResult(BaseModel):
)
transient: bool = Field(
default=False,
- description="the last session died on a transient-failure streak with no final answer "
- "(AgentResult.transient) — whatever it wrote before the wall is in files_changed",
+ description="the last session died of a provider failure (AgentResult.transient), or the call "
+ "raised one (a ModelError the retry layer marks retryable or answers 429/5xx: is_model_outage) — "
+ "whatever it wrote before the wall is in files_changed",
+ )
+ quota: bool = Field(
+ default=False,
+ description="the last session met the vendor's usage limit (AgentResult.quota): no retry gets "
+ "through until it resets",
)
storm: bool = Field(
default=False,
@@ -339,6 +345,25 @@ class GenerationResult(BaseModel):
"tracks fall back to the hedged single-shot path (tracks.common.generate_for)",
)
+ @classmethod
+ def from_error(cls, label: str, e: BaseException) -> GenerationResult:
+ """The failed result of a generation call that RAISED, classified by the error's type
+ rather than its message: the round loop reads ``transient`` / ``quota``, never text."""
+ return cls(ok=False, notes=f"{type(e).__name__}: {e}", label=label, transient=is_model_outage(e))
+
+
+def is_model_outage(e: BaseException) -> bool:
+ """Is this a *service* failure (the model is down) rather than a bad answer?
+
+ Read off the ``ModelError`` the models layer raises — ``retryable`` or an HTTP status of
+ capacity / rate limiting — never off its message. A 503 capacity storm reaches us only
+ after ``models.retry`` has already spent its whole storm budget waiting."""
+ from codeverse3d.models.base import ModelError
+
+ if isinstance(e, ModelError):
+ return bool(e.retryable) or e.status in (429, 500, 502, 503, 504, 529)
+ return False
+
# ----------------------------------------------------------------------------- strategies
def is_single_shot(agent_id: str) -> bool:
@@ -607,6 +632,9 @@ def run_agent_task(
not changes
and not acc.wrapped
and res.exit_reason not in ("timeout", "budget")
+ # a provider failure or a spent usage limit is not a bail: a second session meets the
+ # same wall (the storm fallback and the round loop's one retry handle a transient)
+ and not (res.transient or res.quota)
):
if events is not None:
events.emit("generate.silent_bail", label=task.label, exit_reason=res.exit_reason)
@@ -650,6 +678,7 @@ def run_agent_task(
sessions=acc.sessions,
turn_capped=acc.wrapped,
transient=bool(res.transient),
+ quota=bool(res.quota),
storm=not changes and bool(res.transient),
)
diff --git a/harness/codeverse3d/tracks/lifecycle.py b/harness/codeverse3d/tracks/lifecycle.py
index 361313f9..6ce9a412 100644
--- a/harness/codeverse3d/tracks/lifecycle.py
+++ b/harness/codeverse3d/tracks/lifecycle.py
@@ -57,8 +57,6 @@ from codeverse3d.tracks.steps import (
RoundPipeline,
failed_acceptance,
load_round_journal,
- looks_quota,
- looks_transport,
rejudge_round,
run_round,
sum_usage,
@@ -534,7 +532,7 @@ class BaseTrack:
previous=previous, files_hint=ctx.runtime.expected_files(ctx.plan),
extra_notes=self.round_extra_notes(ctx))
except RoundFailed as e:
- if looks_quota(str(e)):
+ if e.quota:
# The vendor's own usage limit: not a transport death (a retry meets the
# same wall) — the agent is gone until the limit resets. cmp8
# (2026-09-09): three runs filed a plateau on "You've hit your usage
@@ -543,13 +541,15 @@ class BaseTrack:
if index == 0:
raise
return _stop(RunStatus.AGENT_QUOTA)
- if index not in transport_retried and looks_transport(str(e)):
- # A vendor-CLI crash / 503 storm / dropped socket is not an agent
+ if index not in transport_retried and e.transient:
+ # A 503 storm / dropped socket / overloaded provider is not an agent
# verdict — the session never really happened. Re-run the SAME
# round once, baseline included (rc=247 alone killed three whole
# runs on 2026-08-29), before letting the failure mean anything.
# ``continue`` re-enters through the loop head, so the budget and
- # round ceilings still guard the retry.
+ # round ceilings still guard the retry. Typed since 2026-09-22
+ # (RoundFailed.transient): a session that merely timed out on its own
+ # work, or a CLI that crashed with no provider error, is not retried.
transport_retried.add(index)
ctx.events.emit("round.transport_retry", round=index, detail=str(e)[:500])
continue
diff --git a/harness/codeverse3d/tracks/scene_assets.py b/harness/codeverse3d/tracks/scene_assets.py
index 24f82e40..c0ac0a55 100644
--- a/harness/codeverse3d/tracks/scene_assets.py
+++ b/harness/codeverse3d/tracks/scene_assets.py
@@ -46,7 +46,7 @@ from codeverse3d.tracks.common import (
generate_for,
single_shot_ctx,
)
-from codeverse3d.tracks.generation import GenerationTask, is_single_shot
+from codeverse3d.tracks.generation import GenerationTask, is_model_outage, is_single_shot
from codeverse3d.tracks.planner import plan as run_planner
from codeverse3d.tracks.prompting import (
base_prompt_context,
@@ -101,18 +101,6 @@ class AssetResult(BaseModel):
clips: int = Field(default=0, description="glTF animation clips the hero GLB carries (a keyframed Blender part)")
-def is_model_outage(e: BaseException) -> bool:
- """Is this a *service* failure (the model is down) rather than a bad answer?
-
- A 503 capacity storm reaches us only after ``models.retry`` has already spent its
- whole storm budget waiting, so the escalation the harness would normally do —
- a full agent session, ten times the money and ten minutes — hits the same wall.
- """
- from codeverse3d.models.base import ModelError
-
- if isinstance(e, ModelError):
- return bool(e.retryable) or e.status in (429, 500, 502, 503, 504, 529)
- return False
def asset_api_summary(plan: ScenePlan, results: dict[str, AssetResult], alias: dict[str, str] | None = None) -> str:
diff --git a/harness/codeverse3d/tracks/steps.py b/harness/codeverse3d/tracks/steps.py
index 2e79464d..2ae271c3 100644
--- a/harness/codeverse3d/tracks/steps.py
+++ b/harness/codeverse3d/tracks/steps.py
@@ -71,47 +71,27 @@ RenderFn = Callable[[RunContext, int, BuildResult, Measurement | None], RenderSe
class RoundFailed(RuntimeError):
- """Every generation task of a round failed — nothing to build."""
+ """Every generation task of a round failed — nothing to build.
+ Typed, so the round loop never reads the message: ``transient`` — a task died of a
+ provider failure (a vendor-CLI 503 storm, a dropped socket, a ``ModelError`` outage), so
+ the round is re-run once before the failure may mean anything; ``quota`` — the vendor's
+ usage limit is spent, so the run stops as ``agent_quota``. Neither — the agents ran
+ and changed nothing: a ``no_change`` stop. The flags come from each backend's own
+ classification (``AgentResult``) through ``GenerationResult``; until 2026-09-22 the loop
+ substring-matched the joined notes, with a vocabulary that had drifted from the backends'
+ (a codex usage limit reached the loop only because the loop's list said "usage limit")."""
-#: error-text markers that mean a round DIED IN TRANSPORT (vendor CLI crash, 503
-#: storm, dropped socket) rather than the agent declining the work. They match
-#: ``RoundFailed`` messages, which join ``GenerationResult.notes`` as composed by
-#: ``agents/backends.py`` (``rc=N; response=<empty>; stderr tail: ...``) or by
-#: ``_run_phase`` from a raised ``ModelError`` (``... timed out``, ``503``).
-_TRANSPORT_MARKS = (
- "response=<empty>", "no result envelope", "503", "unavailable", "overloaded",
- "timed out", "etimedout", "econnreset", "socket hang up", "connection reset",
-)
-
-
-#: the vendor's own usage limit — the agent is gone until it resets, whatever we retry
-_QUOTA_MARKS = (
- "hit your usage limit", "usage limit", "purchase more credits", "quota exceeded", "insufficient_quota",
- "insufficient credits", "billing hard limit",
-)
-
+ def __init__(self, message: str, *, transient: bool = False, quota: bool = False) -> None:
+ super().__init__(message)
+ self.transient = transient
+ self.quota = quota
-def looks_quota(msg: str) -> bool:
- """True when a ``RoundFailed`` message says the VENDOR's usage limit is spent.
-
- Not a transport death (a retry meets the same wall) and not an agent verdict (the
- code did not stop improving): cmp8 (2026-09-09) filed three runs as ``plateau`` on
- "You've hit your usage limit … try again at Sep 14th"."""
- low = msg.lower()
- return any(m in low for m in _QUOTA_MARKS)
-
-
-def looks_transport(msg: str) -> bool:
- """True when a ``RoundFailed`` message carries a transport-death signature.
-
- An agent that ran fine and chose to change nothing reports ``rc=0;
- response=ok`` or plain task notes — none of the markers. A marker therefore
- separates "the session never really happened" (worth exactly one retry) from
- "the agent declined" (a ``no_change`` stop to respect).
- """
- low = msg.lower()
- return any(m in low for m in _TRANSPORT_MARKS)
+ @classmethod
+ def of(cls, results: Sequence[GenerationResult], default: str) -> RoundFailed:
+ """The round's failure: every task's notes, and the typed flags of any of them."""
+ return cls("; ".join(f"{r.label}: {r.notes}" for r in results) or default,
+ transient=any(r.transient for r in results), quota=any(r.quota for r in results))
def round_record_path(ctx: RunContext, index: int) -> Path:
@@ -153,18 +133,18 @@ def run_generation_tasks(ctx: RunContext, tasks: Sequence[GenerationTask]) -> li
picked = [(i, t) for i, t in enumerate(tasks) if t.phase == ph]
try:
got = _run_phase(ctx, [t for _, t in picked])
- except RoundFailed:
+ except RoundFailed as e:
# a phase in which nothing succeeded is not automatically a dead round:
# the earlier phases may have written the parts. Record the failures
- # and let the final check below decide.
- got = [GenerationResult(ok=False, notes="phase produced no change", label=t.label)
- for _, t in picked]
+ # (and why they failed) and let the final check below decide.
+ got = [GenerationResult(ok=False, notes="phase produced no change", label=t.label,
+ transient=e.transient, quota=e.quota) for _, t in picked]
for (i, _), r in zip(picked, got, strict=True):
out[i] = r
ok_any = ok_any or any(r.ok for r in got)
results_seq = [out[i] for i in range(len(tasks))]
if not ok_any:
- raise RoundFailed("; ".join(f"{r.label}: {r.notes}" for r in results_seq) or "no generation task succeeded")
+ raise RoundFailed.of(results_seq, "no generation task succeeded")
return results_seq
return _run_phase(ctx, list(tasks))
@@ -186,13 +166,13 @@ def _run_phase(ctx: RunContext, tasks: Sequence[GenerationTask]) -> list[Generat
if isinstance(r, BudgetExceeded) and budget_stop is None:
budget_stop = r # a failed item; the siblings' paid results still land in ``out``
ctx.events.emit("generate.failed", label=task.label, error=f"{type(r).__name__}: {r}")
- out.append(GenerationResult(ok=False, notes=f"{type(r).__name__}: {r}", label=task.label))
+ out.append(GenerationResult.from_error(task.label, r))
else:
out.append(r)
if not any(r.ok for r in out):
if budget_stop is not None:
raise budget_stop # nothing usable survived the phase
- raise RoundFailed("; ".join(f"{r.label}: {r.notes}" for r in out) or "no generation task succeeded")
+ raise RoundFailed.of(out, "no generation task succeeded")
ctx.budget.check() # phase boundary: single-shot money is booked non-enforcing upstream
return out
diff --git a/harness/tests/orchestrator_tracks/test_prompts_assets.py b/harness/tests/orchestrator_tracks/test_prompts_assets.py
index 92e0d90c..6981c1f0 100644
--- a/harness/tests/orchestrator_tracks/test_prompts_assets.py
+++ b/harness/tests/orchestrator_tracks/test_prompts_assets.py
@@ -181,7 +181,7 @@ def test_a_model_outage_is_not_an_escalation_signal() -> None:
"""A 503 reaches the asset stage only after models.retry spent its whole storm budget
waiting; escalating to a full agent session then costs 10× and hits the same wall."""
from codeverse3d.models.base import ModelError
- from codeverse3d.tracks.scene_assets import is_model_outage
+ from codeverse3d.tracks.generation import is_model_outage
assert is_model_outage(ModelError("high demand", retryable=True, status=503))
assert is_model_outage(ModelError("overloaded", status=529))
diff --git a/harness/tests/orchestrator_tracks/test_transport_retry.py b/harness/tests/orchestrator_tracks/test_transport_retry.py
index 854d1834..e78216c7 100644
--- a/harness/tests/orchestrator_tracks/test_transport_retry.py
+++ b/harness/tests/orchestrator_tracks/test_transport_retry.py
@@ -1,9 +1,14 @@
-"""The transport-retry lever: a round killed in TRANSPORT (vendor CLI crash, 503
-storm, dropped socket) is re-run exactly once before the failure may mean
-anything; an agent that ran fine and DECLINED the work is still a plateau.
+"""The transport-retry lever: a round killed by the PROVIDER (a 503 storm, a dropped
+socket, an overloaded API) is re-run exactly once before the failure may mean anything;
+an agent that ran fine and DECLINED the work is still a no_change stop; the vendor's
+spent usage limit stops the run as agent_quota.
Shipped after 2026-08-29: rc=247 gemini-cli crashes killed three whole runs at
-baseline, and a refine-round crash was delivered as a fake plateau (microscope)."""
+baseline, and a refine-round crash was delivered as a fake plateau (microscope).
+Typed since 2026-09-22: each backend classifies its own CLI's failure
+(``AgentResult.transient`` / ``.quota``), the flags ride ``GenerationResult`` into
+``RoundFailed``, and the loop reads them — it matched substrings of the joined
+notes before, with a vocabulary that had drifted from the backends'."""
from __future__ import annotations
import pytest
@@ -11,9 +16,11 @@ import pytest
from codeverse3d.contracts.agent import AgentJob, AgentResult
from codeverse3d.contracts.common import Language, Usage
from codeverse3d.contracts.run import RunStatus
+from codeverse3d.models.base import ModelError
from codeverse3d.proc import EventLog
+from codeverse3d.tracks.generation import GenerationResult
from codeverse3d.tracks.static_object import StaticObjectTrack
-from codeverse3d.tracks.steps import RoundFailed, looks_quota, looks_transport
+from codeverse3d.tracks.steps import RoundFailed
from codeverse3d.workspace import Workspace
from tests.orchestrator_tracks.conftest import make_spec
from tests.orchestrator_tracks.fakes import (
@@ -25,57 +32,30 @@ from tests.orchestrator_tracks.fakes import (
)
from tests.orchestrator_tracks.test_tracks import _agent_writer as _writer
-# --------------------------------------------------------------- signature unit
+# --------------------------------------------------------------- the typed failure
-TRANSPORT = [
- "generate: rc=247; response=<empty>; stderr tail: Error: 503 UNAVAILABLE",
- "refine: rc=1; response=<empty>; stderr tail: at process.processTicksAndRejections",
- "refine: ModelError: Gemini request timed out: The read operation timed out",
- "assembly: rc=3; no result envelope; stderr tail: read ECONNRESET",
- "gen: ApiError: 503 the model is overloaded",
-]
-VERDICTS = [
- "refine: exit=no_changes",
- "refine: exit=completed; errors=['skipped out-of-root paths: notes.md']",
- "no generation task succeeded",
- "every candidate failed",
- "refine: the agents judged the requested edits unnecessary",
-]
+def test_round_failed_carries_the_flags_of_its_tasks_never_their_words():
+ ok = GenerationResult(ok=False, notes="exit=completed; errors=['503 in a code comment']", label="a")
+ storm = GenerationResult(ok=False, notes="exit=error", label="b", transient=True)
+ spent = GenerationResult(ok=False, notes="exit=error", label="c", quota=True)
+ assert not RoundFailed.of([ok], "x").transient # a word in the notes is only a word
+ e = RoundFailed.of([ok, storm], "x")
+ assert e.transient and not e.quota and str(e) == "a: exit=completed; errors=['503 in a code comment']; b: exit=error"
+ assert RoundFailed.of([ok, spent], "x").quota
+ assert str(RoundFailed.of([], "no generation task succeeded")) == "no generation task succeeded"
-QUOTA = [
- "refine: exit=error; errors=[\"You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to "
- "purchase more credits or try again at Sep 14th, 2026 6:25 PM.\"]",
- "generate: RESOURCE_EXHAUSTED: quota exceeded for this project",
- "refine: insufficient_quota: You exceeded your current quota",
-]
-
-
[email protected]("msg", TRANSPORT)
-def test_transport_signatures_match(msg):
- assert looks_transport(msg)
-
-
[email protected]("msg", QUOTA)
-def test_quota_signatures_are_quota_not_transport(msg):
- """cmp8 (2026-09-09): the vendor's usage limit ran out mid-battery and three runs were
- filed as plateau — a retry meets the same wall, and the code did not stop improving."""
- assert looks_quota(msg) and not looks_transport(msg)
-
-
[email protected]("msg", TRANSPORT + VERDICTS)
-def test_transport_and_verdict_messages_are_not_quota(msg):
- assert not looks_quota(msg)
-
-
[email protected]("msg", VERDICTS)
-def test_agent_verdicts_do_not_match(msg):
- assert not looks_transport(msg)
+def test_a_raised_error_is_classified_by_its_type():
+ assert GenerationResult.from_error("g", ModelError("Gemini request timed out", retryable=True, status=408)).transient
+ assert GenerationResult.from_error("g", ModelError("Gemini API error 503", status=503)).transient
+ assert not GenerationResult.from_error("g", ModelError("bad request", status=400)).transient
+ assert not GenerationResult.from_error("g", ValueError("503 in the message")).transient
# --------------------------------------------------------------- track fixtures
CRASH = ["rc=247; response=<empty>; stderr tail: Error: 503 UNAVAILABLE (crash-test)"]
+QUOTA = "You've hit your usage limit. Visit https://chatgpt.com/codex/settings/usage to purchase more credits."
class CrashingAgent(FakeAgent):
@@ -90,7 +70,8 @@ class CrashingAgent(FakeAgent):
if job.round == self.crash_round and self.left != 0:
self.left -= 1
self.jobs.append(job)
- return AgentResult(ok=False, exit_reason="error", errors=list(CRASH), usage=Usage(cost_usd=0.01))
+ return AgentResult(ok=False, exit_reason="error", errors=list(CRASH), usage=Usage(cost_usd=0.01),
+ transient=True)
return super().run(job)
@@ -108,7 +89,8 @@ class CrashUntilRetried(FakeAgent):
retried = any(e["event"] == "round.transport_retry" for e in EventLog(ws.events_path).read())
if job.round == self.crash_round and not retried:
self.jobs.append(job)
- return AgentResult(ok=False, exit_reason="error", errors=list(CRASH), usage=Usage(cost_usd=0.01))
+ return AgentResult(ok=False, exit_reason="error", errors=list(CRASH), usage=Usage(cost_usd=0.01),
+ transient=True)
return super().run(job)
@@ -122,7 +104,7 @@ class QuotaAfterBaseline(FakeAgent):
if job.round == 0:
return super().run(job)
self.jobs.append(job)
- return AgentResult(ok=False, exit_reason="error", errors=[QUOTA[0]], usage=Usage(cost_usd=0.0))
+ return AgentResult(ok=False, exit_reason="error", errors=[QUOTA], usage=Usage(cost_usd=0.0), quota=True)
class IdleAfterBaseline(FakeAgent):
@@ -182,6 +164,31 @@ def test_baseline_transport_crash_is_retried_once_then_fails(tmp_path, chair_pla
assert evs.count("round.transport_retry") == 1 and "run.failed" in evs
+class CrashAfterBaseline(FakeAgent):
+ """Baseline works; every refine session dies with a transport-looking message that its
+ backend did NOT classify transient (a CLI crash with no provider error)."""
+
+ def __init__(self):
+ super().__init__(_writer)
+
+ def run(self, job: AgentJob) -> AgentResult:
+ if job.round == 0:
+ return super().run(job)
+ self.jobs.append(job)
+ return AgentResult(ok=False, exit_reason="error", usage=Usage(cost_usd=0.01),
+ errors=["rc=1; response=<empty>; stderr tail: at process.processTicksAndRejections"])
+
+
+def test_an_untyped_crash_is_no_longer_a_transport_retry(tmp_path, chair_plan, settings):
+ """The words "response=<empty>" used to buy a retry of the whole round; only the backend's
+ own verdict does now (0 of 34 recorded gemini-cli error exits lacked a provider signature)."""
+ ws = Workspace(tmp_path / "runs" / "crash")
+ rec = _track(CrashAfterBaseline(), (0.55,), chair_plan, settings).run(make_spec(max_rounds=3), ws)
+ assert rec.status is RunStatus.NO_CHANGE
+ evs = _events(ws)
+ assert "round.transport_retry" not in evs and "round.no_change" in evs
+
+
def test_an_idle_agent_is_a_no_change_stop_not_a_retry(tmp_path, chair_plan, settings):
agent = IdleAfterBaseline()
ws = Workspace(tmp_path / "runs" / "idle")