Skip to content

Comments

Python: [BREAKING] Renamed next middleware parameter to call_next#3735

Merged
dmytrostruk merged 4 commits intomicrosoft:mainfrom
dmytrostruk:next-middleware-rename
Feb 9, 2026
Merged

Python: [BREAKING] Renamed next middleware parameter to call_next#3735
dmytrostruk merged 4 commits intomicrosoft:mainfrom
dmytrostruk:next-middleware-rename

Conversation

@dmytrostruk
Copy link
Member

Motivation and Context

Resolves: #3583

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.

@dmytrostruk dmytrostruk self-assigned this Feb 6, 2026
Copilot AI review requested due to automatic review settings February 6, 2026 20:02
@dmytrostruk dmytrostruk added python breaking change Introduces changes that are not backward compatible and may require updates to dependent code. labels Feb 6, 2026
@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Feb 6, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 6, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _middleware.py3291695%80, 83, 88, 797, 799, 801, 922, 949, 951, 976, 1057, 1061, 1185, 1189, 1250, 1324
packages/orchestrations/agent_framework_orchestrations
   _handoff.py3806183%104–105, 107, 136–137, 159–169, 171, 173, 175, 180, 280, 334, 359, 387, 395–396, 410, 461–462, 494, 541–543, 737, 744, 749, 836, 839, 848–851, 861, 866, 873, 879–882, 917, 922, 1003–1004, 1036–1037, 1117, 1120, 1128, 1146, 1153, 1228
packages/purview/agent_framework_purview
   _middleware.py950100% 
TOTAL16592205987% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3920 225 💤 0 ❌ 0 🔥 1m 7s ⏱️

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.

Pull request overview

This PR standardizes the Python middleware “next step” parameter name from next to call_next across the Agent Framework Python codebase, samples, and documentation to avoid shadowing Python’s built-in next().

Changes:

  • Renamed middleware callback parameter nextcall_next throughout Python samples and docs.
  • Updated core middleware abstractions/docs and dependent package middleware implementations to use call_next.
  • Updated unit tests to reflect the new middleware parameter name.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/samples/getting_started/middleware/thread_behavior_middleware.py Renames middleware parameter and doc text to call_next.
python/samples/getting_started/middleware/shared_state_middleware.py Renames function middleware parameter to call_next.
python/samples/getting_started/middleware/runtime_context_delegation.py Renames function middleware parameter to call_next across examples.
python/samples/getting_started/middleware/override_result_with_middleware.py Renames chat/agent middleware parameter to call_next.
python/samples/getting_started/middleware/middleware_termination.py Renames agent middleware parameter to call_next and updates explanatory text.
python/samples/getting_started/middleware/function_based_middleware.py Renames agent/function middleware parameter to call_next and updates comments.
python/samples/getting_started/middleware/exception_handling_with_middleware.py Renames function middleware parameter to call_next.
python/samples/getting_started/middleware/decorator_middleware.py Renames decorator-based middleware parameter to call_next.
python/samples/getting_started/middleware/class_based_middleware.py Renames class-based middleware parameter to call_next and updates comments.
python/samples/getting_started/middleware/chat_middleware.py Renames chat middleware parameter to call_next.
python/samples/getting_started/middleware/agent_and_run_level_middleware.py Renames agent/run/function middleware parameters to call_next and updates comments.
python/samples/getting_started/devui/weather_agent_azure/agent.py Renames chat/function middleware parameters to call_next.
python/samples/getting_started/agents/openai/openai_responses_client_with_agent_as_tool.py Renames function middleware parameter to call_next.
python/samples/getting_started/agents/openai/openai_responses_client_basic.py Renames chat middleware parameter to call_next.
python/samples/getting_started/agents/azure_ai/azure_ai_with_agent_as_tool.py Renames function middleware parameter to call_next.
python/samples/concepts/tools/README.md Updates diagrams and narrative from next to call_next.
python/packages/purview/agent_framework_purview/_middleware.py Renames overridden middleware method parameter to call_next.
python/packages/orchestrations/agent_framework_orchestrations/_handoff.py Renames function middleware parameter to call_next.
python/packages/ollama/tests/test_ollama_chat_client.py Updates test middleware function parameter to call_next.
python/packages/core/tests/core/test_middleware_with_chat.py Updates chat middleware tests to use call_next.
python/packages/core/tests/core/test_middleware_with_agent.py Updates agent/function/chat middleware tests to use call_next.
python/packages/core/tests/core/test_middleware_context_result.py Updates context.result-related middleware tests to use call_next.
python/packages/core/tests/core/test_middleware.py Updates pipeline tests to use call_next.
python/packages/core/tests/core/test_as_tool_kwargs_propagation.py Updates agent middleware in kwargs propagation tests to use call_next.
python/packages/core/agent_framework/_middleware.py Updates middleware docs/examples and core signatures to call_next; updates related error text.
python/packages/core/AGENTS.md Updates middleware example parameter name to call_next (but example semantics need correction).
Comments suppressed due to low confidence (1)

python/packages/core/tests/core/test_middleware_with_agent.py:1758

  • This statement is unreachable.
                await call_next(context)

Copy link
Contributor

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

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

LGTM. Small nit: can we adjust the PR description to show some motivation and context as to why we're renaming (we understand internally, but external readers may not).

@moonbox3
Copy link
Contributor

moonbox3 commented Feb 6, 2026

LGTM. Small nit: can we adjust the PR description to show some motivation and context as to why we're renaming (we understand internally, but external readers may not).

Sorry, I overlooked that you linked to some context. Disregard if you want...

@dmytrostruk dmytrostruk enabled auto-merge February 9, 2026 17:07
@dmytrostruk dmytrostruk added this pull request to the merge queue Feb 9, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 9, 2026
)

* Renamed next middleware parameter to call_next

* Resolved comments
Merged via the queue into microsoft:main with commit e4ca3e6 Feb 9, 2026
26 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible and may require updates to dependent code. documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: middleware: Rename 'next' parameter to avoid shadowing built-in

4 participants