Official Codebase of 3DCodeVerse
Python
scene heroes: a thin hero plan is asked again with the sheet's features as the checklist
gaoypengcf8e5747f761
diff --git a/harness/codeverse/tracks/scene_assets.py b/harness/codeverse/tracks/scene_assets.pyindex e6ad4214..bf5609be 100644--- a/harness/codeverse/tracks/scene_assets.py+++ b/harness/codeverse/tracks/scene_assets.py@@ -20,6 +20,7 @@ from __future__ import annotationsimport hashlibimport jsonimport logging+import reimport shutilimport structfrom collections.abc import Callable@@ -353,6 +354,8 @@ def _inline(ctx: RunContext, files: list[str]) -> str:HERO_MAX_TRIS = 40_000HERO_ENTRY = "src/model.py"HERO_GROUND_TOL_M = 0.02+#: a hero plan with this many parts or fewer, for a sheet naming more features, is asked again once+HERO_THIN_PLAN_PARTS = 2def build_blender_asset(ctx: RunContext, asset: AssetPlan, *, judge: bool) -> AssetResult:@@ -476,6 +479,16 @@ def hero_plan(sub: RunContext, asset: AssetPlan) -> StaticPlan:model = sub.services.chat_model(sub.spec.backends.planner)plan = run_planner(sub.spec, sub.spec.backends.planner, StaticPlan, sub.ws, model=model, events=sub.events,budget=sub.budget, runtime=sub.runtime, **track._plan_kwargs(sub.spec))+ features = hero_features(asset.description)+ if len(plan.parts) <= HERO_THIN_PLAN_PARTS and len(features) > HERO_THIN_PLAN_PARTS:+ # a one-part answer for a prop whose sheet names several features (the windmill got+ # 'BrickBase' alone twice on 2026-09-07 while every other hero got 7-12 parts): ask+ # ONCE more with the features as the checklist, which is what sizes the planner's+ # part budget (plan_budget: must_have) and names the parts it must list+ sub.events.emit("asset.plan_thin", asset=asset.name, n_parts=len(plan.parts), features=features)+ spec2 = sub.spec.model_copy(update={"constraints": sub.spec.constraints.model_copy(update={"must_have": features})})+ plan = run_planner(spec2, spec2.backends.planner, StaticPlan, sub.ws, model=model, events=sub.events,+ budget=sub.budget, runtime=sub.runtime, **track._plan_kwargs(spec2))except Exception as e: # noqa: BLE001 — PlanningError / outage: the sheet still says what the prop isfrom codeverse.orchestrator import BudgetExceeded@@ -488,6 +501,21 @@ def hero_plan(sub: RunContext, asset: AssetPlan) -> StaticPlan:return plan+def hero_features(description: str, limit: int = 8) -> list[str]:+ """The features an asset sheet names — its clauses of two words or more — as a checklist.++ 'an octagonal brick base, a thatched body, a cap with a gallery and four lattice sails'+ → four items; the planner's part budget is sized from must_have (plan_budget)."""+ out: list[str] = []+ for clause in re.split(r"[;,]|\band\b|\bwith\b|\bplus\b", description):+ words = clause.strip(" .:()").split()+ if len(words) >= 2 and clause.strip() not in out:+ out.append(" ".join(words))+ if len(out) >= limit:+ break+ return out++def _blender_check(ctx: RunContext, asset: AssetPlan, files: list[str], *, label: str, timeout_s: int) -> AssetCheck:"""Build the hero — the agent path gets ONE error-focused repair session, the single-shotpath none (its repair is the ladder's feedback rewrite) — then the soft findings adiff --git a/harness/tests/orchestrator_tracks/test_scene_hero_ladder.py b/harness/tests/orchestrator_tracks/test_scene_hero_ladder.pyindex 4eb24f9d..3f3ceb47 100644--- a/harness/tests/orchestrator_tracks/test_scene_hero_ladder.py+++ b/harness/tests/orchestrator_tracks/test_scene_hero_ladder.py@@ -235,3 +235,43 @@ def test_the_largest_module_is_judged_and_the_small_ones_are_not(tmp_ws, settingassert SA._judge_wanted(ctx, small, ok, judge=True) is Falseevents = [json.loads(line) for line in tmp_ws.events_path.read_text().splitlines()]assert [e["asset"] for e in events if e["event"] == "asset.judge_skipped"] == [small.name]+++def test_a_thin_hero_plan_is_asked_again_with_the_sheets_features_as_the_checklist(tmp_ws, settings):+ """The windmill got a one-part plan twice while every other hero got 7-12 parts: a plan+ of <= HERO_THIN_PLAN_PARTS parts for a sheet naming more features is re-asked ONCE with+ those features as must_have (what sizes the planner's part budget)."""++ calls = []++ class ThinUntilTheChecklist(SingleShotServices):+ """One part for every ask that carries no checklist — the planner's own in-context+ re-ask and restart included, which is what the windmill did — and the real list once+ the features are in must_have."""++ def _answer(self, req):+ if req.response_schema is not None:+ text = " ".join(p.text for m in req.messages for p in m.parts if getattr(p, "text", ""))+ # the description names the lid in EVERY ask; only the retry puts it on the checklist+ calls.append("MUST HAVE: a hinged lid" in text)+ if "MUST HAVE: a hinged lid" not in text:+ ex = dict(plan_example(Track.STATIC_OBJECT))+ ex["parts"] = [ex["parts"][0]] # one part+ return ex+ return plan_example(Track.STATIC_OBJECT) # the real list+ return self.model_text++ services = ThinUntilTheChecklist()+ ctx, hero = _scene(tmp_ws, settings, services=services, agent=FakeAgent(_writer(GOOD_MODEL)))+ hero = hero.model_copy(update={"description": "a slatted crate with a hinged lid, rope handles, iron corner straps and a chalked label"})+ assert len(SA.hero_features(hero.description)) > SA.HERO_THIN_PLAN_PARTS+ res = SA.build_blender_asset(ctx, hero, judge=False)+ # the planner's own asks (no checklist) came first and stayed thin; the retry's asks carry+ # the checklist and are the last — the planner may re-ask once more INSIDE that one retry+ assert res.ok and calls[0] is False and calls[-1] is True, calls+ events = [json.loads(line) for line in tmp_ws.events_path.read_text().splitlines()]+ thin = [e for e in events if e["event"] == "asset.plan_thin"]+ assert len(thin) == 1, [e["event"] for e in events] # exactly one retry+ assert thin[0]["n_parts"] == 1 and "a hinged lid" in thin[0]["features"]+ plan = json.loads((tmp_ws.root / "_assets" / SA.to_snake(hero.name) / "plan.json").read_text())+ assert len(plan["parts"]) > 1