{"library":"microsoft-agents-hosting-core","title":"Microsoft Agents Hosting Core","description":"The `microsoft-agents-hosting-core` library is the foundational component of the Microsoft 365 Agents SDK for Python. It provides the essential building blocks for creating conversational AI agents, handling core functionalities such as activity processing, state management, and channel communication. This library is crucial for orchestrating conversations and managing agent state across turns, enabling the development of production-ready agents for platforms like Microsoft Teams, M365 Copilot, Copilot Studio, and web chat. It is actively maintained with frequent updates.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install microsoft-agents-hosting-core","pip install microsoft-agents-hosting-aiohttp"],"cli":null},"imports":["from microsoft_agents.hosting.core import AgentApplication","from microsoft_agents.hosting.core import AgentAuthConfiguration","from microsoft_agents.hosting.core import TurnContext","from microsoft_agents.hosting.core import ActivityHandler","from microsoft_agents.hosting.aiohttp import start_agent_process"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom aiohttp.web import Request, Response, Application\nfrom microsoft_agents.hosting.core import AgentApplication, AgentAuthConfiguration, TurnContext\nfrom microsoft_agents.hosting.aiohttp import (\n    start_agent_process,\n    jwt_authorization_middleware,\n    CloudAdapter,\n)\nfrom microsoft_agents.activity import Activity\n\n# Define the Echo Agent using AgentApplication\nagent_app = AgentApplication()\n\n@agent_app.activity(\"message\")\nasync def message_activity_handler(turn_context: TurnContext):\n    await turn_context.send_activity(Activity(text=f\"Echo: {turn_context.activity.text}\"))\n\nasync def main():\n    # Example of setting up auth configuration (for non-anonymous hosting)\n    # Use os.environ.get for dynamic configuration\n    auth_config = AgentAuthConfiguration(\n        TENANT_ID=os.environ.get('TENANT_ID', ''),\n        CLIENT_ID=os.environ.get('CLIENT_ID', ''),\n        CLIENT_SECRET=os.environ.get('CLIENT_SECRET', ''),\n        # Add other auth parameters as needed\n    )\n\n    # Start the agent using aiohttp, defaulting to anonymous if no client_id is set\n    await start_agent_process(\n        agent_app,\n        CloudAdapter(),\n        auth_config if auth_config.CLIENT_ID else None, # Pass auth_config only if credentials are provided\n        middlewares=[jwt_authorization_middleware] if auth_config.CLIENT_ID else [],\n        port=3978 # Default port for agents\n    )\n\nif __name__ == \"__main__\":\n    import asyncio\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to create a simple 'Echo Agent' using `microsoft-agents-hosting-core` and host it with `aiohttp`. It utilizes the `AgentApplication` class, which is the recommended modern API for building agents, replacing the older `ActivityHandler`. The example shows how to define an activity handler for 'message' activities, echoing back the user's input. It also includes boilerplate for authentication configuration, though it can run anonymously if environment variables for `TENANT_ID`, `CLIENT_ID`, and `CLIENT_SECRET` are not set. The `start_agent_process` function from `microsoft-agents-hosting-aiohttp` is used to launch the web server.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.4.0","pypi_latest":"0.9.1","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":6,"avg_import_s":1.55,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.48,"mem_mb":22.8,"disk_size":"50.1M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"41.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":8.6,"import_time_s":1.06,"mem_mb":22.8,"disk_size":"51M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.3,"import_time_s":null,"mem_mb":null,"disk_size":"41M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.88,"mem_mb":24.4,"disk_size":"54.7M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"45.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":7,"import_time_s":1.65,"mem_mb":24.4,"disk_size":"56M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.7,"import_time_s":null,"mem_mb":null,"disk_size":"45M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.81,"mem_mb":24.2,"disk_size":"46.0M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"36.9M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.4,"import_time_s":1.8,"mem_mb":24.1,"disk_size":"47M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4,"import_time_s":null,"mem_mb":null,"disk_size":"36M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.77,"mem_mb":24.5,"disk_size":"45.8M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"36.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.6,"import_time_s":1.74,"mem_mb":24.5,"disk_size":"47M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.1,"import_time_s":null,"mem_mb":null,"disk_size":"36M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.19,"mem_mb":21.7,"disk_size":"44.9M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"35.6M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-aiohttp","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":9.5,"import_time_s":1.13,"mem_mb":21.7,"disk_size":"47M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"microsoft-agents-hosting-core","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.5,"import_time_s":null,"mem_mb":null,"disk_size":"35M"}]}}