Description
What happened?
Describe the bug
When a team state with save_state
a serialization exception is raised and the state is truncated at the first datetime.
To Reproduce
A Swarm team was created, with only one assistant agent:
# Assume existing and working model_client and project_search
project_agent = AssistantAgent(
name="ProjectSearchAgent",
model_client=model_client,
tools=[project_search],
system_message="You are a project search agent. Search for information and respond with JSON: {\"response\": \"your answer\", \"terminate\": \"TERMINATE\"}",
output_content_type_format="json_object"
)
# Team setup
termination = TextMentionTermination("TERMINATE")
team = Swarm([project_agent], termination_condition=termination)
async def main():
result = await team.run(task="What is a Montague?")
team_state = await team.save_state()
with open(state_file, "w") as f:
json.dump(team_state, f) # This throws "Object of type datetime is not JSON serializable"
Expected behavior
The state should be dumped without errors, as per (documentation)[https://microsoft.github.io/autogen/stable//user-guide/agentchat-user-guide/tutorial/state.html#persisting-state-file-or-database].
Workaround
A good workaround is to jsonpickle
the state. It should be documented, though
Which packages was the bug in?
Python AgentChat (autogen-agentchat>=0.4.0)
AutoGen library version.
Python 0.6.4
Other library version.
autogen-ext = {extras = ["anthropic"], version = "^0.6.2"}
Model used
eu.anthropic.claude-sonnet-4-20250514-v1:
Model provider
AWS Bedrock
Other model provider
No response
Python version
3.13
.NET version
None
Operating system
MacOS