microsoft/autogen · error · ValueError
Agent not initialized
Error message
Agent not initialized
What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py:371
self._initial_message_ids: Set[str] = set()
self._initial_state_retrieved: bool = False
# Properties
@property
def produced_message_types(self) -> Sequence[type[ChatMessage]]:
"""The types of messages that the assistant agent produces."""
return (TextMessage,)
@property
def thread_id(self) -> str:
if self._thread is None:
raise ValueError("Thread not initialized")
return self._thread.id
@property
def _get_agent_id(self) -> str:
if self._agent is None:
raise ValueError("Agent not initialized")
return self._agent.id
@property
def description(self) -> str:
if not self._description:
raise ValueError("Description not initialized")
return self._description
@property
def agent_id(self) -> str:
if not self._agent_id:
raise ValueError("Agent not initialized")
return self._agent_id
@property
def deployment_name(self) -> str:
if not self._deployment_name:
raise ValueError("Deployment name not initialized")View on GitHub (pinned to 027ecf0a37)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try:
aid = agent._get_agent_id
except ValueError:
# initialize first, then retry
... Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Calling save_state or introspecting the agent right after construction; a first on_messages that failed before agent creation finished.
Related errors
- Thread not initialized
- Description not initialized
- Deployment name not initialized
- Instructions not initialized
- Unsupported tool string: {tool}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/e6a395a39a580982.
Report an issue: GitHub.