Skip to content

Commit 45582e1

Browse files
Enhance get_chat_client to use latest agent version and log agent name
1 parent 1bc5725 commit 45582e1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/backend/v4/magentic_agents/common/lifecycle.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ async def _after_open(self) -> None:
149149
raise NotImplementedError
150150

151151
def get_chat_client(self, chat_client) -> AzureAIClient:
152-
"""Return the underlying ChatClientProtocol (AzureAIClient)."""
152+
"""Return the underlying ChatClientProtocol (AzureAIClient).
153+
154+
Uses agent_name with use_latest_version=True to get the latest agent version
155+
"""
153156
if chat_client:
154157
return chat_client
155158
if (
@@ -159,11 +162,14 @@ def get_chat_client(self, chat_client) -> AzureAIClient:
159162
return self._agent.chat_client # type: ignore
160163
chat_client = AzureAIClient(
161164
project_endpoint=self.project_endpoint,
165+
agent_name=self.agent_name,
162166
model_deployment_name=self.model_deployment_name,
163167
credential=self.creds,
168+
use_latest_version=True,
164169
)
165170
self.logger.info(
166-
"Created new AzureAIClient for get chat client",
171+
"Created new AzureAIClient (agent_name=%s, use_latest_version=True)",
172+
self.agent_name,
167173
)
168174
return chat_client
169175

0 commit comments

Comments
 (0)