Skip to content

Commit 4e87965

Browse files
fix: apply breaking-change fixes for agent-framework 1.1.1
agent-framework stable releases (1.1.1+) have the same API changes as 1.3.0: - Individual event classes replaced by unified WorkflowEvent with type field - Azure OpenAI clients moved to agent_framework.openai sub-package - Constructor params renamed (deployment_name->model, endpoint->azure_endpoint) - ChatMessage(text=...) replaced with ChatMessage(contents=[...]) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 77f0171 commit 4e87965

14 files changed

Lines changed: 137 additions & 210 deletions

File tree

src/ContentProcessor/src/libs/agent_framework/agent_framework_helper.py

Lines changed: 29 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
)
2929

3030
if TYPE_CHECKING:
31-
from agent_framework.azure import (
32-
AzureAIAgentClient,
33-
AzureOpenAIAssistantsClient,
34-
AzureOpenAIChatClient,
35-
AzureOpenAIResponsesClient,
31+
from agent_framework.openai import (
32+
OpenAIChatClient,
33+
OpenAIChatCompletionClient,
3634
)
3735

3836

@@ -142,7 +140,7 @@ def create_client(
142140
env_file_path: str | None = None,
143141
env_file_encoding: str | None = None,
144142
instruction_role: str | None = None,
145-
) -> "AzureOpenAIChatClient":
143+
) -> "OpenAIChatCompletionClient":
146144
pass
147145

148146
@overload
@@ -189,7 +187,7 @@ def create_client(
189187
async_client: object | None = None,
190188
env_file_path: str | None = None,
191189
env_file_encoding: str | None = None,
192-
) -> "AzureOpenAIAssistantsClient":
190+
) -> Any:
193191
pass
194192

195193
@overload
@@ -211,7 +209,7 @@ def create_client(
211209
env_file_path: str | None = None,
212210
env_file_encoding: str | None = None,
213211
instruction_role: str | None = None,
214-
) -> "AzureOpenAIResponsesClient":
212+
) -> "OpenAIChatClient":
215213
pass
216214

217215
@overload
@@ -251,7 +249,7 @@ def create_client(
251249
async_credential: object | None = None,
252250
env_file_path: str | None = None,
253251
env_file_encoding: str | None = None,
254-
) -> "AzureAIAgentClient":
252+
) -> Any:
255253
pass
256254

257255
@staticmethod
@@ -384,18 +382,15 @@ def create_client(
384382
"OpenAIResponsesClient is not implemented in this context."
385383
)
386384
elif client_type == ClientType.AzureOpenAIChatCompletion:
387-
from agent_framework.azure import AzureOpenAIChatClient
385+
from agent_framework.openai import OpenAIChatCompletionClient
388386

