diff --git a/openevolve/database.py b/openevolve/database.py index f06786cf4..bcaad6b60 100644 --- a/openevolve/database.py +++ b/openevolve/database.py @@ -2660,7 +2660,9 @@ def get_artifacts(self, program_id: str) -> Dict[str, Union[str, bytes]]: # Load small artifacts from JSON if program.artifacts_json: try: - small_artifacts = json.loads(program.artifacts_json) + small_artifacts = json.loads( + program.artifacts_json, object_hook=self._artifact_deserializer + ) artifacts.update(small_artifacts) except json.JSONDecodeError as e: logger.warning(f"Failed to decode artifacts JSON for program {program_id}: {e}") diff --git a/tests/test_artifacts.py b/tests/test_artifacts.py index 5ccbce55f..0095f2a71 100644 --- a/tests/test_artifacts.py +++ b/tests/test_artifacts.py @@ -90,6 +90,15 @@ def test_store_small_artifacts(self): program = self.database.get(self.program.id) self.assertIsNotNone(program.artifacts_json) + def test_store_small_bytes_artifacts(self): + """Test that small bytes artifacts round-trip as bytes""" + artifacts = {"blob": b"\x00\x01binary"} + + self.database.store_artifacts(self.program.id, artifacts) + + retrieved = self.database.get_artifacts(self.program.id) + self.assertEqual(retrieved, artifacts) + def test_store_large_artifacts(self): """Test storing large artifacts to disk""" large_content = "x" * (50 * 1024) # 50KB