Fix dict(message) bug in AgentMemory.replay for ChatMessage objects by Flakes342 · Pull Request #1763 · huggingface/smolagents (original) (raw)

Fixes #1742

PR Description

This PR fixes a bug in AgentMemory.replay where dict(message) was called on ChatMessage objects, causing

TypeError: 'ChatMessage' object is not iterable

Changes

Changed dict(message) → message.dict() (Correct pydantic’s method). This makes replay stable when detailed logging is enabled.

Test

Added a simple unit test case to test_monitoring.py
image