Skip to content

Python: [BREAKING] Reduce core dependencies and simplify optional integrations - #4904

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:reduce_deps
Mar 25, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 3 commits into
microsoft:mainfrom
eavanvalkenburg:reduce_deps

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

Motivation and Context

Slim down agent-framework-core by removing provider- and SDK-specific runtime dependencies, make optional MCP/OpenTelemetry integrations fail only when they are actually used, and keep agent telemetry latency from including agent middleware overhead.

Description

  • remove provider-specific and SDK-specific dependencies from agent-framework-core, move direct runtime dependencies to the packages that actually use them (agent-framework-azure-ai, agent-framework-devui, and the gaia lab extra), and refresh repo/dev dependency wiring
  • simplify MCP optional dependency handling by localizing runtime imports, keeping typing-only MCP imports under TYPE_CHECKING, updating missing-dependency guidance to point directly to mcp/mcp[ws], and expanding MCP regression coverage
  • simplify observability optional SDK loading, remove cached resource state, inline the semantic-convention constants used by core, eliminate noisy OTEL exporter setup in core tests, and ensure AgentMiddlewareLayer wraps AgentTelemetryLayer for both Agent and FoundryAgent

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? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings March 25, 2026 14:43
@markwallace-microsoft Mark Wallace (markwallace-microsoft) added python Usage: [Issues, PRs], Target: Python lab labels Mar 25, 2026
@markwallace-microsoft

Mark Wallace (markwallace-microsoft) commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _agents.py3634787%465, 469, 524, 936, 972, 988, 1085–1089, 1144, 1172, 1305, 1321, 1323, 1336, 1342, 1387, 1389, 1398–1403, 1408, 1410, 1416–1417, 1424, 1426–1427, 1435–1436, 1439–1441, 1451–1456, 1460, 1465, 1467
   _mcp.py5582994%269, 329–330, 459, 521, 534, 536–539, 558–559, 572–575, 577–578, 582, 644–646, 965, 1078, 1130–1131, 1134, 1152, 1557
   observability.py7478388%376, 378–379, 382, 385, 388–389, 394–395, 401–402, 408–409, 416, 418–420, 423–425, 430–431, 437–438, 444–445, 452, 609–610, 738, 742–744, 746, 750–751, 755, 793, 795, 806–808, 810–812, 816, 824, 948–949, 1111, 1355–1356, 1453–1458, 1465–1468, 1472–1480, 1487, 1608–1612, 1669–1670, 1810, 2008, 2226, 2228
packages/foundry/agent_framework_foundry
   _foundry_agent.py441956%157, 159, 161–163, 165–168, 173, 175–178, 183, 185–186, 188, 194
TOTAL27962341287% 

Python Unit Test Overview

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR slims down the Python agent-framework-core distribution by removing provider/SDK runtime dependencies, making MCP and OpenTelemetry SDK usage fail only when those integrations are invoked, and ensuring agent middleware time is excluded from agent telemetry latency measurements.

Changes:

  • Move provider/SDK dependencies out of agent-framework-core into the packages that require them, and refresh repo/dev dependency wiring.
  • Refactor MCP and observability code paths to use localized runtime imports and improved missing-dependency guidance; add/expand regression tests.
  • Change Agent and FoundryAgent base-class ordering so AgentMiddlewareLayer wraps AgentTelemetryLayer, with tests enforcing the MRO.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
python/uv.lock Updates locked dev/runtime dependencies to reflect moved integrations and removed OTEL semconv-ai dependency.
python/pyproject.toml Adds dev-only dependencies for MCP websocket support and OpenTelemetry SDK.
python/packages/lab/pyproject.toml Adds opentelemetry-sdk to the GAIA extra to keep integration working after core dep slimming.
python/packages/foundry/tests/test_foundry_agent.py Adds a regression test ensuring middleware wraps telemetry in FoundryAgent.
python/packages/foundry/agent_framework_foundry/_foundry_agent.py Reorders base classes to put middleware outside telemetry timing.
python/packages/devui/pyproject.toml Adds opentelemetry-sdk since core no longer depends on it directly.
python/packages/core/tests/core/test_optional_dependencies.py New tests validating optional dependency behavior for OTEL SDK and MCP.
python/packages/core/tests/core/test_observability.py Avoids noisy OTEL exporter setup in tests; adds MRO regression test for Agent.
python/packages/core/tests/core/test_mcp.py Expands MCP parsing/transport tests and updates patch targets to MCP’s runtime import locations.
python/packages/core/tests/conftest.py Adjusts OTEL test fixture to create resources without relying on cached settings state.
python/packages/core/pyproject.toml Removes provider/SDK deps from core; keeps MCP as an optional extra and adds openai package to “all”.
python/packages/core/agent_framework/observability.py Localizes OTEL SDK imports, removes cached resource state, and inlines semantic convention names used by core.
python/packages/core/agent_framework/_mcp.py Localizes MCP imports and refactors helper parsing into instance methods; improves missing-dependency errors.
python/packages/core/agent_framework/_agents.py Localizes MCP server imports and reorders Agent base classes to wrap telemetry with middleware.
python/packages/azure-ai/pyproject.toml Adds Azure Projects/Identity deps to the Azure package after removing them from core.

Comment thread python/packages/core/agent_framework/_mcp.py Outdated
Comment thread python/packages/core/agent_framework/_mcp.py Outdated
Merged via the queue into microsoft:main with commit c012aac Mar 25, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants