Skip to content

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

Closed
Aishwarya Sawant (aishsawant0202-tech) wants to merge 4 commits into
microsoft:mainfrom
aishsawant0202-tech:fix/update-docs-aifunction-to-functiontool
Closed

Python: docs: fix outdated @ai_function reference to @tool in workflows README#5597
Aishwarya Sawant (aishsawant0202-tech) wants to merge 4 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 v1.0.0b260128 (PR #3413). Updated the workflows README to use the correct tool decorator name.

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 v1.0.0b260128 (PR microsoft#3413).
Updated the workflows README to use the correct @tool decorator name.
Copilot AI review requested due to automatic review settings April 30, 2026 21:02
@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 Apr 30, 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 Apr 30, 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 workflows sample README to match the current Python tool API naming (@tool), preventing users from following outdated documentation after the breaking rename introduced in PR #3413.

Changes:

  • Replaced the outdated @ai_function reference with @tool in the “Workflow as Agent kwargs” row.
  • Reformatted multiple sample tables for consistent Markdown table layout/alignment.

Comment on lines +37 to +45
| Sample | File | Concepts |
| ------------------------ | ---------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| Basic Pipeline | [functional/basic_pipeline.py](./functional/basic_pipeline.py) | Sequential steps as plain async functions |
| Basic Streaming Pipeline | [functional/basic_streaming_pipeline.py](./functional/basic_streaming_pipeline.py) | Stream workflow events in real time with `run(stream=True)` |
| Parallel Pipeline | [functional/parallel_pipeline.py](./functional/parallel_pipeline.py) | Fan-out/fan-in with `asyncio.gather` |
| Steps and Checkpointing | [functional/steps_and_checkpointing.py](./functional/steps_and_checkpointing.py) | `@step` decorator for per-step checkpointing and observability |
| Human-in-the-Loop Review | [functional/hitl_review.py](./functional/hitl_review.py) | HITL with `ctx.request_info()` and replay |
| Agent Integration | [functional/agent_integration.py](./functional/agent_integration.py) | Calling agents inside workflow steps |
| Naive Group Chat | [functional/naive_group_chat.py](./functional/naive_group_chat.py) | Simple round-robin group chat as a plain loop |

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description says this is a single-line docs fix (line 58), but this commit also reformats multiple tables across the README. Consider either (a) limiting the change to the @tool rename to keep the PR focused, or (b) explicitly calling out the table reformatting in the PR description (or splitting it into a separate PR) to reduce review noise.

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +135
| Sample | File | Concepts |
| -------------------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
| State with Agents | [state-management/state_with_agents.py](./state-management/state_with_agents.py) | Store in state once and later reuse across agents |
| Workflow Kwargs - Global Context | [state-management/workflow_kwargs_global.py](./state-management/workflow_kwargs_global.py) | Pass custom context (data, user tokens) via kwargs to `@tool` tools in all agents |
| Workflow Kwargs - Per Agent | [state-management/workflow_kwargs_per_agent.py](./state-management/workflow_kwargs_per_agent.py) | Pass custom context (data, user tokens) via kwargs to `@tool` tools in individual agents |

Copilot AI Apr 30, 2026

Copy link

Choose a reason for hiding this comment

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

In the state-management table, the phrasing "@tool tools" is a bit redundant/ambiguous, especially now that the agents table uses "@tool functions". Consider rewording these rows to consistently refer to "@tool-decorated functions" (or similar) to avoid confusing readers about whether @tool applies to a function vs a tool object.

Suggested change
| Sample | File | Concepts |
| -------------------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
| State with Agents | [state-management/state_with_agents.py](./state-management/state_with_agents.py) | Store in state once and later reuse across agents |
| Workflow Kwargs - Global Context | [state-management/workflow_kwargs_global.py](./state-management/workflow_kwargs_global.py) | Pass custom context (data, user tokens) via kwargs to `@tool` tools in all agents |
| Workflow Kwargs - Per Agent | [state-management/workflow_kwargs_per_agent.py](./state-management/workflow_kwargs_per_agent.py) | Pass custom context (data, user tokens) via kwargs to `@tool` tools in individual agents |
| Sample | File | Concepts |
| -------------------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| State with Agents | [state-management/state_with_agents.py](./state-management/state_with_agents.py) | Store in state once and later reuse across agents |
| Workflow Kwargs - Global Context | [state-management/workflow_kwargs_global.py](./state-management/workflow_kwargs_global.py) | Pass custom context (data, user tokens) via kwargs to `@tool`-decorated functions in all agents |
| Workflow Kwargs - Per Agent | [state-management/workflow_kwargs_per_agent.py](./state-management/workflow_kwargs_per_agent.py) | Pass custom context (data, user tokens) via kwargs to `@tool`-decorated functions in individual agents |

Copilot uses AI. Check for mistakes.
@aishsawant0202-tech

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@moonbox3 Evan Mattson (moonbox3) 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.

What is the actual change here? I see lots of table formatting changes (extra spaces?).

@aishsawant0202-tech

Copy link
Copy Markdown
Contributor Author

Hi Evan Mattson (@moonbox3) , the core fix is on line 58 — changing @ai_function to @tool in python/samples/03-workflows/README.md in the agents table (Workflow as Agent kwargs row). The extra spacing changes were unintentional formatting noise from my editor. I can revert those and submit a clean, single-line fix if preferred.

@moonbox3

Copy link
Copy Markdown
Contributor

Hi Evan Mattson (@moonbox3) , the core fix is on line 58 — changing @ai_function to @tool in python/samples/03-workflows/README.md in the agents table (Workflow as Agent kwargs row). The extra spacing changes were unintentional formatting noise from my editor. I can revert those and submit a clean, single-line fix if preferred.

Yes, please, let's keep it scoped to the rename only with no unnecessary formatting/white space additions.

@aishsawant0202-tech
Aishwarya Sawant (aishsawant0202-tech) deleted the fix/update-docs-aifunction-to-functiontool branch May 4, 2026 10:02
@aishsawant0202-tech

Copy link
Copy Markdown
Contributor Author

Hi Evan Mattson (@moonbox3), apologies for the noise. I've created a new focused PR with only the single-line fix — no formatting or whitespace changes.

👉 Link to new PR

Thanks for the feedback!

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'

3 participants