Skip to content

get_artifacts returns small bytes artifacts as {'__bytes__': ...} dicts #536

Open

Description

@harshajv7981

Bug

ProgramDatabase.get_artifacts() returns small bytes artifacts (under the 32KB disk threshold) as {'__bytes__': '<base64>'} dicts instead of bytes, so evaluators that return binary artifacts get the encoded dict back and it ends up in prompts as-is.

Reproduction

import tempfile
from openevolve.config import DatabaseConfig
from openevolve.database import Program, ProgramDatabase

db = ProgramDatabase(DatabaseConfig(db_path=tempfile.mkdtemp()))
db.add(Program(id="p1", code="print('hello')", metrics={"score": 0.5}))
db.store_artifacts("p1", {"blob": b"\x00\x01binary"})
print(db.get_artifacts("p1"))

Expected: {'blob': b'\x00\x01binary'} Actual: {'blob': {'__bytes__': 'AAFiaW5hcnk='}}

Large artifacts written to disk already come back as bytes, so the return type currently depends on the artifact's size.

Cause

store_artifacts encodes with json.dumps(..., default=self._artifact_serializer) (openevolve/database.py:2633), but get_artifacts decodes with a plain json.loads (openevolve/database.py:2663) and never uses the matching _artifact_deserializer, which is otherwise unused.

Fix

A minimal fix with a regression test is in the linked PR.


I found this with patchwork, an automated code-audit tool I run, and verified the reproduction test in an isolated sandbox. If tool-assisted reports aren't welcome here, let me know and I won't send more.

Activity

  1. codelion commented on Oct 23, 2026

    @codelion
    Member

    I will look in to the PR.

    You might want to rename your tool, given that I created a similar one with exactly the same name - https://github.com/patched-codes/patchwork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions