{"record":{"id":"7a12a27416b5ed11","repo":"microsoft/autogen","slug":"invalid-state-format-the-expected-state-format-ha","errorCode":null,"errorMessage":"Invalid state format. The expected state format has changed since v0.4.9. Please read the release note on GitHub.","messagePattern":"Invalid state format\\. The expected state format has changed since v0\\.4\\.9\\. Please read the release note on GitHub\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py","lineNumber":827,"sourceCode":"            raise RuntimeError(\"The team cannot be loaded while it is running.\")\n        self._is_running = True\n\n        try:\n            team_state = TeamState.model_validate(state)\n            # Load the state of all participants.\n            for name, agent_type in zip(self._participant_names, self._participant_topic_types, strict=True):\n                agent_id = AgentId(type=agent_type, key=self._team_id)\n                if name not in team_state.agent_states:\n                    raise ValueError(f\"Agent state for {name} not found in the saved state.\")\n                await self._runtime.agent_load_state(agent_id, team_state.agent_states[name])\n            # Load the state of the group chat manager.\n            agent_id = AgentId(type=self._group_chat_manager_topic_type, key=self._team_id)\n            if self._group_chat_manager_name not in team_state.agent_states:\n                raise ValueError(f\"Agent state for {self._group_chat_manager_name} not found in the saved state.\")\n            await self._runtime.agent_load_state(agent_id, team_state.agent_states[self._group_chat_manager_name])\n\n        except ValidationError as e:\n            raise ValueError(\n                \"Invalid state format. The expected state format has changed since v0.4.9. \"\n                \"Please read the release note on GitHub.\"\n            ) from e\n\n        finally:\n            # Indicate that the team is no longer running.\n            self._is_running = False\n","sourceCodeStart":809,"sourceCodeEnd":835,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py#L809-L835","documentation":"A pydantic ValidationError while TeamState.model_validate(state) runs is caught and re-raised as this friendlier ValueError: the dict passed to load_state() does not match the current TeamState schema, which changed in v0.4.9. The original validation error is chained as __cause__ for details.","triggerScenarios":"Passing a pre-0.4.9 state dict (different field names/structure) to load_state(); passing arbitrary JSON that is not a TeamState at all; truncated or re-serialized state files that lost nested types.","commonSituations":"Upgrading autogen-agentchat past 0.4.9 and loading old checkpoints; persisting state through a layer that mangles nested structures; loading a state file from a different library version.","solutions":["Read the chained error for the exact field mismatch: except ValueError as e: print(e.__cause__).","Discard or regenerate old checkpoints — the pre-0.4.9 format is not loadable; start a fresh conversation and re-save.","If migrating programmatically, transform the old dict into the current TeamState schema (see the v0.4.9 release notes) before calling load_state()."],"exampleFix":"# before\nawait team.load_state(old_checkpoint)  # ValueError: invalid state format\n\n# after\ntry:\n    await team.load_state(old_checkpoint)\nexcept ValueError as e:\n    print(\"schema errors:\", e.__cause__)  # decide: migrate or start fresh\n    raise","handlingStrategy":"try-catch","validationCode":"from autogen_agentchat.teams._group_chat._base_group_chat import TeamState\ntry:\n    TeamState.model_validate(state)  # schema pre-check\nexcept Exception:\n    raise ValueError(\"state file is not in the current TeamState format; regenerate it\")","typeGuard":null,"tryCatchPattern":"try:\n    await team.load_state(state)\nexcept ValueError as e:\n    if \"state format has changed\" in str(e):\n        logger.error(\"stale checkpoint (pre-0.4.9): %s\", e.__cause__)\n        state = None  # start a fresh session\n    else:\n        raise","preventionTips":["Version-tag checkpoint files with the library version that wrote them.","After upgrading autogen-agentchat, migrate or regenerate checkpoints before use.","Inspect e.__cause__ (pydantic ValidationError) to see exactly which fields fail."],"tags":["python","autogen","state","version-migration","pydantic"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}