Skip to content

Python: [BREAKING] Python: Provider-leading client design & OpenAI package extraction#4818

Open
eavanvalkenburg wants to merge 10 commits intomicrosoft:mainfrom
eavanvalkenburg:refactor_openai
Open

Python: [BREAKING] Python: Provider-leading client design & OpenAI package extraction#4818
eavanvalkenburg wants to merge 10 commits intomicrosoft:mainfrom
eavanvalkenburg:refactor_openai

Conversation

@eavanvalkenburg
Copy link
Member

Motivation and Context

Make agent-framework-core lightweight by extracting OpenAI clients into their own package, and improve discoverability by using provider-leading naming conventions. See ADR-0020 for full rationale.

Description

New agent-framework-openai package:

  • OpenAIChatClient (Responses API, was OpenAIResponsesClient)
  • OpenAIChatCompletionClient (Chat Completions API, was OpenAIChatClient)
  • OpenAIEmbeddingClient
  • Raw clients do all work (settings, client creation); public clients just combine layers

Core made lighter:

  • Removed openai, azure-identity, azure-ai-projects, packaging from core deps
  • agent_framework.openai and agent_framework.azure are lazy-loading gateways

New Foundry clients in azure-ai:

  • FoundryChatClient / RawFoundryChatClient — Responses API via Foundry project
  • FoundryAgent / RawFoundryAgent — connect to pre-configured PromptAgents/HostedAgents
  • RawFoundryAgentChatClient — extension point for custom client middleware

Parameter unification:

  • model_id / deployment_name / model_deployment_namemodel
  • OPENAI_RESPONSES_MODEL_ID / OPENAI_CHAT_MODEL_IDOPENAI_MODEL
  • FOUNDRY_MODEL, FOUNDRY_PROJECT_ENDPOINT for Foundry clients

Class hierarchy cleanup:

  • OpenAIBase / OpenAIConfigMixin removed from non-deprecated MRO
  • _ensure_client / _initialize_client removed (client set directly in Raw init)
  • Deprecated: AzureOpenAI* clients, AzureAIClient, AzureAIAgentClient, OpenAIAssistantsClient
  • All deprecated Azure OpenAI classes in single _deprecated_azure_openai.py for clean deletion

Samples:

  • azure_openai/ + azure_ai/ + azure_ai_agent/ merged into azure/
  • CRUD-based Azure AI samples removed (no longer supported)
  • New FoundryAgent and FoundryChatClient samples added
  • Default client for concept samples: FoundryChatClient
  • as_agent() replaced with Agent(client=...) pattern
  • Always AzureCliCredential, never DefaultAzureCredential

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? Yes — client renames, parameter renames, package extraction

Copilot AI review requested due to automatic review settings March 20, 2026 16:23
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python lab Agent Framework Lab labels Mar 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions github-actions bot changed the title [BREAKING] Python: Provider-leading client design & OpenAI package extraction Python: [BREAKING] Python: Provider-leading client design & OpenAI package extraction Mar 20, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Mar 20, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/azure-ai-search/agent_framework_azure_ai_search
   _context_provider.py3361097%110–111, 284, 335–336, 459–460, 638–639, 686
packages/azure-ai/agent_framework_azure_ai
   _agent_provider.py114199%270
   _chat_client.py4957884%465–466, 468, 658, 663–664, 666–667, 670, 673, 675, 680, 941–942, 944, 947, 950, 953–958, 961, 963, 971, 983–985, 989, 992–993, 1001–1004, 1014, 1022–1025, 1027–1028, 1030–1031, 1038, 1046–1047, 1055–1068, 1073, 1076, 1084, 1090, 1098–1100, 1103, 1123–1124, 1257, 1284, 1299, 1415, 1465, 1471
   _client.py4034987%214, 394, 396, 444, 454–458, 460–466, 479, 540, 555–560, 602, 618–619, 645–646, 664, 695, 697, 718–719, 722, 767, 770, 772, 863, 894, 936, 1145, 1148, 1151–1152, 1154–1157
   _deprecated_azure_openai.py3326281%152–159, 161–162, 164–165, 167, 170–183, 185, 187–193, 195, 197–198, 200, 309, 328, 333, 338, 344, 350, 354, 395, 401–404, 542, 547, 558, 612–613, 622, 853, 863, 869, 873, 892
   _entra_id_authentication.py220100% 
   _foundry_agent.py441956%157, 159, 161–163, 165–168, 173, 175–178, 183, 185–186, 188, 194
   _foundry_agent_client.py1003070%159–160, 164–166, 171–174, 215, 237–238, 250–252, 254–255, 257–263, 265–266, 268, 270, 274–275
   _foundry_chat_client.py1214959%126, 135–137, 139, 141–142, 146–148, 153–155, 160–162, 164, 170, 174–177, 201, 203–206, 211, 213–216, 221, 223–224, 226, 232, 254, 315, 317, 405, 407, 409–410, 412–415, 508
   _foundry_memory_provider.py910100% 
   _project_provider.py122595%157, 213, 312, 352, 385
packages/azure-cosmos/agent_framework_azure_cosmos
   _history_provider.py125596%162–164, 261, 268
packages/core/agent_framework
   _types.py10748891%58, 67–68, 122, 127, 146, 148, 152, 156, 158, 160, 162, 180, 184, 210, 232, 237, 242, 246, 276, 686–687, 846–847, 1232, 1304, 1339, 1359, 1369, 1413, 1545–1547, 1737, 1828–1833, 1858, 2030, 2042, 2306, 2331, 2339, 2434, 2665, 2871, 2940, 2951, 2953–2957, 2959, 2962–2970, 2980, 3185–3187, 3190–3192, 3196, 3201, 3205, 3289–3291, 3320, 3374, 3397–3401, 3407, 3491
packages/core/agent_framework/_workflows
   _events.py1492185%90–91, 224, 228, 230, 262, 337, 352, 367, 382, 394–396, 408–410, 412–413, 415–416, 420
packages/foundry_local/agent_framework_foundry_local
   _foundry_local_client.py420100% 
packages/openai/agent_framework_openai
   _assistant_provider.py1091189%162, 290, 356, 471–478
   _assistants_client.py3333689%428, 430, 432, 435, 439–440, 443, 446, 451–452, 454, 457–459, 464, 475, 500, 502, 504, 506, 508, 513, 516, 519, 523, 534, 729, 815, 818, 837, 848, 885–888, 958
   _chat_client.py85913184%296, 298–299, 337, 355, 408–411, 415–416, 421–422, 432–433, 440, 455–461, 482, 490, 513, 610, 709, 768, 770, 772, 774, 840, 854, 934, 944, 949, 992, 1071, 1088, 1101, 1166, 1259, 1264, 1268–1270, 1274–1275, 1341, 1370, 1376, 1386, 1392, 1397, 1403, 1408–1409, 1470, 1492–1493, 1508–1509, 1527–1528, 1569–1572, 1734, 1789, 1791, 1871–1879, 2001, 2056, 2071, 2091–2101, 2114, 2125–2129, 2143, 2157–2168, 2177, 2209–2212, 2220–2221, 2223–2225, 2239–2241, 2251–2252, 2258, 2273
   _chat_completion_client.py3673391%205, 207–208, 264, 314, 395–396, 400, 525, 532, 608–615, 617–620, 630, 708, 710, 727, 748, 776, 789, 813, 833, 873, 948
   _embedding_client.py921089%93, 95–96, 133, 135, 146, 156, 191, 292, 300
   _exceptions.py330100% 
   _shared.py1382284%64, 70–73, 165, 167–168, 184, 186, 188, 195, 197, 210, 291, 296, 315, 374–377, 379
packages/orchestrations/agent_framework_orchestrations
   _sequential.py881187%74, 172, 183, 189, 220, 222–223, 225, 230, 247, 251
packages/purview/agent_framework_purview
   _client.py128298%74–75
   _middleware.py1170100% 
TOTAL27759341287% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5369 20 💤 0 ❌ 0 🔥 1m 27s ⏱️

eavanvalkenburg and others added 10 commits March 21, 2026 16:39
## Summary
Major refactoring of the Python Agent Framework client architecture:

- Extract OpenAI clients into new `agent-framework-openai` package
- Core package no longer depends on openai, azure-identity, azure-ai-projects
- Rename clients for discoverability: OpenAIResponsesClient → OpenAIChatClient,
  OpenAIChatClient → OpenAIChatCompletionClient
- Unify `model_id`/`deployment_name`/`model_deployment_name` → `model` param
- New FoundryChatClient for Azure AI Foundry Responses API
- New FoundryAgent/FoundryAgentClient for connecting to pre-configured Foundry agents
- Remove OpenAIBase/OpenAIConfigMixin from non-deprecated client MRO
- Deprecate AzureOpenAI* clients, AzureAIClient, OpenAIAssistantsClient
- Reorganize samples: azure_openai+azure_ai+azure_ai_agent → azure/
- ADR-0020: Provider-Leading Client Design

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…local sample

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- azure-ai mypy: add type ignores for TypedDict total=, model arg, forward ref
- Coverage: replace core.azure/openai targets with openai package target
- project_provider: add type annotation for opts dict

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gets

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lab Agent Framework Lab python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants