Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion benchmarks/factory_harbor_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,14 @@ async def install(self, environment: BaseEnvironment) -> None:
"if command -v apk &> /dev/null; then"
" apk add --no-cache curl bash nodejs npm procps git;"
" elif command -v apt-get &> /dev/null; then"
" apt-get update && apt-get install -y curl procps git;"
" if ! command -v curl &> /dev/null || ! command -v git &> /dev/null; then"
" sed -i 's|http://mirrors.aliyun.com/ubuntu|http://archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list 2>/dev/null || true;"
" sed -i 's|http://mirrors.cloud.aliyuncs.com/ubuntu|http://archive.ubuntu.com/ubuntu|g' /etc/apt/sources.list 2>/dev/null || true;"
" rm -f /etc/apt/trusted.gpg.d/* 2>/dev/null || true;"
" apt-get clean; rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* 2>/dev/null || true;"
" apt-get -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true update;"
" apt-get --allow-unauthenticated --no-install-recommends install -y curl procps git || true;"
" fi;"
" elif command -v yum &> /dev/null; then"
" yum install -y curl procps-ng git;"
" fi"
Expand Down
2 changes: 2 additions & 0 deletions factory/cli/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"frontend-design-scan",
"evolve",
"deep-research",
"outer-loop",
]


Expand All @@ -55,6 +56,7 @@
"study",
"swebench",
"frontend-design-scan",
"outer-loop",
]


Expand Down
16 changes: 16 additions & 0 deletions factory/cli/_parser_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,22 @@ def add_entry_point_parsers(sub: argparse._SubParsersAction) -> None: # type: i
"tool (CEO drives via factory workflow tool commands), "
"deterministic (headless WorkflowExecutor, no CEO)")

# Outer-loop specific arguments
p.add_argument("--benchmark", default=None,
help="Benchmark adapter for outer-loop fitness evaluation (required for --mode outer-loop)")
p.add_argument("--budget", type=int, default=None, dest="ol_budget",
help="Max evaluations for outer-loop evolution (default: 100)")
p.add_argument("--population", type=int, default=None,
help="Population size per generation for outer-loop (default: 4)")
p.add_argument("--target-score", type=float, default=None, dest="target_score",
help="Optional early stop score for outer-loop evolution")
p.add_argument("--seed", default=None, dest="seed_mode",
help="Existing mode name to seed the outer-loop from (default: benchmark's contributed workflow)")
p.add_argument("--training-instances", default=None, dest="training_instances",
help="Comma-separated problem IDs for evolution (required for --mode outer-loop)")
p.add_argument("--holdout-instances", default=None, dest="holdout_instances",
help="Comma-separated held-out problem IDs for overfit detection (required for --mode outer-loop)")

p = sub.add_parser("run", help="Run factory cycle (delegates to CEO agent)")
p.add_argument("path", help="Project path, GitHub URL, idea file path, or prompt")
p.add_argument(
Expand Down
7 changes: 7 additions & 0 deletions factory/cli/_task_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def _mode_suffix(mode: str, discover_only: bool) -> str:
"with structural graph context included. "
"Terminal mode — does not chain to other modes."
),
"outer-loop": (
"\n\nRun Outer Loop mode: evolutionary swarm search for workflow optimization. "
"Seed a population from the specified mode, evolve via mutation + selection + "
"novelty filtering + LLM-guided design, evaluate against benchmark instances. "
"Post-evolution: holdout audit for overfit detection, export best workflow. "
"The full step-by-step playbook is in your system prompt above."
),
}
if mode == "discover":
if discover_only:
Expand Down
63 changes: 63 additions & 0 deletions factory/outer_loop/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Outer loop — evolutionary swarm search for workflow optimization."""

from factory.outer_loop.designer import DesignerAgent, extract_telemetry
from factory.outer_loop.engine import BudgetTracker, SwarmEngine
from factory.outer_loop.filesystem import (
export_best_workflow,
init_filesystem,
load_checkpoint,
load_config,
save_best,
save_checkpoint,
save_generation,
save_map_elites,
)
from factory.outer_loop.direct_evaluator import DirectFeatureBenchEvaluator
from factory.outer_loop.harbor_evaluator import (
HarborEvaluator,
create_seed_workflow,
workflow_to_harbor_yaml,
)
from factory.outer_loop.models import (
AuditResult,
EvalResult,
GenerationSummary,
HyperparameterRecord,
Individual,
MutationRecord,
MutationType,
OuterLoopResult,
OuterLoopState,
SwarmConfig,
)
from factory.outer_loop.workflow import outer_loop_workflow

__all__ = [
"AuditResult",
"BudgetTracker",
"DirectFeatureBenchEvaluator",
"DesignerAgent",
"EvalResult",
"GenerationSummary",
"HarborEvaluator",
"HyperparameterRecord",
"Individual",
"MutationRecord",
"MutationType",
"OuterLoopResult",
"OuterLoopState",
"SwarmConfig",
"SwarmEngine",
"create_seed_workflow",
"export_best_workflow",
"extract_telemetry",
"init_filesystem",
"load_checkpoint",
"load_config",
"outer_loop_workflow",
"save_best",
"save_checkpoint",
"save_generation",
"save_map_elites",
"workflow_to_harbor_yaml",
]
Loading
Loading