Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions configs/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ prompt:
- "I suggest the following improvements:"
- "We can enhance this code by:"

# Artifact rendering
include_artifacts: true # Include execution outputs/errors in prompt
max_artifact_bytes: 20480 # Maximum artifact size in bytes (20KB default)
artifact_security_filter: true # Apply security filtering to artifacts

# Note: meta-prompting features are not yet implemented

# Database configuration
Expand Down
12 changes: 9 additions & 3 deletions openevolve/process_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ def _run_iteration_worker(
reverse=True
)

island_top_programs = island_programs[:5]
island_previous_programs = island_programs[:3]
# Use config values for limits instead of hardcoding
island_top_programs = island_programs[:_worker_config.prompt.num_top_programs + _worker_config.prompt.num_diverse_programs]
island_previous_programs = island_programs[:_worker_config.prompt.num_top_programs]

# Build prompt
prompt = _worker_prompt_sampler.build_prompt(
Expand Down Expand Up @@ -342,7 +343,12 @@ def _create_database_snapshot(self) -> Dict[str, Any]:
}

# Include artifacts for programs that might be selected
# (limit to reduce serialization overhead)
# IMPORTANT: This limits artifacts (execution outputs/errors) to first 100 programs only.
# This does NOT affect program code - all programs are fully serialized above.
# With max_artifact_bytes=20KB and population_size=1000, artifacts could be 20MB total,
# which would significantly slow worker process initialization. The limit of 100 keeps
# artifact data under 2MB while still providing execution context for recent programs.
# Workers can still evolve properly as they have access to ALL program code.
for pid in list(self.database.programs.keys())[:100]:
artifacts = self.database.get_artifacts(pid)
if artifacts:
Expand Down
25 changes: 9 additions & 16 deletions openevolve/prompt/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,8 @@ def _format_evolution_history(
selected_top = top_programs[: min(self.config.num_top_programs, len(top_programs))]

for i, program in enumerate(selected_top):
# Extract a snippet (first 10 lines) for display
# Use the full program code
program_code = program.get("code", "")
program_snippet = "\n".join(program_code.split("\n")[:10])
if len(program_code.split("\n")) > 10:
program_snippet += "\n# ... (truncated for brevity)"

# Calculate a composite score using safe numeric average
score = safe_numeric_average(program.get("metrics", {}))
Expand All @@ -338,7 +335,7 @@ def _format_evolution_history(
program_number=i + 1,
score=f"{score:.4f}",
language=language,
program_snippet=program_snippet,
program_snippet=program_code,
key_features=key_features_str,
)
+ "\n\n"
Expand All @@ -362,11 +359,8 @@ def _format_evolution_history(
diverse_programs_str += "\n\n## Diverse Programs\n\n"

for i, program in enumerate(diverse_programs):
# Extract a snippet (first 5 lines for diversity)
# Use the full program code
program_code = program.get("code", "")
program_snippet = "\n".join(program_code.split("\n")[:5])
if len(program_code.split("\n")) > 5:
program_snippet += "\n# ... (truncated)"

# Calculate a composite score using safe numeric average
score = safe_numeric_average(program.get("metrics", {}))
Expand All @@ -388,7 +382,7 @@ def _format_evolution_history(
program_number=f"D{i + 1}",
score=f"{score:.4f}",
language=language,
program_snippet=program_snippet,
program_snippet=program_code,
key_features=key_features_str,
)
+ "\n\n"
Expand Down Expand Up @@ -430,11 +424,8 @@ def _format_inspirations_section(
inspiration_programs_str = ""

for i, program in enumerate(inspirations):
# Extract a snippet (first 8 lines) for display
# Use the full program code
program_code = program.get("code", "")
program_snippet = "\n".join(program_code.split("\n")[:8])
if len(program_code.split("\n")) > 8:
program_snippet += "\n# ... (truncated for brevity)"

# Calculate a composite score using safe numeric average
score = safe_numeric_average(program.get("metrics", {}))
Expand All @@ -451,7 +442,7 @@ def _format_inspirations_section(
score=f"{score:.4f}",
program_type=program_type,
language=language,
program_snippet=program_snippet,
program_snippet=program_code,
unique_features=unique_features,
)
+ "\n\n"
Expand Down Expand Up @@ -540,7 +531,9 @@ def _extract_unique_features(self, program: Dict[str, Any]) -> str:
program_type = self._determine_program_type(program)
features.append(f"{program_type} approach to the problem")

return ", ".join(features[:3]) # Limit to top 3 features
# Use num_top_programs as limit for features (similar to how we limit programs)
feature_limit = self.config.num_top_programs
return ", ".join(features[:feature_limit])

def _apply_template_variations(self, template: str) -> str:
"""Apply stochastic variations to the template"""
Expand Down