Official Codebase of 3DCodeVerse
Python
rounds: a refine session that dies on the vendor's usage limit stops the run at agent_quota (status budget), not plateau
gaoypenga38654d4d1fb
diff --git a/harness/codeverse/orchestrator.py b/harness/codeverse/orchestrator.pyindex 18b41ff6..4ad8256a 100644--- a/harness/codeverse/orchestrator.py+++ b/harness/codeverse/orchestrator.py@@ -444,7 +444,7 @@ def _acceptance_target(item: AcceptanceItem, known: dict[str, str]) -> str:# ===================================================================== roundsStopReason = Literal["pass", "plateau", "budget", "continue", "max_rounds", "judge_unavailable",- "regression", "diminishing_returns"]+ "regression", "diminishing_returns", "agent_quota"]#: what the next round should look like when the loop continuesStrategy = Literal["same", "switch", "detail"]diff --git a/harness/codeverse/tracks/lifecycle.py b/harness/codeverse/tracks/lifecycle.pyindex b89c2f73..65c75dd9 100644--- a/harness/codeverse/tracks/lifecycle.py+++ b/harness/codeverse/tracks/lifecycle.py@@ -73,6 +73,7 @@ from codeverse.tracks.steps import (RoundPipeline,failed_acceptance,load_round_journal,+ looks_quota,looks_transport,rejudge_round,run_round,@@ -144,6 +145,8 @@ _STATUS: dict[str, RunStatus] = {# judge outage (degraded/crashed verdicts even after a retry): the code is intact# and the best built round is delivered — a stop, not a failure."judge_unavailable": RunStatus.PLATEAU,+ # the vendor's usage limit, not ours — the best round ships, the status says a budget ended+ "agent_quota": RunStatus.BUDGET,}@@ -674,6 +677,16 @@ class BaseTrack:previous=previous, files_hint=self.round_files_hint(ctx),extra_notes=self.round_extra_notes(ctx), previous_best=best_score(rounds))except RoundFailed as e:+ if looks_quota(str(e)):+ # The vendor's own usage limit: not a transport death (a retry meets the+ # same wall) and not a plateau (the code did not stop improving) — the+ # agent is gone until the limit resets. cmp8 (2026-09-09): three runs+ # filed "plateau" on "You've hit your usage limit … try again at Sep 14th".+ ctx.events.emit("round.agent_quota", round=index, detail=str(e)[:500])+ if index == 0:+ raise+ ctx.events.emit("stop", reason="agent_quota", rounds=len(rounds), best=ctx.state.best_round)+ return "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# verdict — the session never really happened. Re-run the SAMEdiff --git a/harness/codeverse/tracks/steps.py b/harness/codeverse/tracks/steps.pyindex 6028f372..36b49ed3 100644--- a/harness/codeverse/tracks/steps.py+++ b/harness/codeverse/tracks/steps.py@@ -78,6 +78,23 @@ _TRANSPORT_MARKS = ()+#: 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 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.diff --git a/harness/docs/RUNBOOK.md b/harness/docs/RUNBOOK.mdindex 8471d8c8..249af358 100644--- a/harness/docs/RUNBOOK.md+++ b/harness/docs/RUNBOOK.md@@ -217,6 +217,11 @@ cell is finished with no score (`bench run` will not re-run it: the row exists).scoreless cells afterwards — delete the row from `results.jsonl` and the run directory,then `bench run --id <prompt>`.+A refine session that dies on the VENDOR's usage limit ("You've hit your usage limit … try again at+Sep 14th", `RESOURCE_EXHAUSTED`, `insufficient_quota`) stops the run at `agent_quota` with status+`budget`: the best round ships, and the record says the agent's budget ended, not the code's+improvement (cmp8, 2026-09-09, filed three such runs as `plateau` before this).+**A cell can also lose its renders to the box rather than to itself.** When the machineruns out of memory Chrome reaps the render tab and the driver reports`Attempted to use detached Frame '<id>'`: the scene built, every gate ran, and the judgediff --git a/harness/tests/orchestrator_tracks/test_transport_retry.py b/harness/tests/orchestrator_tracks/test_transport_retry.pyindex 67b636be..0b1c88cf 100644--- a/harness/tests/orchestrator_tracks/test_transport_retry.py+++ b/harness/tests/orchestrator_tracks/test_transport_retry.py@@ -13,7 +13,7 @@ from codeverse.contracts.common import Language, Usagefrom codeverse.contracts.run import RunStatusfrom codeverse.proc import EventLogfrom codeverse.tracks.static_object import StaticObjectTrack-from codeverse.tracks.steps import RoundFailed, looks_transport+from codeverse.tracks.steps import RoundFailed, looks_quota, looks_transportfrom codeverse.workspace import Workspacefrom tests.orchestrator_tracks.conftest import make_specfrom tests.orchestrator_tracks.fakes import (@@ -43,11 +43,31 @@ VERDICTS = []+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",+]++@pytest.mark.parametrize("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)++@pytest.mark.parametrize("msg", VERDICTS)def test_agent_verdicts_do_not_match(msg):assert not looks_transport(msg)@@ -92,6 +112,19 @@ class CrashUntilRetried(FakeAgent):return super().run(job)+class QuotaAfterBaseline(FakeAgent):+ """Baseline works; every refine session dies on the vendor's usage limit."""++ 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", errors=[QUOTA[0]], usage=Usage(cost_usd=0.0))++class IdleAfterBaseline(FakeAgent):"""Baseline works; every refine session completes fine and changes nothing."""@@ -156,3 +189,14 @@ def test_an_idle_agent_is_a_plateau_not_a_retry(tmp_path, chair_plan, settings):assert rec.status is RunStatus.PLATEAUevs = _events(ws)assert "round.transport_retry" not in evs and "round.no_change" in evs+++def test_a_vendor_usage_limit_stops_the_run_as_agent_quota_not_plateau(tmp_path, chair_plan, settings):+ agent = QuotaAfterBaseline()+ ws = Workspace(tmp_path / "runs" / "quota")+ rec = _track(agent, (0.55,), chair_plan, settings).run(make_spec(max_rounds=3), ws)+ assert rec.status is RunStatus.BUDGET and rec.extra["stop_reason"] == "agent_quota"+ assert rec.final_score == pytest.approx(0.55) # the baseline best is still delivered+ evs = _events(ws)+ assert "round.agent_quota" in evs and "round.transport_retry" not in evs and "round.no_change" not in evs+ assert max(j.round for j in agent.jobs) == 1 # the refine round's sessions met the wall; no retry round