Files
agent-framework/python/samples/03-workflows/declarative/function_tools
T
Eduard van Valkenburg 3a49b1d6dd Python: [BREAKING] Remove deprecated Python OpenAI/Azure AI surfaces (#4990)
* [BREAKING] Remove deprecated Python OpenAI/Azure AI surfaces

Also clean up follow-on docs, environment guidance, package metadata, and lab test stability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix deleted semantic-kernel sample links

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Address PR review feedback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* improve foundry language

* Fix A2A Foundry sample regression

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3a49b1d6dd ยท 2026-03-31 20:36:21 +00:00
History
..
2026-03-31 15:20:35 +00:00

Function Tools Workflow

This sample demonstrates an agent with function tools responding to user queries about a restaurant menu.

Overview

The workflow showcases:

  • Function Tools: Agent equipped with tools to query menu data
  • Real Foundry-backed agent: Uses FoundryChatClient to create an agent with tools
  • Agent Registration: Shows how to register agents with the WorkflowFactory

Tools

The MenuAgent has access to these function tools:

Tool Description
get_menu() Returns all menu items with category, name, and price
get_specials() Returns today's special items
get_item_price(name) Returns the price of a specific item

Menu Data

Soups:
  - Clam Chowder - $4.95 (Special)
  - Tomato Soup - $4.95

Salads:
  - Cobb Salad - $9.99
  - House Salad - $4.95

Drinks:
  - Chai Tea - $2.95 (Special)
  - Soda - $1.95

Prerequisites

  • Microsoft Foundry configured with required environment variables
  • Authentication via azure-identity (run az login before executing)

Usage

python main.py

Example Output

Loaded workflow: function-tools-workflow
============================================================
Restaurant Menu Assistant
============================================================

[Bot]: Welcome to the Restaurant Menu Assistant!

[Bot]: Today's soup special is the Clam Chowder for $4.95!

============================================================
Session Complete
============================================================

How It Works

  1. Create a Foundry chat client
  2. Create an agent with instructions and function tools
  3. Register the agent with the workflow factory
  4. Load the workflow YAML and run it with run() and stream=True
# Create the agent with tools
client = FoundryChatClient(
    project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    model=os.environ["FOUNDRY_MODEL"],
    credential=AzureCliCredential(),
)
menu_agent = client.as_agent(
    name="MenuAgent",
    instructions="You are a helpful restaurant menu assistant...",
    tools=[get_menu, get_specials, get_item_price],
)

# Register with the workflow factory
factory = WorkflowFactory(execution_mode="graph")
factory.register_agent("MenuAgent", menu_agent)

# Load and run the workflow
workflow = factory.create_workflow_from_yaml_path(workflow_path)
async for event in workflow.run(inputs={"userInput": "What is the soup of the day?"}, stream=True):
    ...