Official Codebase of 3DCodeVerse
Python
models: ask for the model's real output ceiling, 65536, not 16000
gaoypeng18adc2d8d4eb
diff --git a/harness/codeverse/agents/api_agent.py b/harness/codeverse/agents/api_agent.pyindex 77612a59..741a5021 100644--- a/harness/codeverse/agents/api_agent.py+++ b/harness/codeverse/agents/api_agent.py@@ -42,8 +42,8 @@ MODEL_RETRIES = 3#: 15 359 + 637 = 15 996 — the model behaved normally, the envelope was four tokens too#: small. ``tracks/planner`` has grown its budget on truncation since it hit the same#: wall (PLAN_TOKENS_MAX / TRUNCATION_GROWTH); the agent loop never did.-TURN_TOKENS = 16_000-TURN_TOKENS_MAX = 48_000+TURN_TOKENS = 65_536 # the model's declared ceiling; unused tokens cost nothing+TURN_TOKENS_MAX = 65_536TURN_TOKENS_GROWTH = 1.5#: retry budget (``ChatRequest.max_wait_s``) for ONE model call of a turn: the session's#: remaining time, clipped to this window. Audit 2026-08-26 §5.1: with the model's owndiff --git a/harness/codeverse/contracts/chat.py b/harness/codeverse/contracts/chat.pyindex 254beef3..08c57086 100644--- a/harness/codeverse/contracts/chat.py+++ b/harness/codeverse/contracts/chat.py@@ -72,7 +72,12 @@ class ChatRequest(BaseModel):response_schema: dict[str, Any] | None = Field(default=None, description="force JSON matching this schema")tools: list[ToolSpec] | None = Nonetemperature: float = 0.7- max_output_tokens: int = 16000+ #: 65 536 is the declared output limit of every gemini-3.x model the harness uses+ #: (models.get: input 1 048 576 / output 65 536). It is a CEILING, not a reservation —+ #: only tokens actually produced are billed — and a low one silently truncates a+ #: thinking model mid-answer: a 15 359-token thought hit the old 16 000 default at+ #: 15 996 and the turn arrived with no tool call (art_med_tool_chest, 2026-08-27).+ max_output_tokens: int = 65_536thinking: Literal["off", "low", "medium", "high"] = "low"label: str = Field(default="", description="for logs/cost ledger: planner / judge / generate ...")max_wait_s: float | None = Field(diff --git a/harness/codeverse/tracks/graphics_steps.py b/harness/codeverse/tracks/graphics_steps.pyindex 5dc5ad33..f9566fcf 100644--- a/harness/codeverse/tracks/graphics_steps.py+++ b/harness/codeverse/tracks/graphics_steps.py@@ -38,7 +38,7 @@ log = logging.getLogger(__name__)PLAN_TEMPLATE = "tracks/plan_graphics.j2"PLAN_TEMPERATURE = 0.5-PLAN_MAX_OUTPUT_TOKENS = 16000+PLAN_MAX_OUTPUT_TOKENS = 65_536 # the model's declared output ceiling; unused tokens cost nothingEXPECTED_FILES: dict[Language, list[str]] = {Language.GLSL_SHADER: ["src/shader.frag", "src/common.glsl"],Language.OPENGL_PYTHON: ["src/program.py"],diff --git a/harness/codeverse/tracks/planner.py b/harness/codeverse/tracks/planner.pyindex a691ff6c..2c7a6718 100644--- a/harness/codeverse/tracks/planner.py+++ b/harness/codeverse/tracks/planner.py@@ -58,7 +58,7 @@ MAX_QUALITY_REASKS = 1#: prompts. Callers may raise the floor; this only ever raises it further.PLAN_TOKENS_PER_PART = 600PLAN_TOKENS_PER_LEAF = 400-PLAN_TOKENS_MAX = 60000+PLAN_TOKENS_MAX = 65_536 # the model's declared output ceiling#: one more attempt when the model truncates anyway, with half again as much roomTRUNCATION_GROWTH = 1.5#: retry budget (``ChatRequest.max_wait_s``) for one planner call. Audit 2026-08-26 §2: thediff --git a/harness/tests/agents/test_api_agent.py b/harness/tests/agents/test_api_agent.pyindex b38f4206..7ae4abd3 100644--- a/harness/tests/agents/test_api_agent.py+++ b/harness/tests/agents/test_api_agent.py@@ -327,7 +327,7 @@ def test_a_truncated_turn_widens_the_output_envelope(tmp_ws):"""The model was not misbehaving: thinking grew 13 -> 3 144 -> 15 359 tokens on a hardproblem and 15 359 + 637 hit the 16 000 default exactly. planner has grown its budgeton truncation for months; the agent loop took the default and never moved."""- from codeverse.agents.api_agent import TURN_TOKENS, TURN_TOKENS_GROWTH+ from codeverse.agents.api_agent import TURN_TOKENS, TURN_TOKENS_GROWTH, TURN_TOKENS_MAXfake = FakeChatModel([cut("<thought>the hinge axis and"),@@ -337,4 +337,7 @@ def test_a_truncated_turn_widens_the_output_envelope(tmp_ws):ApiAgent("fake:fake-1", chat_model=fake).run(_job(tmp_ws))asked = [r.max_output_tokens for r in fake.requests]assert asked[0] == TURN_TOKENS- assert asked[1] == int(TURN_TOKENS * TURN_TOKENS_GROWTH), "the turn after a truncation gets room"+ # TURN_TOKENS already IS the model's declared ceiling, so growth clamps there: the+ # invariant is "never shrink, never exceed the ceiling" — it survives the default moving+ assert TURN_TOKENS <= asked[1] <= TURN_TOKENS_MAX+ assert asked[1] == min(TURN_TOKENS_MAX, int(TURN_TOKENS * TURN_TOKENS_GROWTH))diff --git a/harness/tests/models/test_openai.py b/harness/tests/models/test_openai.pyindex 2c84e3ce..ff203f02 100644--- a/harness/tests/models/test_openai.py+++ b/harness/tests/models/test_openai.py@@ -93,7 +93,7 @@ def test_text_reasoning_effort_usage_cost():assert (kw["reasoning_effort"] == "high"and "temperature" not in kw- and kw["max_completion_tokens"] == 16000+ and kw["max_completion_tokens"] == ChatRequest.model_fields["max_output_tokens"].default)u = r.usageassert (u.input_tokens, u.cached_tokens, u.output_tokens, u.thoughts_tokens) == (