Skip to content

Official Codebase of 3DCodeVerse

Python

planner: the validation re-ask names the part shortfall when the invalid plan is degenerate

ziyao39d2f93e53a7
diff --git a/harness/codeverse/tracks/planner.py b/harness/codeverse/tracks/planner.py
index 1598fec9..b9078f87 100644
--- a/harness/codeverse/tracks/planner.py
+++ b/harness/codeverse/tracks/planner.py
@@ -642,6 +642,20 @@ def _with_note(msg: ChatMessage, note: str) -> ChatMessage:
return ChatMessage.user(msg.text + note, images=images)
+def _thin_plan_note(raw: Any, budget: PlanBudget) -> str:
+ """A second line for the validation re-ask when the invalid plan is also far too small.
+
+ compare_art_v4_pf0 (2026-08-28): flash answered an architect-lamp brief with ONE part
+ ("base") and a joint naming a link it never listed, three times in a row — the re-ask
+ only echoed the unknown-link error, so the model kept fixing the wrong thing."""
+ parts = raw.get("parts") if isinstance(raw, dict) else None
+ # only a degenerate plan (a third of the floor or less) — the quality complaint owns the rest
+ if not isinstance(parts, list) or len(parts) > max(2, budget.min_parts // 3):
+ return ""
+ return (f"\nAlso: this plan lists only {len(parts)} part(s) but the request needs about {budget.target_parts} "
+ f"({budget.reason}). Put EVERY link a joint references under `parts` with its own bbox.")
+
+
def _truncated(exc: Exception) -> bool:
"""Did this model error mean 'the answer did not fit'?"""
return "MAX_TOKENS" in str(exc)
@@ -791,7 +805,7 @@ def plan_with_usage[P: BaseModel](spec: Spec, model_id: str, plan_model: type[P]
messages = messages + [
_echo(raw, resp.text),
ChatMessage.user("Your plan failed validation. Fix EXACTLY these problems and return the full corrected "
- f"plan JSON again (same schema):\n{last_error}"),
+ f"plan JSON again (same schema):\n{last_error}" + _thin_plan_note(raw, budget)),
]
continue
complaint = plan_quality_complaint(result, budget, unit=unit) if requeried < MAX_QUALITY_REASKS else ""
diff --git a/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py b/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py
index 36c348cc..498aa6fc 100644
--- a/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py
+++ b/harness/tests/orchestrator_tracks/test_planner_geometry_reask.py
@@ -107,3 +107,14 @@ def test_a_crashing_geometry_check_never_costs_the_plan(tmp_ws, monkeypatch):
assert isinstance(p, ArticulatedPlan) and len(model.requests) == 1
kinds = [e["event"] for e in events.read()]
assert "plan.geometry_error" in kinds and "plan.done" in kinds
+
+
+def test_validation_reask_names_the_missing_parts_when_the_plan_is_thin(tmp_ws):
+ thin = _good()
+ thin["parts"] = thin["parts"][:1] # only the cabinet; the joint still references the drawer
+ answers = [thin, _good()]
+ model = FakeChatModel(lambda req: answers.pop(0))
+ p = plan(_spec(), "fake:planner", ArticulatedPlan, tmp_ws, model=model, runtime=FakeRuntime(Language.URDF_BLENDER))
+ assert isinstance(p, ArticulatedPlan) and len(model.requests) == 2
+ reask = model.requests[1].messages[-1].text
+ assert "failed validation" in reask and "lists only 1 part(s)" in reask and "needs about" in reask