Skip to content

Commit 0b4d494

Browse files
fix: sync live loop progression into 1.0 line
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 3ed9f19 commit 0b4d494

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

scripts/innovation_loop.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,25 @@ def build_guard_prompt(
623623
def materialize_live_choice(
624624
raw: dict, round_index: int, research_context: dict, role: str
625625
) -> dict:
626+
def parse_expected_gain(value: object) -> float:
627+
if isinstance(value, (int, float)):
628+
return float(value)
629+
text = str(value or "").strip()
630+
if not text:
631+
return 0.02
632+
import re
633+
634+
numbers = re.findall(r"-?\d+(?:\.\d+)?", text)
635+
if not numbers:
636+
return 0.02
637+
values = [float(item) for item in numbers]
638+
estimate = (
639+
values[0] if len(values) == 1 else sum(values[:2]) / min(2, len(values))
640+
)
641+
if "%" in text:
642+
estimate /= 100.0
643+
return estimate
644+
626645
choice = str(raw.get("choice", "objective"))
627646
templates = {item["change_class"]: item for item in candidate_mutation_templates()}
628647
if choice not in templates:
@@ -632,7 +651,7 @@ def materialize_live_choice(
632651
template["title"] = raw.get("title") or template["change_unit"]
633652
template["innovation_tags"] = raw.get("innovation_tags") or [choice]
634653
template["mechanism"] = raw.get("mechanism") or "selected exploit recipe"
635-
template["expected_gain"] = float(raw.get("expected_gain", 0.02))
654+
template["expected_gain"] = parse_expected_gain(raw.get("expected_gain", 0.02))
636655
template["risk"] = str(raw.get("risk", "low"))
637656
template["why_not_parameter_only"] = raw.get(
638657
"why_not_parameter_only"
@@ -872,6 +891,8 @@ def tick(config_path: pathlib.Path, workspace: pathlib.Path, mode: str) -> dict:
872891
}
873892
record_research_feedback(workspace, research_context, judged)
874893
session = load_session(session_file)
894+
session["iteration_count"] = int(session.get("iteration_count", 0)) + 1
895+
session["round"] = int(session["iteration_count"])
875896
session["last_failed_task"] = active
876897
session["active_dvc_task"] = None
877898
set_session_stage(session, "crash_recoverable", f"dvc task {active} failed")
@@ -904,6 +925,8 @@ def tick(config_path: pathlib.Path, workspace: pathlib.Path, mode: str) -> dict:
904925
}
905926
record_research_feedback(workspace, research_context, judged)
906927
session = load_session(session_file)
928+
session["iteration_count"] = int(session.get("iteration_count", 0)) + 1
929+
session["round"] = int(session["iteration_count"])
907930
if judged["status"] == "keep" and current_best_metric(workspace) is not None:
908931
if float(current_best_metric(workspace) or 0.0) >= float(
909932
goal.get("target_threshold") or 0.0

0 commit comments

Comments
 (0)