Skip to content

Commit ad9c9c1

Browse files
codelionclaude
andauthored
Make max snapshot artifacts limit configurable (#386)
* Make max snapshot artifacts limit configurable Add `database.max_snapshot_artifacts` config option to control how many program artifacts are included in worker process snapshots. Default remains 100 for backward compatibility. - Set to a higher number to include more artifacts in prompts - Set to `null` (None) for unlimited artifacts (use with caution for large populations as this can significantly increase memory usage) Note: This limit only affects artifacts passed to worker processes, not the total artifacts stored. All program code is always available regardless of this setting. Closes #383 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add tests for recent features Add comprehensive tests for recently merged PRs: - test_llm_config_optional_params.py: Tests for optional temperature/top_p parameters (PR #385 - Anthropic model compatibility) - test_snapshot_artifacts_limit.py: Tests for configurable max_snapshot_artifacts (PR #386) - test_visualization_sanitization.py: Tests for -inf/+inf/NaN sanitization in visualization (PR #384) - test_early_stopping_config.py: Tests for event-based early stopping configuration (PR #375) - test_changes_description.py: Tests for large codebase support via changes description (PR #376) Total tests increased from 264 to 326. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add integration tests for example validation Add comprehensive integration tests that verify: - Example config files load correctly - Initial programs have EVOLVE-BLOCK markers - Evaluators exist and have required functions - Evaluators can run on initial programs - Cascade evaluation functions are detected - Database stores and retrieves programs correctly - Program evolution tracking works Tests cover function_minimization, circle_packing, and signal_processing examples, plus general structure validation for all examples. Total tests: 346 (was 326) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b0a5ca8 commit ad9c9c1

File tree

8 files changed

+1169
-4
lines changed

8 files changed

+1169
-4
lines changed

openevolve/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ class DatabaseConfig:
340340
artifact_size_threshold: int = 32 * 1024 # 32KB threshold
341341
cleanup_old_artifacts: bool = True
342342
artifact_retention_days: int = 30
343+
max_snapshot_artifacts: Optional[int] = 100 # Max artifacts in worker snapshots (None=unlimited)
343344

344345
novelty_llm: Optional["LLMInterface"] = None
345346
embedding_model: Optional[str] = None

openevolve/process_parallel.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,18 @@ def _create_database_snapshot(self) -> Dict[str, Any]:
431431
}
432432

433433
# Include artifacts for programs that might be selected
434-
# IMPORTANT: This limits artifacts (execution outputs/errors) to first 100 programs only.
434+
# This limits artifacts (execution outputs/errors) to avoid large snapshot sizes.
435435
# This does NOT affect program code - all programs are fully serialized above.
436436
# With max_artifact_bytes=20KB and population_size=1000, artifacts could be 20MB total,
437-
# which would significantly slow worker process initialization. The limit of 100 keeps
438-
# artifact data under 2MB while still providing execution context for recent programs.
437+
# which would significantly slow worker process initialization. The default limit of 100
438+
# keeps artifact data under 2MB while still providing execution context for recent programs.
439439
# Workers can still evolve properly as they have access to ALL program code.
440-
for pid in list(self.database.programs.keys())[:100]:
440+
# Configure via database.max_snapshot_artifacts (None for unlimited).
441+
max_artifacts = self.database.config.max_snapshot_artifacts
442+
program_ids = list(self.database.programs.keys())
443+
if max_artifacts is not None:
444+
program_ids = program_ids[:max_artifacts]
445+
for pid in program_ids:
441446
artifacts = self.database.get_artifacts(pid)
442447
if artifacts:
443448
snapshot["artifacts"][pid] = artifacts

0 commit comments

Comments
 (0)