Skip to content

Official Codebase of 3DCodeVerse

Python

generation: a session never outlives the run's wall clock

gaoypengd7b6bb460c59
diff --git a/harness/codeverse/tracks/generation.py b/harness/codeverse/tracks/generation.py
index 08b5294c..06cdcb1e 100644
--- a/harness/codeverse/tracks/generation.py
+++ b/harness/codeverse/tracks/generation.py
@@ -377,6 +377,12 @@ def run_agent_task(
charged to ``budget`` as it ends, so nothing is lost when a later attempt raises."""
before = ws.head()
timeout = task.timeout_s or (settings.limits.agent_timeout_s if settings is not None else 1800)
+ # ...but never longer than the run's remaining wall clock. The scene track has
+ # clipped this since the greenhouse incident; object/articulated/graphics did not,
+ # so a flat 30-minute session ran 9 minutes PAST a 30-minute ceiling (measured
+ # 2026-08-27: 'elapsed 39.0 min exceeds max_minutes 30.0', round 0 never finished).
+ if budget is not None and hasattr(budget, "timeout_s"):
+ timeout = budget.timeout_s(timeout, floor_s=120.0)
turns_cap = task.max_turns or max_turns or agent_max_turns() # 0 = leave AgentJob's own default
# typed job context honoured by every CodingAgent: round → trajectory dir + ToolContext,
# language/track → spatial tool filtering, files_hint → per-session attribution of
diff --git a/harness/tests/orchestrator_tracks/test_cost_latency.py b/harness/tests/orchestrator_tracks/test_cost_latency.py
index cd675c1f..613eeae7 100644
--- a/harness/tests/orchestrator_tracks/test_cost_latency.py
+++ b/harness/tests/orchestrator_tracks/test_cost_latency.py
@@ -466,3 +466,20 @@ def test_a_model_outage_escalates_the_asset_instead_of_losing_it(tmp_path, setti
assert [j.label for j in agent.jobs] == ["asset_bollard"]
failed = [e for e in _events(ctx) if e["event"] == "asset.generate_failed"]
assert failed and "503" in failed[0]["error"]
+
+
+def test_a_generation_session_never_outlives_the_wall_budget():
+ """Measured 2026-08-27: a static run with --max-minutes 30 stopped at 39.0 min with
+ round 0 unfinished, because run_agent_task handed the session a flat
+ settings.limits.agent_timeout_s (1800 s) and only checked the ceiling at the next
+ boundary. The scene track had clipped this since the greenhouse incident."""
+ from codeverse.contracts.spec import Budget
+ from codeverse.orchestrator.budget import BudgetGuard
+
+ g = BudgetGuard(Budget(max_usd=10.0, max_minutes=30.0, max_rounds=4), run="t")
+ assert g.timeout_s(1800, floor_s=120.0) == pytest.approx(1800, abs=60) # fresh run: full session
+ g.start_time -= 27 * 60 # 3 minutes left
+ clipped = g.timeout_s(1800, floor_s=120.0)
+ assert 120 <= clipped <= 3 * 60, clipped
+ g.start_time -= 10 * 60 # ceiling already crossed
+ assert g.timeout_s(1800, floor_s=120.0) == 120 # the floor, never 1800