1010 MCPStreamableHTTPTool ,
1111)
1212
13- # from agent_framework.azure import AzureAIAgentClient
14- from agent_framework_azure_ai import AzureAIAgentClient
13+ # from agent_framework.azure import AzureAIClient
14+ from agent_framework_azure_ai import AzureAIClient
1515from azure .ai .agents .aio import AgentsClient
1616from azure .identity .aio import DefaultAzureCredential
1717from common .database .database_base import DatabaseBase
@@ -51,7 +51,7 @@ def __init__(
5151 self ._agent : ChatAgent | None = None
5252 self .team_service : TeamService | None = team_service
5353 self .team_config : TeamConfiguration | None = team_config
54- self .client : Optional [AzureAIAgentClient ] = None
54+ self .client : Optional [AzureAIClient ] = None
5555 self .project_endpoint = project_endpoint
5656 self .creds : Optional [DefaultAzureCredential ] = None
5757 self .memory_store : Optional [DatabaseBase ] = memory_store
@@ -105,7 +105,7 @@ async def close(self) -> None:
105105 # Attempt to close the underlying agent/client if it exposes close()
106106 if self ._agent and hasattr (self ._agent , "close" ):
107107 try :
108- await self ._agent .close () # AzureAIAgentClient has async close
108+ await self ._agent .close () # AzureAIClient has async close
109109 except Exception as exc :
110110 # Best-effort close; log failure but continue teardown
111111 self .logger .warning (
@@ -148,24 +148,22 @@ async def _after_open(self) -> None:
148148 """Subclasses must build self._agent here."""
149149 raise NotImplementedError
150150
151- def get_chat_client (self , chat_client ) -> AzureAIAgentClient :
152- """Return the underlying ChatClientProtocol (AzureAIAgentClient )."""
151+ def get_chat_client (self , chat_client ) -> AzureAIClient :
152+ """Return the underlying ChatClientProtocol (AzureAIClient )."""
153153 if chat_client :
154154 return chat_client
155155 if (
156156 self ._agent
157157 and self ._agent .chat_client
158- and self ._agent .chat_client .agent_id is not None
159158 ):
160159 return self ._agent .chat_client # type: ignore
161- chat_client = AzureAIAgentClient (
160+ chat_client = AzureAIClient (
162161 project_endpoint = self .project_endpoint ,
163162 model_deployment_name = self .model_deployment_name ,
164- async_credential = self .creds ,
163+ credential = self .creds ,
165164 )
166165 self .logger .info (
167- "Created new AzureAIAgentClient for get chat client" ,
168- extra = {"agent_id" : chat_client .agent_id },
166+ "Created new AzureAIClient for get chat client" ,
169167 )
170168 return chat_client
171169
@@ -219,20 +217,17 @@ async def resolve_agent_id(self, agent_id: str) -> Optional[str]:
219217 return None
220218
221219 def get_agent_id (self , chat_client ) -> str :
222- """Return the underlying agent ID."""
223- if chat_client and chat_client .agent_id is not None :
224- return chat_client .agent_id
225- if (
226- self ._agent
227- and self ._agent .chat_client
228- and self ._agent .chat_client .agent_id is not None
229- ):
230- return self ._agent .chat_client .agent_id # type: ignore
220+ """Return the underlying agent ID or generate a new one.
221+
222+ Note: The new AzureAIClient doesn't expose agent_id directly.
223+ We generate a new ID if not available.
224+ """
225+ # Generate a new agent ID since AzureAIClient doesn't expose agent_id
231226 id = generate_assistant_id ()
232227 self .logger .info ("Generated new agent ID: %s" , id )
233228 return id
234229
235- async def get_database_team_agent (self ) -> Optional [AzureAIAgentClient ]:
230+ async def get_database_team_agent (self ) -> Optional [AzureAIClient ]:
236231 """Retrieve existing team agent from database, if any."""
237232 chat_client = None
238233 try :
@@ -258,24 +253,24 @@ async def get_database_team_agent(self) -> Optional[AzureAIAgentClient]:
258253
259254 # Create client with resolved ID, preferring project_client for RAI agents
260255 if self .agent_name == "RAIAgent" and self .project_client :
261- chat_client = AzureAIAgentClient (
256+ chat_client = AzureAIClient (
262257 project_client = self .project_client ,
263258 agent_id = resolved ,
264- async_credential = self .creds ,
259+ credential = self .creds ,
265260 )
266261 self .logger .info (
267- "RAI.AgentReuseSuccess: Created AzureAIAgentClient via Projects SDK (id=%s)" ,
262+ "RAI.AgentReuseSuccess: Created AzureAIClient via Projects SDK (id=%s)" ,
268263 resolved ,
269264 )
270265 else :
271- chat_client = AzureAIAgentClient (
266+ chat_client = AzureAIClient (
272267 project_endpoint = self .project_endpoint ,
273268 agent_id = resolved ,
274269 model_deployment_name = self .model_deployment_name ,
275- async_credential = self .creds ,
270+ credential = self .creds ,
276271 )
277272 self .logger .info (
278- "Created AzureAIAgentClient via endpoint (id=%s)" , resolved
273+ "Created AzureAIClient via endpoint (id=%s)" , resolved
279274 )
280275
281276 except Exception as ex :
@@ -339,10 +334,10 @@ async def _prepare_mcp_tool(self) -> None:
339334
340335class AzureAgentBase (MCPEnabledBase ):
341336 """
342- Extends MCPEnabledBase with Azure credential + AzureAIAgentClient contexts.
337+ Extends MCPEnabledBase with Azure credential + AzureAIClient contexts.
343338 Subclasses:
344339 - create or attach an Azure AI Agent definition
345- - instantiate an AzureAIAgentClient and assign to self._agent
340+ - instantiate an AzureAIClient and assign to self._agent
346341 - optionally register themselves via agent_registry
347342 """
348343
0 commit comments