{"record":{"id":"e6a395a39a580982","repo":"microsoft/autogen","slug":"agent-not-initialized","errorCode":null,"errorMessage":"Agent not initialized","messagePattern":"Agent not initialized","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py","lineNumber":371,"sourceCode":"        self._initial_message_ids: Set[str] = set()\n        self._initial_state_retrieved: bool = False\n\n    # Properties\n    @property\n    def produced_message_types(self) -> Sequence[type[ChatMessage]]:\n        \"\"\"The types of messages that the assistant agent produces.\"\"\"\n        return (TextMessage,)\n\n    @property\n    def thread_id(self) -> str:\n        if self._thread is None:\n            raise ValueError(\"Thread not initialized\")\n        return self._thread.id\n\n    @property\n    def _get_agent_id(self) -> str:\n        if self._agent is None:\n            raise ValueError(\"Agent not initialized\")\n        return self._agent.id\n\n    @property\n    def description(self) -> str:\n        if not self._description:\n            raise ValueError(\"Description not initialized\")\n        return self._description\n\n    @property\n    def agent_id(self) -> str:\n        if not self._agent_id:\n            raise ValueError(\"Agent not initialized\")\n        return self._agent_id\n\n    @property\n    def deployment_name(self) -> str:\n        if not self._deployment_name:\n            raise ValueError(\"Deployment name not initialized\")","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py#L353-L389","documentation":"Raised by the private helper _get_agent_id on AzureAIAgent when the Azure AI agent object (_agent) is None — i.e. the cloud agent resource has not been created/retrieved yet. Like thread_id, it depends on lazy initialization completing at least once.","triggerScenarios":"Accessing the internal _get_agent_id property (or code that uses it, e.g. state saving / agent management paths) before _ensure_initialized has run and created/fetched the Azure agent.","commonSituations":"Calling save_state or introspecting the agent right after construction; a first on_messages that failed before agent creation finished.","solutions":["Run one successful interaction (or explicit initialization) before touching agent identity properties.","Create the agent up front via the Azure SDK and pass the existing agent to the constructor so _agent is set at init.","Avoid relying on the private _get_agent_id; use the public agent_id / documented APIs after initialization."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    aid = agent._get_agent_id\nexcept ValueError:\n    # initialize first, then retry\n    ...","preventionTips":["Treat _get_agent_id as internal; use public APIs after initialization.","Ensure the first on_messages call succeeds before state operations.","Pass an existing Azure agent at construction to make identity available immediately."],"tags":["azure","lifecycle","azure-ai-agent","internal-api"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}