bug: role not converted back to enum by njbrake · Pull Request #1833 · huggingface/smolagents (original) (raw)

Found while working on mozilla-ai/any-agent#609 :

When creating a message from a dict, it initializes role as a string instead of an enum. Maybe a quirk of defining the class as MessageRole(str, Enum) that isn't catching in your static code checks, because it lets you pass in a string, but then it doesnt convert it to an enum later, which means later calls that want to access like chat_message.role.value will fail because role is actually a string and not an enum.