Renamed async_credential to credential (#2648)

This commit is contained in:
Dmytro Struk
2025-12-07 17:21:18 -08:00
committed by GitHub
Unverified
parent eb06faea2d
commit cfcb71334a
64 changed files with 266 additions and 269 deletions
@@ -33,7 +33,7 @@ async def non_streaming_example() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="BasicWeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -54,7 +54,7 @@ async def streaming_example() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="BasicWeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -31,7 +31,7 @@ async def main() -> None:
async with AzureCliCredential() as credential:
async with (
AzureAIClient(
async_credential=credential,
credential=credential,
).create_agent(
name="MyWeatherAgent",
instructions="You are a helpful weather agent.",
@@ -47,7 +47,7 @@ async def main() -> None:
# Create a new agent instance
async with (
AzureAIClient(
async_credential=credential,
credential=credential,
# This parameter will allow to re-use latest agent version
# instead of creating a new one
use_latest_version=True,
@@ -21,7 +21,7 @@ Prerequisites:
async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyA2AAgent",
instructions="""You are a helpful assistant that can communicate with other agents.
Use the A2A tool when you need to interact with other agents to complete tasks
@@ -21,7 +21,7 @@ Prerequisites:
async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MySearchAgent",
instructions="""You are a helpful assistant. You must always provide citations for
answers using the tool and render them as: `[message_idx:search_idx†source]`.""",
@@ -21,7 +21,7 @@ Prerequisites:
async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyCustomSearchAgent",
instructions="""You are a helpful agent that can use Bing Custom Search tools to assist users.
Use the available Bing Custom Search tools to answer questions and perform tasks.""",
@@ -27,7 +27,7 @@ To get your Bing connection ID:
async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyBingGroundingAgent",
instructions="""You are a helpful assistant that can search the web for current information.
Use the Bing search tool to find up-to-date information and provide accurate, well-sourced answers.
@@ -21,7 +21,7 @@ Prerequisites:
async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyBrowserAutomationAgent",
instructions="""You are an Agent helping with browser automation tasks.
You can answer questions, provide information, and assist with various tasks
@@ -21,7 +21,7 @@ async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyCodeInterpreterAgent",
instructions="You are a helpful assistant that can write and execute Python code to solve problems.",
tools=HostedCodeInterpreterTool(),
@@ -36,7 +36,7 @@ async def main() -> None:
chat_client=AzureAIClient(
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
model_deployment_name=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
async_credential=credential,
credential=credential,
agent_name="WeatherAgent",
),
instructions="You are a helpful weather agent.",
@@ -32,7 +32,7 @@ async def main() -> None:
async with (
AzureCliCredential() as credential,
AgentsClient(endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"], credential=credential) as agents_client,
AzureAIClient(async_credential=credential) as client,
AzureAIClient(credential=credential) as client,
):
try:
# 1. Upload file and create vector store
@@ -64,7 +64,7 @@ async def run_hosted_mcp_without_approval() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyLearnDocsAgent",
instructions="You are a helpful assistant that can help with Microsoft documentation questions.",
tools=HostedMCPTool(
@@ -89,7 +89,7 @@ async def run_hosted_mcp_with_approval_and_thread() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyApiSpecsAgent",
instructions="You are a helpful agent that can use MCP tools to assist users.",
tools=HostedMCPTool(
@@ -27,7 +27,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="ImageGenAgent",
instructions="Generate images based on user requirements.",
tools=[ImageGenTool(quality="low", size="1024x1024")],
@@ -24,7 +24,7 @@ async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="DocsAgent",
instructions="You are a helpful assistant that can help with Microsoft documentation questions.",
tools=MCPStreamableHTTPTool(
@@ -47,7 +47,7 @@ async def main() -> None:
print(f"Created memory store: {memory_store.name} ({memory_store.id}): {memory_store.description}")
# Then, create the agent using Agent Framework
async with AzureAIClient(async_credential=credential).create_agent(
async with AzureAIClient(credential=credential).create_agent(
name="MyMemoryAgent",
instructions="""You are a helpful assistant that remembers past conversations.
Use the memory search tool to recall relevant information from previous interactions.""",
@@ -21,7 +21,7 @@ Prerequisites:
async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyFabricAgent",
instructions="You are a helpful assistant.",
tools={
@@ -29,7 +29,7 @@ async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MyOpenAPIAgent",
instructions="""You are a helpful assistant that can use country APIs to provide information.
Use the available OpenAPI tools to answer questions about countries, currencies, and demographics.""",
@@ -29,7 +29,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="ProductMarketerAgent",
instructions="Return launch briefs as structured JSON.",
) as agent,
@@ -36,7 +36,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="ProductMarketerAgent",
instructions="Return launch briefs as structured JSON.",
) as agent,
@@ -21,7 +21,7 @@ Prerequisites:
async def main() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="MySharePointAgent",
instructions="""You are a helpful agent that can use SharePoint tools to assist users.
Use the available SharePoint tools to answer questions and perform tasks.""",
@@ -30,7 +30,7 @@ async def example_with_automatic_thread_creation() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="BasicWeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -59,7 +59,7 @@ async def example_with_thread_persistence_in_memory() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="BasicWeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -100,7 +100,7 @@ async def example_with_existing_thread_id() -> None:
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="BasicWeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -122,7 +122,7 @@ async def example_with_existing_thread_id() -> None:
print("\n--- Continuing with the same thread ID in a new agent instance ---")
async with (
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="BasicWeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -24,7 +24,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIClient(async_credential=credential).create_agent(
AzureAIClient(credential=credential).create_agent(
name="WebsearchAgent",
instructions="You are a helpful assistant that can search the web",
tools=[HostedWebSearchTool()],
@@ -34,7 +34,7 @@ async def non_streaming_example() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -56,7 +56,7 @@ async def streaming_example() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -39,7 +39,7 @@ async def main() -> None:
# 2. Use AzureAIAgentClient as async context manager for automatic cleanup
async with (
AzureAIAgentClient(async_credential=AzureCliCredential()) as client,
AzureAIAgentClient(credential=AzureCliCredential()) as client,
ChatAgent(
chat_client=client,
name="BingSearchAgent",
@@ -34,7 +34,7 @@ async def main() -> None:
# 2. Use AzureAIAgentClient as async context manager for automatic cleanup
async with (
AzureAIAgentClient(async_credential=AzureCliCredential()) as client,
AzureAIAgentClient(credential=AzureCliCredential()) as client,
ChatAgent(
chat_client=client,
name="BingSearchAgent",
@@ -39,7 +39,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential) as chat_client,
AzureAIAgentClient(credential=credential) as chat_client,
):
agent = chat_client.create_agent(
name="CodingAgent",
@@ -39,7 +39,7 @@ async def main() -> None:
chat_client=AzureAIAgentClient(
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
model_deployment_name=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
async_credential=credential,
credential=credential,
agent_name="WeatherAgent",
should_cleanup_agent=True, # Set to False if you want to disable automatic agent cleanup
),
@@ -24,7 +24,7 @@ USER_INPUTS = [
async def main() -> None:
"""Main function demonstrating Azure AI agent with file search capabilities."""
client = AzureAIAgentClient(async_credential=AzureCliCredential())
client = AzureAIAgentClient(credential=AzureCliCredential())
file: FileInfo | None = None
vector_store: VectorStore | None = None
@@ -74,7 +74,7 @@ async def main() -> None:
# 6. Cleanup: Delete the vector store and file in case of earlier failure to prevent orphaned resources.
# Refreshing the client is required since chat agent closes it
client = AzureAIAgentClient(async_credential=AzureCliCredential())
client = AzureAIAgentClient(credential=AzureCliCredential())
try:
if vector_store:
await client.agents_client.vector_stores.delete(vector_store.id)
@@ -43,7 +43,7 @@ async def tools_on_agent_level() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful assistant that can provide weather and time information.",
tools=[get_weather, get_time], # Tools defined at agent creation
) as agent,
@@ -77,7 +77,7 @@ async def tools_on_run_level() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful assistant.",
# No tools defined here
) as agent,
@@ -111,7 +111,7 @@ async def mixed_tools_example() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a comprehensive assistant that can help with various information requests.",
tools=[get_weather], # Base tool available for all queries
) as agent,
@@ -42,7 +42,7 @@ async def main() -> None:
"""Example showing Hosted MCP tools for a Azure AI Agent."""
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential) as chat_client,
AzureAIAgentClient(credential=credential) as chat_client,
):
agent = chat_client.create_agent(
name="DocsAgent",
@@ -28,7 +28,7 @@ async def mcp_tools_on_run_level() -> None:
url="https://learn.microsoft.com/api/mcp",
) as mcp_server,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
name="DocsAgent",
instructions="You are a helpful assistant that can help with microsoft documentation questions.",
) as agent,
@@ -55,7 +55,7 @@ async def mcp_tools_on_agent_level() -> None:
# The agent will connect to the MCP server through its context manager.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="DocsAgent",
instructions="You are a helpful assistant that can help with microsoft documentation questions.",
tools=MCPStreamableHTTPTool( # Tools defined at agent creation
@@ -67,7 +67,7 @@ async def main() -> None:
"""Example showing Hosted MCP tools for a Azure AI Agent."""
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential) as chat_client,
AzureAIAgentClient(credential=credential) as chat_client,
):
agent = chat_client.create_agent(
name="DocsAgent",
@@ -41,7 +41,7 @@ async def main() -> None:
weather_openapi_spec, countries_openapi_spec = load_openapi_specs()
# 2. Use AzureAIAgentClient as async context manager for automatic cleanup
async with AzureAIAgentClient(async_credential=AzureCliCredential()) as client:
async with AzureAIAgentClient(credential=AzureCliCredential()) as client:
# 3. Create OpenAPI tools using Azure AI's OpenApiTool
auth = OpenApiAnonymousAuthDetails()
@@ -34,7 +34,7 @@ async def example_with_automatic_thread_creation() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,
@@ -63,7 +63,7 @@ async def example_with_thread_persistence() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,
@@ -104,7 +104,7 @@ async def example_with_existing_thread_id() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,
@@ -127,7 +127,7 @@ async def example_with_existing_thread_id() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(thread_id=existing_thread_id, async_credential=credential),
chat_client=AzureAIAgentClient(thread_id=existing_thread_id, credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,
@@ -27,7 +27,7 @@ def get_weather(
async def main() -> None:
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option.
async with AzureAIAgentClient(async_credential=AzureCliCredential()) as client:
async with AzureAIAgentClient(credential=AzureCliCredential()) as client:
message = "What's the weather in Amsterdam and in Paris?"
stream = False
print(f"User: {message}")
@@ -140,7 +140,7 @@ search_provider = AzureAISearchContextProvider(
)
# Create agent with search context
async with AzureAIAgentClient(async_credential=DefaultAzureCredential()) as client:
async with AzureAIAgentClient(credential=DefaultAzureCredential()) as client:
async with ChatAgent(
chat_client=client,
model=model_deployment,
@@ -110,7 +110,7 @@ async def main() -> None:
AzureAIAgentClient(
project_endpoint=project_endpoint,
model_deployment_name=model_deployment,
async_credential=AzureCliCredential(),
credential=AzureCliCredential(),
) as client,
ChatAgent(
chat_client=client,
@@ -67,7 +67,7 @@ async def main() -> None:
AzureAIAgentClient(
project_endpoint=project_endpoint,
model_deployment_name=model_deployment,
async_credential=AzureCliCredential(),
credential=AzureCliCredential(),
) as client,
ChatAgent(
chat_client=client,
@@ -32,7 +32,7 @@ async def main() -> None:
# For Mem0 authentication, set Mem0 API key via "api_key" parameter or MEM0_API_KEY environment variable.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="FriendlyAssistant",
instructions="You are a friendly assistant.",
tools=retrieve_company_report,
@@ -35,7 +35,7 @@ async def main() -> None:
local_mem0_client = AsyncMemory()
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="FriendlyAssistant",
instructions="You are a friendly assistant.",
tools=retrieve_company_report,
@@ -27,7 +27,7 @@ async def example_global_thread_scope() -> None:
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="GlobalMemoryAssistant",
instructions="You are an assistant that remembers user preferences across conversations.",
tools=get_user_preferences,
@@ -65,7 +65,7 @@ async def example_per_operation_thread_scope() -> None:
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="ScopedMemoryAssistant",
instructions="You are an assistant with thread-scoped memory.",
tools=get_user_preferences,
@@ -113,14 +113,14 @@ async def example_multiple_agents() -> None:
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="PersonalAssistant",
instructions="You are a personal assistant that helps with personal tasks.",
context_providers=Mem0Provider(
agent_id=agent_id_1,
),
) as personal_agent,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WorkAssistant",
instructions="You are a work assistant that helps with professional tasks.",
context_providers=Mem0Provider(
@@ -91,7 +91,7 @@ class UserInfoMemory(ContextProvider):
async def main():
async with AzureCliCredential() as credential:
chat_client = AzureAIClient(async_credential=credential)
chat_client = AzureAIClient(credential=credential)
# Create the memory provider
memory_provider = UserInfoMemory(chat_client)
@@ -34,7 +34,7 @@ model:
# create the agent from the yaml
async with (
AzureCliCredential() as credential,
AgentFactory(client_kwargs={"async_credential": credential}).create_agent_from_yaml(yaml_definition) as agent,
AgentFactory(client_kwargs={"credential": credential}).create_agent_from_yaml(yaml_definition) as agent,
):
response = await agent.run("What can you do for me?")
print("Agent response:", response.text)
@@ -15,7 +15,7 @@ async def main():
# create the agent from the yaml
async with (
AzureCliCredential() as credential,
AgentFactory(client_kwargs={"async_credential": credential}).create_agent_from_yaml_path(yaml_path) as agent,
AgentFactory(client_kwargs={"credential": credential}).create_agent_from_yaml_path(yaml_path) as agent,
):
response = await agent.run("How do I create a storage account with private endpoint using bicep?")
print("Agent response:", response.text)
@@ -45,7 +45,7 @@ agent = ChatAgent(
chat_client=AzureAIAgentClient(
project_endpoint=os.environ.get("AZURE_AI_PROJECT_ENDPOINT"),
model_deployment_name=os.environ.get("FOUNDRY_MODEL_DEPLOYMENT_NAME"),
async_credential=AzureCliCredential(),
credential=AzureCliCredential(),
),
instructions="""
You are a weather assistant using Azure AI Foundry models. You can provide
@@ -166,7 +166,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather assistant.",
tools=get_weather,
@@ -142,7 +142,7 @@ async def class_based_chat_middleware() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="EnhancedChatAgent",
instructions="You are a helpful AI assistant.",
# Register class-based middleware at agent level (applies to all runs)
@@ -164,7 +164,7 @@ async def function_based_chat_middleware() -> None:
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="FunctionMiddlewareAgent",
instructions="You are a helpful AI assistant.",
# Register function-based middleware at agent level
@@ -194,7 +194,7 @@ async def run_level_middleware() -> None:
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="RunLevelAgent",
instructions="You are a helpful AI assistant.",
tools=get_weather,
@@ -99,7 +99,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather assistant.",
tools=get_weather,
@@ -70,7 +70,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="TimeAgent",
instructions="You are a helpful time assistant. Call get_current_time when asked about time.",
tools=get_current_time,
@@ -58,7 +58,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="DataAgent",
instructions="You are a helpful data assistant. Use the data service tool to fetch information for users.",
tools=unstable_data_service,
@@ -83,7 +83,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather assistant.",
tools=get_weather,
@@ -110,7 +110,7 @@ async def pre_termination_middleware() -> None:
print("\n--- Example 1: Pre-termination Middleware ---")
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather assistant.",
tools=get_weather,
@@ -137,7 +137,7 @@ async def post_termination_middleware() -> None:
print("\n--- Example 2: Post-termination Middleware ---")
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather assistant.",
tools=get_weather,
@@ -83,7 +83,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather assistant. Use the weather tool to get current conditions.",
tools=get_weather,
@@ -93,7 +93,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="UtilityAgent",
instructions="You are a helpful assistant that can provide weather information and current time.",
tools=[get_weather, get_time],
@@ -22,7 +22,7 @@ async def suspend_resume_service_managed_thread() -> None:
# AzureAIAgentClient supports service-managed threads.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="MemoryBot", instructions="You are a helpful assistant that remembers our conversation."
) as agent,
):
@@ -92,7 +92,7 @@ def create_coding_agent(client: AzureAIAgentClient) -> ChatAgent:
async def main():
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential) as chat_client,
AzureAIAgentClient(credential=credential) as chat_client,
):
# Build a workflow: Agent generates code -> Evaluator assesses results
# The agent will be wrapped in a special agent executor which produces AgentExecutorResponse