Skip to content

Comments

Python: Add documentation for declaration-only tools and middleware ordering#3774

Merged
giles17 merged 3 commits intomicrosoft:mainfrom
giles17:docstring_fixes
Feb 10, 2026
Merged

Python: Add documentation for declaration-only tools and middleware ordering#3774
giles17 merged 3 commits intomicrosoft:mainfrom
giles17:docstring_fixes

Conversation

@giles17
Copy link
Contributor

@giles17 giles17 commented Feb 9, 2026

Motivation and Context

Adds documentation for declaration-only tools and middleware execution ordering.

Changes

  • _tools.py: Document func parameter in @tool decorator and FunctionTool class explaining declaration-only tool usage (func=None)
  • agent_and_run_level_middleware.py: Add detailed middleware execution ordering documentation

Linked Issues

Closes #3580
Closes #3582

Description

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 February 9, 2026 21:57
@github-actions github-actions bot changed the title Add documentation for declaration-only tools and middleware ordering Python: Add documentation for declaration-only tools and middleware ordering Feb 9, 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.

Pull request overview

Adds clarifying documentation in the Python Agent Framework for (1) declaration-only tools and (2) middleware execution ordering when mixing agent-level and run-level middleware.

Changes:

  • Document func=None behavior for declaration-only tools in FunctionTool and @tool decorator docs, including an example.
  • Add a detailed middleware execution ordering explanation to the agent/run-level middleware sample.

Reviewed changes

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

File Description
python/samples/getting_started/middleware/agent_and_run_level_middleware.py Expands sample documentation to explain agent-level vs run-level middleware ordering with an execution diagram.
python/packages/core/agent_framework/_tools.py Documents func=None for declaration-only tools in FunctionTool and tool() docstrings and adds an example.

@giles17 giles17 enabled auto-merge February 9, 2026 22:52
@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _tools.py7898589%232, 278, 329, 331, 359, 529, 564–565, 676, 678, 698, 716, 730, 742, 747, 749, 756, 789, 860–862, 903, 925–953, 988, 996, 1237, 1489, 1546, 1550, 1629–1633, 1651, 1653–1654, 1759, 1763, 1813, 1815, 1831, 1833, 1897, 1924, 1977, 2045, 2224–2225, 2252, 2260, 2273, 2283–2284, 2319, 2375, 2407
TOTAL16592205987% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3925 225 💤 0 ❌ 0 🔥 1m 8s ⏱️

@giles17 giles17 added this pull request to the merge queue Feb 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 10, 2026
@giles17 giles17 added this pull request to the merge queue Feb 10, 2026
Merged via the queue into microsoft:main with commit 32ba81e Feb 10, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: middleware: Document ordering for agent-level and run-level middleware Python: tools: Add documentation for declaration-only tools

3 participants