Repository navigation
Python: reject unsupported Copilot provider function middleware - #10090
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the middleware-validation and MCP session-boundary changes.
No open issues 🎉
What changed in this PR
This PR makes the Python GitHub Copilot adapter explicitly reject provider-contributed function middleware that its SDK-owned tool loop cannot execute. It also clarifies that MCP configuration changes do not guarantee revocation of capabilities in resumed service sessions.
Changes:
- Reject unsupported function middleware before SDK session creation, resumption, or tool registration.
- Add parametrized regression coverage for middleware forms, agent classes, response modes, session paths, and per-run validation.
- Document middleware limitations, MCP option precedence, authorization boundaries, and fresh-session usage.
| File | Description |
|---|---|
skills/agent-framework-builder-python/references/integrations.md |
Clarifies MCP authorization and fresh-session guidance. |
skills/agent-framework-builder-python/references/extensibility.md |
Documents the Copilot function-middleware limitation. |
python/packages/github_copilot/tests/test_github_copilot_agent.py |
Adds rejection, per-run validation, and standard Agent comparison tests. |
python/packages/github_copilot/tests/conftest.py |
Adds shared middleware, provider, and client fixtures. |
python/packages/github_copilot/README.md |
Explains middleware support and MCP session lifetime. |
python/packages/github_copilot/agent_framework_github_copilot/_agent.py |
Adds provider middleware validation and updates API documentation. |
Review effort: Balanced
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): ef857d50ac75
Model: gpt-5.6-sol
Overview
The change adds a per-invocation guard that rejects provider-contributed function middleware before either Copilot SDK session path or provider tool registration. Shared middleware categorization covers class-based, decorated, annotated, and bundled middleware, while parametrized tests exercise both agent classes, response modes, new and resumed sessions, and repeated runs. No PR-introduced Critical, High, or Medium issue remained after reconciliation.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Motivation & Context
The GitHub Copilot SDK owns its tool-calling loop. The adapter cannot apply Agent Framework function middleware supplied by a context provider, so it should reject that unsupported configuration rather than silently accept it.
The documentation also needs to distinguish SDK option forwarding from the lifetime of an existing service session. Changing MCP configuration is not an authoritative access check or a guarantee that capabilities already resident in a resumed session have been revoked.
Description & Review Guide
MiddlewareExceptionfor provider-contributed function middleware before SDK session creation or resumption and tool registration. Reuse the existing middleware categorizer for class-based, decorated, annotated, and bundled middleware. Add 56 parametrized regression cases covering both agent classes, response modes, session paths, per-run rechecking, and the same provider/tool behavior through normalAgent. Document the middleware limitation, MCP option precedence, service-session lifetime, and fresh-session usage in the package and consumer guidance.Commands run from
python/:uv run --no-sync poe syntax -P github_copilotOTEL_SDK_DISABLED=true uv run --no-sync poe test -P github_copilot -C -m "not integration"uv run --no-sync poe pyright -P github_copilotuv run --no-sync poe test-typing -P github_copilotenv -u OTEL_SDK_DISABLED OTEL_TRACES_EXPORTER=none OTEL_METRICS_EXPORTER=none OTEL_LOGS_EXPORTER=none uv run --no-sync python -m pytest -c packages/core/pyproject.toml packages/core/tests -m "not integration" -n 4 --dist worksteal --maxfail=1uv run --no-sync --group tool-markdown python -m scripts.check_md_code_blocks packages/github_copilot/README.md ../skills/agent-framework-builder-python/references/extensibility.md ../skills/agent-framework-builder-python/references/integrations.mduv build --package agent-framework-github-copilotLive Copilot CLI/MCP integration tests were not run.
Related Issue
N/A - maintainer-directed adapter correction and documentation clarification; no new public issue is required.
AI Assistance
AI assistance details: implementation, regression tests, documentation, and this PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.