Skip to content

fix(memory): make ActionStep.dict() JSON-serializable when observations_images is present - #2732

Closed
teddiesloco wants to merge 1 commit into
huggingface:mainfrom
teddiesloco:fix/action-step-dict-json-serializable-images
Closed

teddiesloco wants to merge 1 commit into
huggingface:mainfrom
teddiesloco:fix/action-step-dict-json-serializable-images

Conversation

@teddiesloco

Copy link
Copy Markdown

What does this PR do?

Resolves #2725.

Currently, ActionStep.dict() converts self.observations_images using image.tobytes(), returning raw Python bytes objects. This causes json.dumps(step.dict()) to raise TypeError: Object of type bytes is not JSON serializable.

This PR:

  • Uses encode_image_base64(image) so observations_images is serialized to base64 strings, matching the serialization format elsewhere in the library.
  • Updates test_action_step_dict in tests/test_memory.py to verify that json.dumps(action_step_dict) succeeds.

Testing

  • Ran pytest tests/test_memory.py - 12 passed.

Closes huggingface#2725 by replacing raw non-serializable bytes with base64 PNG strings so ActionStep.dict() remains JSON-serializable.
@albertvillanova

Copy link
Copy Markdown
Member

Thank you for this pull request.

Under our contribution guidelines, a pull request needs to link an issue that a maintainer has assigned to its author before we review it. Assignment is how we decide what gets worked on and by whom, and it keeps the review queue at a size we can actually handle.

This PR links #2725, which is not assigned to you, so I am closing the PR for now. If we decide we want this change and assign it to you, comment here and we will reopen this PR as it is: please do not open a new one. Closing it is not a judgement on the code.

@albertvillanova albertvillanova added the needs-assigned-issue Closed: the PR does not link an issue assigned to its author (see CONTRIBUTING.md) label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-assigned-issue Closed: the PR does not link an issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ActionStep.dict() returns raw non-JSON-serializable bytes for observations_images

2 participants