Integration library for Microsoft Agents with aiohttp
Project description
Microsoft Agents Hosting - aiohttp
Integration library for hosting Microsoft 365 Agents using aiohttp. This library provides HTTP adapters, middleware, and utilities for building web-based agent applications with the popular aiohttp framework.
This library bridges the Microsoft 365 Agents SDK with aiohttp, allowing you to create HTTP endpoints that handle agent conversations. It provides everything you need to host agents as web services, including request processing, authentication, and routing.
What is this?
This library is part of the Microsoft 365 Agents SDK for Python - a comprehensive framework for building enterprise-grade conversational AI agents. The SDK enables developers to create intelligent agents that work across multiple platforms including Microsoft Teams, M365 Copilot, Copilot Studio, and web chat, with support for third-party integrations like Slack, Facebook Messenger, and Twilio.
Release Notes
| Version | Date | Release Notes |
|---|---|---|
| 0.9.0 | 2026-04-15 | 0.9.0 Release Notes |
| 0.8.0 | 2026-02-23 | 0.8.0 Release Notes |
| 0.7.0 | 2026-01-21 | 0.7.0 Release Notes |
| 0.6.1 | 2025-12-01 | 0.6.1 Release Notes |
| 0.6.0 | 2025-11-18 | 0.6.0 Release Notes |
| 0.5.0 | 2025-10-22 | 0.5.0 Release Notes |
Packages Overview
We offer the following PyPI packages to create conversational experiences based on Agents:
Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
| Package Name | PyPI Version | Description |
|---|---|---|
microsoft-agents-copilotstudio-client |
Direct to Engine client to interact with Agents created in CopilotStudio |
Installation
pip install microsoft-agents-hosting-aiohttp
Simple Echo Agent
See the Quickstart sample for full working code.
agents_sdk_config = load_configuration_from_env(environ)
STORAGE = MemoryStorage()
CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
AGENT_APP = AgentApplication[TurnState](
storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
)
@AGENT_APP.activity("message")
async def on_message(context: TurnContext, state: TurnState):
await context.send_activity(f"You said: {context.activity.text}")
...
start_server(
agent_application=AGENT_APP,
auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
)
Error Handling
Customize error responses. Code take from the Quickstart sample.
@AGENT_APP.error
async def on_error(context: TurnContext, error: Exception):
# This check writes out errors to console log
# NOTE: In production environment, you should consider logging this to Azure
# application insights.
print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
traceback.print_exc()
# Send a message to the user
await context.send_activity("The bot encountered an error or bug.")
Features
✅ HTTP hosting - Full aiohttp integration for web hosting
✅ JWT authentication - Built-in security with middleware
✅ Agent-to-agent - Support for multi-agent communication
✅ Streaming - Real-time response streaming
✅ Error handling - Comprehensive error management
✅ Development friendly - Hot reload and debugging support
Requirements
- Python 3.10+ (supports 3.10, 3.11, 3.12, 3.13, 3.14)
- aiohttp 3.11.11+
- Microsoft Agents hosting core library
Best Practices
- Use middleware for cross-cutting concerns like auth and logging
- Handle errors gracefully with custom error handlers
- Secure your endpoints with JWT middleware in production
- Structure routes logically for agent communication
Quick Links
Sample Applications
| Name | Description | README |
|---|---|---|
| Quickstart | Simplest agent | Quickstart |
| Auto Sign In | Simple OAuth agent using Graph and GitHub | auto-signin |
| OBO Authorization | OBO flow to access a Copilot Studio Agent | obo-authorization |
| Semantic Kernel Integration | A weather agent built with Semantic Kernel | semantic-kernel-multiturn |
| Streaming Agent | Streams OpenAI responses | azure-ai-streaming |
| Copilot Studio Client | Console app to consume a Copilot Studio Agent | copilotstudio-client |
| Cards Agent | Agent that uses rich cards to enhance conversation design | cards |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microsoft_agents_hosting_aiohttp-0.9.0.tar.gz.
File metadata
- Download URL: microsoft_agents_hosting_aiohttp-0.9.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06cd8f8c07c6758181ca3e13828acef8264e176b0577d5e699c9754e8d373882
|
|
| MD5 |
b462c0c6df1c52ac1de125355ce608a9
|
|
| BLAKE2b-256 |
23294a7dd835fae221423890b0dc030ca7466561c92ca501c5f11d302c565624
|
File details
Details for the file microsoft_agents_hosting_aiohttp-0.9.0-py3-none-any.whl.
File metadata
- Download URL: microsoft_agents_hosting_aiohttp-0.9.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54adaf380a5df6e9de8b8123090fafc96ccd512fddb332ca6ee1ca1e95874d9d
|
|
| MD5 |
66f74e6e5af03b61bb77a1401be12b34
|
|
| BLAKE2b-256 |
b2db63665da67e1938c847010e619d90ddc1658a8a519e455ebf9dd90f82ae42
|