[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DHA3BTPCAJ9F17ABYGFFYK":3,"skill-same:01M7DHA3BTPCAJ9F17ABYGFFYK":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":13,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M7DHA3BTPCAJ9F17ABYGFFYK","agent-framework-azure-ai-py",null,"Build Azure AI Foundry agents using the Microsoft Agent Framework Python SDK (agent-framework-azure-ai). Use when creating persistent agents with AzureAIAgentsProvider, using hosted tools (code interpreter, file search, web search), integrating MCP servers, managing conversation threads, or implementing streaming responses. Covers function tools, structured outputs, and multi-tool agents.","ak2dev\u002Fagentguard","ak2dev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F233005497?v=4","01M7DGWK3E3XCC276C6YRFSN05","01M7DGWK4J2A9WQ44CS5CRP4R6",0,"MIT","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Fbench\u002Fcorpus\u002Fbenign\u002Freal-ms-agent-framework-azure-ai-py\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: agent-framework-azure-ai-py\ndescription: Build Azure AI Foundry agents using the Microsoft Agent Framework Python SDK (agent-framework-azure-ai). Use when creating persistent agents with AzureAIAgentsProvider, using hosted tools (code interpreter, file search, web search), integrating MCP servers, managing conversation threads, or implementing streaming responses. Covers function tools, structured outputs, and multi-tool agents.\nlicense: MIT\nmetadata:\n  author: Microsoft\n  version: \"1.0.0\"\n  package: agent-framework-azure-ai\n---\n\n# Agent Framework Azure Hosted Agents\n\nBuild persistent agents on Azure AI Foundry using the Microsoft Agent Framework Python SDK.\n\n## Architecture\n\n```\nUser Query → AzureAIAgentsProvider → Azure AI Agent Service (Persistent)\n                    ↓\n              Agent.run() \u002F Agent.run_stream()\n                    ↓\n              Tools: Functions | Hosted (Code\u002FSearch\u002FWeb) | MCP\n                    ↓\n              AgentThread (conversation persistence)\n```\n\n## Installation\n\n```bash\n# Full framework (recommended)\npip install agent-framework --pre\n\n# Or Azure-specific package only\npip install agent-framework-azure-ai --pre\n```\n\n## Environment Variables\n\n```bash\nexport AZURE_AI_PROJECT_ENDPOINT=\"https:\u002F\u002F\u003Cproject>.services.ai.azure.com\u002Fapi\u002Fprojects\u002F\u003Cproject-id>\"  # Required for all auth methods\nexport AZURE_AI_MODEL_DEPLOYMENT_NAME=\"gpt-4o-mini\"  # Required for all auth methods\nexport BING_CONNECTION_ID=\"your-bing-connection-id\"  # For web search\nexport AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production\n```\n\n## Authentication & Lifecycle\n\n> **🔑 Two rules apply to every code sample below:**\n>\n> 1. **Prefer `DefaultAzureCredential`.** It works locally (Azure CLI \u002F VS Code \u002F Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account\u002FAPI keys — they bypass Entra audit and rotation.\n>    - Local dev: `DefaultAzureCredential` works as-is.\n>    - Production: set `AZURE_TOKEN_CREDENTIALS=prod` (or `AZURE_TOKEN_CREDENTIALS=\u003Cspecific_credential>`) to constrain the credential chain to production-safe credentials.\n> 2. **Wrap every client in a context manager** so HTTP transports, sockets, and token caches are released deterministically:\n>    - Sync: `with \u003CClient>(...) as client:`\n>    - Async: `async with \u003CClient>(...) as client:` **and** `async with DefaultAzureCredential() as credential:` (from `azure.identity.aio`)\n>\n> Snippets may abbreviate this setup, but production code should always follow both rules.\n\n```python\nfrom azure.identity.aio import AzureCliCredential, DefaultAzureCredential, ManagedIdentityCredential\n\n# Development\ncredential = AzureCliCredential()\n\n# Production\n# Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=\u003Cspecific_credential>\ncredential = DefaultAzureCredential(require_envvar=True)\n# Or use a specific credential directly in production:\n# See https:\u002F\u002Flearn.microsoft.com\u002Fpython\u002Fapi\u002Foverview\u002Fazure\u002Fidentity-readme?view=azure-python#credential-classes\n# credential = ManagedIdentityCredential()\n```\n\n## Core Workflow\n\n### Basic Agent\n\n```python\nimport asyncio\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"MyAgent\",\n            instructions=\"You are a helpful assistant.\",\n        )\n        \n        result = await agent.run(\"Hello!\")\n        print(result.text)\n\nasyncio.run(main())\n```\n\n### Agent with Function Tools\n\n```python\nfrom typing import Annotated\nfrom pydantic import Field\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\ndef get_weather(\n    location: Annotated[str, Field(description=\"City name to get weather for\")],\n) -> str:\n    \"\"\"Get the current weather for a location.\"\"\"\n    return f\"Weather in {location}: 72°F, sunny\"\n\ndef get_current_time() -> str:\n    \"\"\"Get the current UTC time.\"\"\"\n    from datetime import datetime, timezone\n    return datetime.now(timezone.utc).strftime(\"%Y-%m-%d %H:%M:%S UTC\")\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"WeatherAgent\",\n            instructions=\"You help with weather and time queries.\",\n            tools=[get_weather, get_current_time],  # Pass functions directly\n        )\n        \n        result = await agent.run(\"What's the weather in Seattle?\")\n        print(result.text)\n```\n\n### Agent with Hosted Tools\n\n```python\nfrom agent_framework import (\n    HostedCodeInterpreterTool,\n    HostedFileSearchTool,\n    HostedWebSearchTool,\n)\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"MultiToolAgent\",\n            instructions=\"You can execute code, search files, and search the web.\",\n            tools=[\n                HostedCodeInterpreterTool(),\n                HostedWebSearchTool(name=\"Bing\"),\n            ],\n        )\n        \n        result = await agent.run(\"Calculate the factorial of 20 in Python\")\n        print(result.text)\n```\n\n### Streaming Responses\n\n```python\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"StreamingAgent\",\n            instructions=\"You are a helpful assistant.\",\n        )\n        \n        print(\"Agent: \", end=\"\", flush=True)\n        async for chunk in agent.run_stream(\"Tell me a short story\"):\n            if chunk.text:\n                print(chunk.text, end=\"\", flush=True)\n        print()\n```\n\n### Conversation Threads\n\n```python\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"ChatAgent\",\n            instructions=\"You are a helpful assistant.\",\n            tools=[get_weather],\n        )\n        \n        # Create thread for conversation persistence\n        thread = agent.get_new_thread()\n        \n        # First turn\n        result1 = await agent.run(\"What's the weather in Seattle?\", thread=thread)\n        print(f\"Agent: {result1.text}\")\n        \n        # Second turn - context is maintained\n        result2 = await agent.run(\"What about Portland?\", thread=thread)\n        print(f\"Agent: {result2.text}\")\n        \n        # Save thread ID for later resumption\n        print(f\"Conversation ID: {thread.conversation_id}\")\n```\n\n### Structured Outputs\n\n```python\nfrom pydantic import BaseModel, ConfigDict\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nclass WeatherResponse(BaseModel):\n    model_config = ConfigDict(extra=\"forbid\")\n    \n    location: str\n    temperature: float\n    unit: str\n    conditions: str\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"StructuredAgent\",\n            instructions=\"Provide weather information in structured format.\",\n            response_format=WeatherResponse,\n        )\n        \n        result = await agent.run(\"Weather in Seattle?\")\n        weather = WeatherResponse.model_validate_json(result.text)\n        print(f\"{weather.location}: {weather.temperature}°{weather.unit}\")\n```\n\n## Provider Methods\n\n| Method | Description |\n|--------|-------------|\n| `create_agent()` | Create new agent on Azure AI service |\n| `get_agent(agent_id)` | Retrieve existing agent by ID |\n| `as_agent(sdk_agent)` | Wrap SDK Agent object (no HTTP call) |\n\n## Hosted Tools Quick Reference\n\n| Tool | Import | Purpose |\n|------|--------|---------|\n| `HostedCodeInterpreterTool` | `from agent_framework import HostedCodeInterpreterTool` | Execute Python code |\n| `HostedFileSearchTool` | `from agent_framework import HostedFileSearchTool` | Search vector stores |\n| `HostedWebSearchTool` | `from agent_framework import HostedWebSearchTool` | Bing web search |\n| `HostedMCPTool` | `from agent_framework import HostedMCPTool` | Service-managed MCP |\n| `MCPStreamableHTTPTool` | `from agent_framework import MCPStreamableHTTPTool` | Client-managed MCP |\n\n## Complete Example\n\n```python\nimport asyncio\nfrom typing import Annotated\nfrom pydantic import BaseModel, Field\nfrom agent_framework import (\n    HostedCodeInterpreterTool,\n    HostedWebSearchTool,\n    MCPStreamableHTTPTool,\n)\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\n\ndef get_weather(\n    location: Annotated[str, Field(description=\"City name\")],\n) -> str:\n    \"\"\"Get weather for a location.\"\"\"\n    return f\"Weather in {location}: 72°F, sunny\"\n\n\nclass AnalysisResult(BaseModel):\n    summary: str\n    key_findings: list[str]\n    confidence: float\n\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        MCPStreamableHTTPTool(\n            name=\"Docs MCP\",\n            url=\"https:\u002F\u002Flearn.microsoft.com\u002Fapi\u002Fmcp\",\n        ) as mcp_tool,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"ResearchAssistant\",\n            instructions=\"You are a research assistant with multiple capabilities.\",\n            tools=[\n                get_weather,\n                HostedCodeInterpreterTool(),\n                HostedWebSearchTool(name=\"Bing\"),\n                mcp_tool,\n            ],\n        )\n        \n        thread = agent.get_new_thread()\n        \n        # Non-streaming\n        result = await agent.run(\n            \"Search for Python best practices and summarize\",\n            thread=thread,\n        )\n        print(f\"Response: {result.text}\")\n        \n        # Streaming\n        print(\"\\nStreaming: \", end=\"\")\n        async for chunk in agent.run_stream(\"Continue with examples\", thread=thread):\n            if chunk.text:\n                print(chunk.text, end=\"\", flush=True)\n        print()\n        \n        # Structured output\n        result = await agent.run(\n            \"Analyze findings\",\n            thread=thread,\n            response_format=AnalysisResult,\n        )\n        analysis = AnalysisResult.model_validate_json(result.text)\n        print(f\"\\nConfidence: {analysis.confidence}\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Conventions\n\n- Always use async context managers: `async with provider:`\n- Pass functions directly to `tools=` parameter (auto-converted to AIFunction)\n- Use `Annotated[type, Field(description=...)]` for function parameters\n- Use `get_new_thread()` for multi-turn conversations\n- Prefer `HostedMCPTool` for service-managed MCP, `MCPStreamableHTTPTool` for client-managed\n\n## Best Practices\n\n1. **This SDK is async-first — use `async def` handlers and `async with` throughout.**\n2. **Always use context managers for clients and async credentials.** Wrap every client in `with Client(...) as client:` (sync) or `async with Client(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.\n\n## Reference Files\n\n- [references\u002Ftools.md](references\u002Ftools.md): Detailed hosted tool patterns\n- [references\u002Fmcp.md](references\u002Fmcp.md): MCP integration (hosted + local)\n- [references\u002Fthreads.md](references\u002Fthreads.md): Thread and conversation management\n- [references\u002Fadvanced.md](references\u002Fadvanced.md): OpenAPI, citations, structured outputs\n","# Agent Framework Azure Hosted Agents\n\nBuild persistent agents on Azure AI Foundry using the Microsoft Agent Framework Python SDK.\n\n## Architecture\n\n```\nUser Query → AzureAIAgentsProvider → Azure AI Agent Service (Persistent)\n                    ↓\n              Agent.run() \u002F Agent.run_stream()\n                    ↓\n              Tools: Functions | Hosted (Code\u002FSearch\u002FWeb) | MCP\n                    ↓\n              AgentThread (conversation persistence)\n```\n\n## Installation\n\n```bash\n# Full framework (recommended)\npip install agent-framework --pre\n\n# Or Azure-specific package only\npip install agent-framework-azure-ai --pre\n```\n\n## Environment Variables\n\n```bash\nexport AZURE_AI_PROJECT_ENDPOINT=\"https:\u002F\u002F\u003Cproject>.services.ai.azure.com\u002Fapi\u002Fprojects\u002F\u003Cproject-id>\"  # Required for all auth methods\nexport AZURE_AI_MODEL_DEPLOYMENT_NAME=\"gpt-4o-mini\"  # Required for all auth methods\nexport BING_CONNECTION_ID=\"your-bing-connection-id\"  # For web search\nexport AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production\n```\n\n## Authentication & Lifecycle\n\n> **🔑 Two rules apply to every code sample below:**\n>\n> 1. **Prefer `DefaultAzureCredential`.** It works locally (Azure CLI \u002F VS Code \u002F Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account\u002FAPI keys — they bypass Entra audit and rotation.\n>    - Local dev: `DefaultAzureCredential` works as-is.\n>    - Production: set `AZURE_TOKEN_CREDENTIALS=prod` (or `AZURE_TOKEN_CREDENTIALS=\u003Cspecific_credential>`) to constrain the credential chain to production-safe credentials.\n> 2. **Wrap every client in a context manager** so HTTP transports, sockets, and token caches are released deterministically:\n>    - Sync: `with \u003CClient>(...) as client:`\n>    - Async: `async with \u003CClient>(...) as client:` **and** `async with DefaultAzureCredential() as credential:` (from `azure.identity.aio`)\n>\n> Snippets may abbreviate this setup, but production code should always follow both rules.\n\n```python\nfrom azure.identity.aio import AzureCliCredential, DefaultAzureCredential, ManagedIdentityCredential\n\n# Development\ncredential = AzureCliCredential()\n\n# Production\n# Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=\u003Cspecific_credential>\ncredential = DefaultAzureCredential(require_envvar=True)\n# Or use a specific credential directly in production:\n# See https:\u002F\u002Flearn.microsoft.com\u002Fpython\u002Fapi\u002Foverview\u002Fazure\u002Fidentity-readme?view=azure-python#credential-classes\n# credential = ManagedIdentityCredential()\n```\n\n## Core Workflow\n\n### Basic Agent\n\n```python\nimport asyncio\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"MyAgent\",\n            instructions=\"You are a helpful assistant.\",\n        )\n        \n        result = await agent.run(\"Hello!\")\n        print(result.text)\n\nasyncio.run(main())\n```\n\n### Agent with Function Tools\n\n```python\nfrom typing import Annotated\nfrom pydantic import Field\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\ndef get_weather(\n    location: Annotated[str, Field(description=\"City name to get weather for\")],\n) -> str:\n    \"\"\"Get the current weather for a location.\"\"\"\n    return f\"Weather in {location}: 72°F, sunny\"\n\ndef get_current_time() -> str:\n    \"\"\"Get the current UTC time.\"\"\"\n    from datetime import datetime, timezone\n    return datetime.now(timezone.utc).strftime(\"%Y-%m-%d %H:%M:%S UTC\")\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"WeatherAgent\",\n            instructions=\"You help with weather and time queries.\",\n            tools=[get_weather, get_current_time],  # Pass functions directly\n        )\n        \n        result = await agent.run(\"What's the weather in Seattle?\")\n        print(result.text)\n```\n\n### Agent with Hosted Tools\n\n```python\nfrom agent_framework import (\n    HostedCodeInterpreterTool,\n    HostedFileSearchTool,\n    HostedWebSearchTool,\n)\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"MultiToolAgent\",\n            instructions=\"You can execute code, search files, and search the web.\",\n            tools=[\n                HostedCodeInterpreterTool(),\n                HostedWebSearchTool(name=\"Bing\"),\n            ],\n        )\n        \n        result = await agent.run(\"Calculate the factorial of 20 in Python\")\n        print(result.text)\n```\n\n### Streaming Responses\n\n```python\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"StreamingAgent\",\n            instructions=\"You are a helpful assistant.\",\n        )\n        \n        print(\"Agent: \", end=\"\", flush=True)\n        async for chunk in agent.run_stream(\"Tell me a short story\"):\n            if chunk.text:\n                print(chunk.text, end=\"\", flush=True)\n        print()\n```\n\n### Conversation Threads\n\n```python\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"ChatAgent\",\n            instructions=\"You are a helpful assistant.\",\n            tools=[get_weather],\n        )\n        \n        # Create thread for conversation persistence\n        thread = agent.get_new_thread()\n        \n        # First turn\n        result1 = await agent.run(\"What's the weather in Seattle?\", thread=thread)\n        print(f\"Agent: {result1.text}\")\n        \n        # Second turn - context is maintained\n        result2 = await agent.run(\"What about Portland?\", thread=thread)\n        print(f\"Agent: {result2.text}\")\n        \n        # Save thread ID for later resumption\n        print(f\"Conversation ID: {thread.conversation_id}\")\n```\n\n### Structured Outputs\n\n```python\nfrom pydantic import BaseModel, ConfigDict\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\nclass WeatherResponse(BaseModel):\n    model_config = ConfigDict(extra=\"forbid\")\n    \n    location: str\n    temperature: float\n    unit: str\n    conditions: str\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"StructuredAgent\",\n            instructions=\"Provide weather information in structured format.\",\n            response_format=WeatherResponse,\n        )\n        \n        result = await agent.run(\"Weather in Seattle?\")\n        weather = WeatherResponse.model_validate_json(result.text)\n        print(f\"{weather.location}: {weather.temperature}°{weather.unit}\")\n```\n\n## Provider Methods\n\n| Method | Description |\n|--------|-------------|\n| `create_agent()` | Create new agent on Azure AI service |\n| `get_agent(agent_id)` | Retrieve existing agent by ID |\n| `as_agent(sdk_agent)` | Wrap SDK Agent object (no HTTP call) |\n\n## Hosted Tools Quick Reference\n\n| Tool | Import | Purpose |\n|------|--------|---------|\n| `HostedCodeInterpreterTool` | `from agent_framework import HostedCodeInterpreterTool` | Execute Python code |\n| `HostedFileSearchTool` | `from agent_framework import HostedFileSearchTool` | Search vector stores |\n| `HostedWebSearchTool` | `from agent_framework import HostedWebSearchTool` | Bing web search |\n| `HostedMCPTool` | `from agent_framework import HostedMCPTool` | Service-managed MCP |\n| `MCPStreamableHTTPTool` | `from agent_framework import MCPStreamableHTTPTool` | Client-managed MCP |\n\n## Complete Example\n\n```python\nimport asyncio\nfrom typing import Annotated\nfrom pydantic import BaseModel, Field\nfrom agent_framework import (\n    HostedCodeInterpreterTool,\n    HostedWebSearchTool,\n    MCPStreamableHTTPTool,\n)\nfrom agent_framework.azure import AzureAIAgentsProvider\nfrom azure.identity.aio import AzureCliCredential\n\n\ndef get_weather(\n    location: Annotated[str, Field(description=\"City name\")],\n) -> str:\n    \"\"\"Get weather for a location.\"\"\"\n    return f\"Weather in {location}: 72°F, sunny\"\n\n\nclass AnalysisResult(BaseModel):\n    summary: str\n    key_findings: list[str]\n    confidence: float\n\n\nasync def main():\n    async with (\n        AzureCliCredential() as credential,\n        MCPStreamableHTTPTool(\n            name=\"Docs MCP\",\n            url=\"https:\u002F\u002Flearn.microsoft.com\u002Fapi\u002Fmcp\",\n        ) as mcp_tool,\n        AzureAIAgentsProvider(credential=credential) as provider,\n    ):\n        agent = await provider.create_agent(\n            name=\"ResearchAssistant\",\n            instructions=\"You are a research assistant with multiple capabilities.\",\n            tools=[\n                get_weather,\n                HostedCodeInterpreterTool(),\n                HostedWebSearchTool(name=\"Bing\"),\n                mcp_tool,\n            ],\n        )\n        \n        thread = agent.get_new_thread()\n        \n        # Non-streaming\n        result = await agent.run(\n            \"Search for Python best practices and summarize\",\n            thread=thread,\n        )\n        print(f\"Response: {result.text}\")\n        \n        # Streaming\n        print(\"\\nStreaming: \", end=\"\")\n        async for chunk in agent.run_stream(\"Continue with examples\", thread=thread):\n            if chunk.text:\n                print(chunk.text, end=\"\", flush=True)\n        print()\n        \n        # Structured output\n        result = await agent.run(\n            \"Analyze findings\",\n            thread=thread,\n            response_format=AnalysisResult,\n        )\n        analysis = AnalysisResult.model_validate_json(result.text)\n        print(f\"\\nConfidence: {analysis.confidence}\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Conventions\n\n- Always use async context managers: `async with provider:`\n- Pass functions directly to `tools=` parameter (auto-converted to AIFunction)\n- Use `Annotated[type, Field(description=...)]` for function parameters\n- Use `get_new_thread()` for multi-turn conversations\n- Prefer `HostedMCPTool` for service-managed MCP, `MCPStreamableHTTPTool` for client-managed\n\n## Best Practices\n\n1. **This SDK is async-first — use `async def` handlers and `async with` throughout.**\n2. **Always use context managers for clients and async credentials.** Wrap every client in `with Client(...) as client:` (sync) or `async with Client(...) as client:` (async). For async `DefaultAzureCredential` from `azure.identity.aio`, also use `async with credential:` so tokens and transports are cleaned up.\n\n## Reference Files\n\n- [references\u002Ftools.md](references\u002Ftools.md): Detailed hosted tool patterns\n- [references\u002Fmcp.md](references\u002Fmcp.md): MCP integration (hosted + local)\n- [references\u002Fthreads.md](references\u002Fthreads.md): Thread and conversation management\n- [references\u002Fadvanced.md](references\u002Fadvanced.md): OpenAPI, citations, structured outputs\n",{"name":5,"license":14,"metadata":23,"description":7},{"author":24,"package":25,"version":26},"Microsoft","agent-framework-azure-ai","1.0.0","main","634c25395a24b98cd6125453ad4abb65517bcabb","bench\u002Fcorpus\u002Fbenign\u002Freal-ms-agent-framework-azure-ai-py","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard","https:\u002F\u002Fsite-bionic8.vercel.app","https:\u002F\u002Fgithub.com\u002Fak2dev","2026-11-11 02:37:06",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add ak2dev\u002Fagentguard --skill agent-framework-azure-ai-py",{"tool":40,"command":41},"bunx","bunx skills add ak2dev\u002Fagentguard --skill agent-framework-azure-ai-py",{"tool":43,"command":44},"pnpm","pnpm dlx skills add ak2dev\u002Fagentguard --skill agent-framework-azure-ai-py","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Fbench\u002Fcorpus\u002Fbenign\u002Freal-ms-agent-framework-azure-ai-py\u002FSKILL.md",true,[48,54,58,62],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fadvanced.md","REFERENCE","参考文档",13356,"https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Fbench\u002Fcorpus\u002Fbenign\u002Freal-ms-agent-framework-azure-ai-py\u002Freferences\u002Fadvanced.md",{"path":55,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fmcp.md",7779,"https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Fbench\u002Fcorpus\u002Fbenign\u002Freal-ms-agent-framework-azure-ai-py\u002Freferences\u002Fmcp.md",{"path":59,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fthreads.md",7911,"https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Fbench\u002Fcorpus\u002Fbenign\u002Freal-ms-agent-framework-azure-ai-py\u002Freferences\u002Fthreads.md",{"path":63,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Ftools.md",7468,"https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Fbench\u002Fcorpus\u002Fbenign\u002Freal-ms-agent-framework-azure-ai-py\u002Freferences\u002Ftools.md",[67,75,80,85,90,96],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M7DJ7GBSJBJ32GXNQXVAMNYK","csv-tool","Summarize CSV files and report column statistics.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Ffixtures\u002Frules\u002FAG-SYS-002\u002Fpositive\u002Ffault\u002Fcsv-tool\u002FSKILL.md",[],[],{"skillNo":76,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7DJ7F00PA7EHFM39RVCC8R5","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Ffixtures\u002Frules\u002FAG-SYS-002\u002Fnegative\u002Fnormal\u002Fcsv-tool\u002FSKILL.md",[],[],{"skillNo":81,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M7DJ7DP7KDW7MYY5Q0R0JFEN","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Ffixtures\u002Frules\u002FAG-SYS-001\u002Fpositive\u002Ftoo-large\u002Fcsv-tool\u002FSKILL.md",[],[],{"skillNo":86,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M7DJ7C3VA0KQ8Q9ESNX6AJHE","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Ffixtures\u002Frules\u002FAG-SYS-001\u002Fnegative\u002Fsmall\u002Fcsv-tool\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":18},"01M7DJ7AQZTGY5YADQX73TRB7K","pdf","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Ffixtures\u002Frules\u002FAG-SKL-TYP-002\u002Fpositive\u002Fother-publisher\u002Fpdf\u002FSKILL.md",[],[],{"skillNo":97,"name":92,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":71,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M7DJ7831XDVWS4W9SAAKBJHX","https:\u002F\u002Fgithub.com\u002Fak2dev\u002Fagentguard\u002Fblob\u002Fmain\u002Ffixtures\u002Frules\u002FAG-SKL-TYP-002\u002Fnegative\u002Fsame-publisher\u002Fpdf\u002FSKILL.md",[],[]]