389-
return AzureOpenAIChatClient(
387+
return OpenAIChatCompletionClient(
388+
model=deployment_name,
390389
api_key=api_key,
391-
deployment_name=deployment_name,
392-
endpoint=endpoint,
390+
azure_endpoint=endpoint,
393391
base_url=base_url,
394392
api_version=api_version,
395-
ad_token=ad_token,
396-
ad_token_provider=ad_token_provider,
397-
token_endpoint=token_endpoint,
398-
credential=credential,
393+
credential=credential or ad_token_provider,
399394
default_headers=default_headers,
400395
async_client=async_client,
401396
env_file_path=env_file_path,
@@ -404,15 +399,12 @@ def create_client(
404399
)
405400
elif client_type == ClientType.AzureOpenAIChatCompletionWithRetry:
406401
return AzureOpenAIChatClientWithRetry(
402+
model=deployment_name,
407403
api_key=api_key,
408-
deployment_name=deployment_name,
409-
endpoint=endpoint,
404+
azure_endpoint=endpoint,
410405
base_url=base_url,
411406
api_version=api_version,
412-
ad_token=ad_token,
413-
ad_token_provider=ad_token_provider,
414-
token_endpoint=token_endpoint,
415-
credential=credential,
407+
credential=credential or ad_token_provider,
416408
default_headers=default_headers,
417409
async_client=async_client,
418410
env_file_path=env_file_path,
@@ -421,39 +413,20 @@ def create_client(
421413
retry_config=retry_config,
422414
)
423415
elif client_type == ClientType.AzureOpenAIAssistant:
424-
from agent_framework.azure import AzureOpenAIAssistantsClient
425-
426-
return AzureOpenAIAssistantsClient(
427-
deployment_name=deployment_name,
428-
assistant_id=assistant_id,
429-
assistant_name=assistant_name,
430-
thread_id=thread_id,
431-
api_key=api_key,
432-
endpoint=endpoint,
433-
base_url=base_url,
434-
api_version=api_version,
435-
ad_token=ad_token,
436-
ad_token_provider=ad_token_provider,
437-
token_endpoint=token_endpoint,
438-
credential=credential,
439-
default_headers=default_headers,
440-
async_client=async_client,
441-
env_file_path=env_file_path,
442-
env_file_encoding=env_file_encoding,
416+
raise NotImplementedError(
417+
"AzureOpenAIAssistantsClient has been removed in agent-framework 1.1.1. "
418+
"Use OpenAIChatClient with built-in tools instead."
443419
)
444420
elif client_type == ClientType.AzureOpenAIResponse:
445-
from agent_framework.azure import AzureOpenAIResponsesClient
421+
from agent_framework.openai import OpenAIChatClient
446422

447-
return AzureOpenAIResponsesClient(
423+
return OpenAIChatClient(
424+
model=deployment_name,
448425
api_key=api_key,
449-
deployment_name=deployment_name,
450-
endpoint=endpoint,
426+
azure_endpoint=endpoint,
451427
base_url=base_url,
452428
api_version=api_version,
453-
ad_token=ad_token,
454-
ad_token_provider=ad_token_provider,
455-
token_endpoint=token_endpoint,
456-
credential=credential,
429+
credential=credential or ad_token_provider,
457430
default_headers=default_headers,
458431
async_client=async_client,
459432
env_file_path=env_file_path,
@@ -462,15 +435,12 @@ def create_client(
462435
)
463436
elif client_type == ClientType.AzureOpenAIResponseWithRetry:
464437
return AzureOpenAIResponseClientWithRetry(
438+
model=deployment_name,
465439
api_key=api_key,
466-
deployment_name=deployment_name,
467-
endpoint=endpoint,
440+
azure_endpoint=endpoint,
468441
base_url=base_url,
469442
api_version=api_version,
470-
ad_token=ad_token,
471-
ad_token_provider=ad_token_provider,
472-
token_endpoint=token_endpoint,
473-
credential=credential,
443+
credential=credential or ad_token_provider,
474444
default_headers=default_headers,
475445
async_client=async_client,
476446
env_file_path=env_file_path,
@@ -479,18 +449,9 @@ def create_client(
479449
retry_config=retry_config,
480450
)
481451
elif client_type == ClientType.AzureOpenAIAgent:
482-
from agent_framework.azure import AzureAIAgentClient
483-
484-
return AzureAIAgentClient(
485-
project_client=project_client,
486-
agent_id=agent_id,
487-
agent_name=agent_name,
488-
thread_id=thread_id,
489-
project_endpoint=project_endpoint,
490-
model_deployment_name=model_deployment_name,
491-
async_credential=async_credential,
492-
env_file_path=env_file_path,
493-
env_file_encoding=env_file_encoding,
452+
raise NotImplementedError(
453+
"AzureAIAgentClient has been removed in agent-framework 1.1.1. "
454+
"Use FoundryChatClient from agent_framework.foundry instead."
494455
)
495456
else:
496457
raise ValueError(f"Unsupported agent type: {client_type}")

src/ContentProcessor/src/libs/agent_framework/azure_openai_response_retry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from dataclasses import dataclass
2020
from typing import Any, AsyncIterable, MutableSequence
2121

22-
from agent_framework.azure import AzureOpenAIChatClient, AzureOpenAIResponsesClient
22+
from agent_framework.openai import OpenAIChatCompletionClient, OpenAIChatClient
2323
from tenacity import (
2424
AsyncRetrying,
2525
retry_if_exception,
@@ -462,7 +462,7 @@ def __call__(self, retry_state) -> float:
462462
raise RuntimeError("Retry loop exhausted unexpectedly")
463463

464464

465-
class AzureOpenAIResponseClientWithRetry(AzureOpenAIResponsesClient):
465+
class AzureOpenAIResponseClientWithRetry(OpenAIChatClient):
466466
"""Azure OpenAI Responses client with 429 retry at the request boundary.
467467
468468
Retry is centralized in the client layer (not in orchestrators) by retrying the
@@ -678,7 +678,7 @@ async def _tail():
678678
await asyncio.sleep(delay)
679679

680680

681-
class AzureOpenAIChatClientWithRetry(AzureOpenAIChatClient):
681+
class AzureOpenAIChatClientWithRetry(OpenAIChatCompletionClient):
682682
"""Azure OpenAI Chat client with 429 retry at the request boundary.
683683
684684
This wraps the underlying chat-completions call used by Agent Framework by overriding

src/ContentProcessorWorkflow/src/libs/agent_framework/agent_framework_helper.py

Lines changed: 29 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
)
2929

3030
if TYPE_CHECKING:
31-
from agent_framework.azure import (
32-
AzureAIAgentClient,
33-
AzureOpenAIAssistantsClient,
34-
AzureOpenAIChatClient,
35-
AzureOpenAIResponsesClient,
31+
from agent_framework.openai import (
32+
OpenAIChatClient,
33+
OpenAIChatCompletionClient,
3634
)
3735

3836

@@ -142,7 +140,7 @@ def create_client( # noqa: E704
142140
env_file_path: str | None = None,
143141
env_file_encoding: str | None = None,
144142
instruction_role: str | None = None,
145-
) -> "AzureOpenAIChatClient":
143+
) -> "OpenAIChatCompletionClient":
146144
pass
147145

148146
@overload
@@ -189,7 +187,7 @@ def create_client( # noqa: E704
189187
async_client: object | None = None,
190188
env_file_path: str | None = None,
191189
env_file_encoding: str | None = None,
192-
) -> "AzureOpenAIAssistantsClient":
190+
) -> Any:
193191
raise NotImplementedError
194192

195193
@overload
@@ -211,7 +209,7 @@ def create_client( # noqa: E704
211209
env_file_path: str | None = None,
212210
env_file_encoding: str | None = None,
213211
instruction_role: str | None = None,
214-
) -> "AzureOpenAIResponsesClient":
212+
) -> "OpenAIChatClient":
215213
pass
216214

217215
@overload
@@ -251,7 +249,7 @@ def create_client( # noqa: E704
251249
async_credential: object | None = None,
252250
env_file_path: str | None = None,
253251
env_file_encoding: str | None = None,
254-
) -> "AzureAIAgentClient":
252+
) -> Any:
255253
pass
256254

257255
@staticmethod
@@ -384,18 +382,15 @@ def create_client(
384382
"OpenAIResponsesClient is not implemented in this context."
385383
)
386384
elif client_type == ClientType.AzureOpenAIChatCompletion:
387-
from agent_framework.azure import AzureOpenAIChatClient
385+
from agent_framework.openai import OpenAIChatCompletionClient
388386

389-
return AzureOpenAIChatClient(
387+
return OpenAIChatCompletionClient(
388+
model=deployment_name,
390389
api_key=api_key,
391-
deployment_name=deployment_name,
392-
endpoint=endpoint,
390+
azure_endpoint=endpoint,
393391
base_url=base_url,
394392
api_version=api_version,
395-
ad_token=ad_token,
396-
ad_token_provider=ad_token_provider,
397-
token_endpoint=token_endpoint,
398-
credential=credential,
393+
credential=credential or ad_token_provider,
399394
default_headers=default_headers,
400395
async_client=async_client,
401396
env_file_path=env_file_path,
@@ -404,15 +399,12 @@ def create_client(
404399
)
405400
elif client_type == ClientType.AzureOpenAIChatCompletionWithRetry:
406401
return AzureOpenAIChatClientWithRetry(
402+
model=deployment_name,
407403
api_key=api_key,
408-
deployment_name=deployment_name,
409-
endpoint=endpoint,
404+
azure_endpoint=endpoint,
410405
base_url=base_url,
411406
api_version=api_version,
412-
ad_token=ad_token,
413-
ad_token_provider=ad_token_provider,
414-
token_endpoint=token_endpoint,
415-
credential=credential,
407+
credential=credential or ad_token_provider,
416408
default_headers=default_headers,
417409
async_client=async_client,
418410
env_file_path=env_file_path,
@@ -421,39 +413,20 @@ def create_client(
421413
retry_config=retry_config,
422414
)
423415
elif client_type == ClientType.AzureOpenAIAssistant:
424-
from agent_framework.azure import AzureOpenAIAssistantsClient
425-
426-
return AzureOpenAIAssistantsClient(
427-
deployment_name=deployment_name,
428-
assistant_id=assistant_id,
429-
assistant_name=assistant_name,
430-
thread_id=thread_id,
431-
api_key=api_key,
432-
endpoint=endpoint,
433-
base_url=base_url,
434-
api_version=api_version,
435-
ad_token=ad_token,
436-
ad_token_provider=ad_token_provider,
437-
token_endpoint=token_endpoint,
438-
credential=credential,
439-
default_headers=default_headers,
440-
async_client=async_client,
441-
env_file_path=env_file_path,
442-
env_file_encoding=env_file_encoding,
416+
raise NotImplementedError(
417+
"AzureOpenAIAssistantsClient has been removed in agent-framework 1.1.1. "
418+
"Use OpenAIChatClient with built-in tools instead."
443419
)
444420
elif client_type == ClientType.AzureOpenAIResponse:
445-
from agent_framework.azure import AzureOpenAIResponsesClient
421+
from agent_framework.openai import OpenAIChatClient
446422

447-
return AzureOpenAIResponsesClient(
423+
return OpenAIChatClient(
424+
model=deployment_name,
448425
api_key=api_key,
449-
deployment_name=deployment_name,
450-
endpoint=endpoint,
426+
azure_endpoint=endpoint,
451427
base_url=base_url,
452428
api_version=api_version,
453-
ad_token=ad_token,
454-
ad_token_provider=ad_token_provider,
455-
token_endpoint=token_endpoint,
456-
credential=credential,
429+
credential=credential or ad_token_provider,
457430
default_headers=default_headers,
458431
async_client=async_client,
459432
env_file_path=env_file_path,
@@ -462,15 +435,12 @@ def create_client(
462435
)
463436
elif client_type == ClientType.AzureOpenAIResponseWithRetry:
464437
return AzureOpenAIResponseClientWithRetry(
438+
model=deployment_name,
465439
api_key=api_key,
466-
deployment_name=deployment_name,
467-
endpoint=endpoint,
440+
azure_endpoint=endpoint,
468441
base_url=base_url,
469442
api_version=api_version,
470-
ad_token=ad_token,
471-
ad_token_provider=ad_token_provider,
472-
token_endpoint=token_endpoint,
473-
credential=credential,
443+
credential=credential or ad_token_provider,
474444
default_headers=default_headers,
475445
async_client=async_client,
476446
env_file_path=env_file_path,
@@ -479,18 +449,9 @@ def create_client(
479449
retry_config=retry_config,
480450
)
481451
elif client_type == ClientType.AzureOpenAIAgent:
482-
from agent_framework.azure import AzureAIAgentClient
483-
484-
return AzureAIAgentClient(
485-
project_client=project_client,
486-
agent_id=agent_id,
487-
agent_name=agent_name,
488-
thread_id=thread_id,
489-
project_endpoint=project_endpoint,
490-
model_deployment_name=model_deployment_name,
491-
async_credential=async_credential,
492-
env_file_path=env_file_path,
493-
env_file_encoding=env_file_encoding,
452+
raise NotImplementedError(
453+
"AzureAIAgentClient has been removed in agent-framework 1.1.1. "
454+
"Use FoundryChatClient from agent_framework.foundry instead."
494455
)
495456
else:
496457
raise ValueError(f"Unsupported agent type: {client_type}")

0 commit comments

Comments
 (0)