Skip to content

Python: docs: fix outdated @ai_function reference to @tool in workflows README - #5622

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
aishsawant0202-tech:fix/update-docs-aifunction-to-functiontool
May 4, 2026
Merged

Python: docs: fix outdated @ai_function reference to @tool in workflows README#5622
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
aishsawant0202-tech:fix/update-docs-aifunction-to-functiontool

Conversation

@aishsawant0202-tech

Copy link
Copy Markdown
Contributor

The @ai_function decorator was renamed to tool in release python-1.0.0b260128 (PR #3413) as a breaking change.

Line 58 of python/samples/03-workflows/README.md still referenced the old @ai_function name, causing users to hit:
ImportError: cannot import name 'AIFunction'

Changes made:

  • Fixed @ai_function to tool on line 58 only
  • No formatting or whitespace changes

Motivation and Context

The @ai_function decorator was renamed to tool in release python-1.0.0b260128 (Jan 28, 2026) as a breaking change (PR #3413).
However, line 58 of python/samples/03-workflows/README.md still referenced the old @ai_function name, causing users to follow outdated documentation and hit ImportError: cannot import name 'AIFunction'.
Additionally, the official Microsoft Learn docs at:
https://learn.microsoft.com/en-us/python/api/agent-framework-core/agent_framework.aifunction still show the old API — this is the primary source of user confusion.
Fixes #5564

Description

Changed @ai_function tools to tool functions on line 58 of python/samples/03-workflows/README.md in the agents table (Workflow as Agent kwargs row).

Contribution Checklist

✅ The code builds clean without any errors or warnings — docs-only change, no build impact
✅ The PR follows the Contribution Guidelines
✅ All unit tests pass, and I have added new tests where possible — no tests needed for docs fix
❌ Is this a breaking change? — No, this is a docs fix only

The @ai_function decorator was renamed to @tool in release 
python-1.0.0b260128 (PR microsoft#3413) as a breaking change.

Line 58 of python/samples/03-workflows/README.md still referenced 
the old @ai_function name, causing users to hit:
ImportError: cannot import name 'AIFunction'

Changes made:
- Fixed @ai_function to @tool on line 58 only
- No formatting or whitespace changes
Copilot AI review requested due to automatic review settings May 4, 2026 10:34
@moonbox3 Evan Mattson (moonbox3) added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels May 4, 2026
@github-actions github-actions Bot changed the title docs: fix outdated @ai_function reference to @tool in workflows README Python: docs: fix outdated @ai_function reference to @tool in workflows README May 4, 2026

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

Updates the Python workflows sample README to reflect the breaking rename of the @ai_function decorator to @tool, preventing users from following outdated guidance and hitting ImportError: cannot import name 'AIFunction'.

Changes:

  • Replaced the outdated @ai_function reference with @tool in the “Workflow as Agent kwargs” sample entry.

Merged via the queue into microsoft:main with commit e558d36 May 4, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: ImportError: cannot import name 'AIFunction' from 'agent_framework'

4 participants