Working: Workflow as agent with function approval

This commit is contained in:
Tao Chen
2026-06-01 22:10:28 -07:00
Unverified
parent 9c0623ca5f
commit 5fade9e2a8
8 changed files with 1080 additions and 65 deletions
@@ -1,9 +1,8 @@
# Copyright (c) Microsoft. All rights reserved.
import os
from random import randint
from agent_framework import Agent, AgentExecutor, WorkflowBuilder, tool
from agent_framework import Agent, AgentExecutor, WorkflowBuilder
from agent_framework.foundry import FoundryChatClient
from agent_framework_foundry_hosting import ResponsesHostServer
from azure.identity import DefaultAzureCredential
@@ -13,13 +12,6 @@ from dotenv import load_dotenv
load_dotenv()
@tool(approval_mode="always_require")
def get_locale() -> str:
"""Get the weather for a given location."""
conditions = ["CZ", "US", "FR", "DE"]
return f"The locale is {conditions[randint(0, 3)]}."
def main():
client = FoundryChatClient(
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
@@ -30,7 +22,6 @@ def main():
writer_agent = Agent(
client=client,
instructions=("You are an excellent slogan writer. You create new slogans based on the given topic."),
tools=[get_locale],
name="writer",
)