microsoft-agents-hosting-aiohttp 0.4.0.dev16__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. microsoft_agents_hosting_aiohttp-0.5.0/LICENSE +21 -0
  2. microsoft_agents_hosting_aiohttp-0.5.0/PKG-INFO +162 -0
  3. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/jwt_authorization_middleware.py +3 -2
  4. microsoft_agents_hosting_aiohttp-0.5.0/microsoft_agents_hosting_aiohttp.egg-info/PKG-INFO +162 -0
  5. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents_hosting_aiohttp.egg-info/SOURCES.txt +2 -0
  6. microsoft_agents_hosting_aiohttp-0.5.0/microsoft_agents_hosting_aiohttp.egg-info/requires.txt +2 -0
  7. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/pyproject.toml +9 -2
  8. microsoft_agents_hosting_aiohttp-0.5.0/readme.md +140 -0
  9. microsoft_agents_hosting_aiohttp-0.4.0.dev16/PKG-INFO +0 -13
  10. microsoft_agents_hosting_aiohttp-0.4.0.dev16/microsoft_agents_hosting_aiohttp.egg-info/PKG-INFO +0 -13
  11. microsoft_agents_hosting_aiohttp-0.4.0.dev16/microsoft_agents_hosting_aiohttp.egg-info/requires.txt +0 -2
  12. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/__init__.py +0 -0
  13. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/_start_agent_process.py +0 -0
  14. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/agent_http_adapter.py +0 -0
  15. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/app/__init__.py +0 -0
  16. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/app/streaming/__init__.py +0 -0
  17. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/app/streaming/citation.py +0 -0
  18. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/app/streaming/citation_util.py +0 -0
  19. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/app/streaming/streaming_response.py +0 -0
  20. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/channel_service_route_table.py +0 -0
  21. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents/hosting/aiohttp/cloud_adapter.py +0 -0
  22. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents_hosting_aiohttp.egg-info/dependency_links.txt +0 -0
  23. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/microsoft_agents_hosting_aiohttp.egg-info/top_level.txt +0 -0
  24. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/setup.cfg +0 -0
  25. {microsoft_agents_hosting_aiohttp-0.4.0.dev16 → microsoft_agents_hosting_aiohttp-0.5.0}/setup.py +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: microsoft-agents-hosting-aiohttp
3
+ Version: 0.5.0
4
+ Summary: Integration library for Microsoft Agents with aiohttp
5
+ Author: Microsoft Corporation
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/microsoft/Agents
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: microsoft-agents-hosting-core==0.5.0
19
+ Requires-Dist: aiohttp>=3.11.11
20
+ Dynamic: license-file
21
+ Dynamic: requires-dist
22
+
23
+ # Microsoft Agents Hosting - aiohttp
24
+
25
+ [![PyPI version](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/)
26
+
27
+ 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.
28
+
29
+ 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.
30
+
31
+ # What is this?
32
+
33
+ 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.
34
+
35
+ ## Release Notes
36
+ <table style="width:100%">
37
+ <tr>
38
+ <th style="width:20%">Version</th>
39
+ <th style="width:20%">Date</th>
40
+ <th style="width:60%">Release Notes</th>
41
+ </tr>
42
+ <tr>
43
+ <td>0.5.0</td>
44
+ <td>2025-10-22</td>
45
+ <td>
46
+ <a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md">
47
+ 0.5.0 Release Notes
48
+ </a>
49
+ </td>
50
+ </tr>
51
+ </table>
52
+
53
+ ## Packages Overview
54
+
55
+ We offer the following PyPI packages to create conversational experiences based on Agents:
56
+
57
+ | Package Name | PyPI Version | Description |
58
+ |--------------|-------------|-------------|
59
+ | `microsoft-agents-activity` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-activity)](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
60
+ | `microsoft-agents-hosting-core` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-core)](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
61
+ | `microsoft-agents-hosting-aiohttp` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
62
+ | `microsoft-agents-hosting-teams` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-teams)](https://pypi.org/project/microsoft-agents-hosting-teams/) | Provides classes to host an Agent for Teams. |
63
+ | `microsoft-agents-storage-blob` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-blob)](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
64
+ | `microsoft-agents-storage-cosmos` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-cosmos)](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
65
+ | `microsoft-agents-authentication-msal` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-authentication-msal)](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
66
+
67
+ Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
68
+
69
+ | Package Name | PyPI Version | Description |
70
+ |--------------|-------------|-------------|
71
+ | `microsoft-agents-copilotstudio-client` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-copilotstudio-client)](https://pypi.org/project/microsoft-agents-copilotstudio-client/) | Direct to Engine client to interact with Agents created in CopilotStudio |
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ pip install microsoft-agents-hosting-aiohttp
77
+ ```
78
+
79
+ ## Simple Echo Agent
80
+ See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
81
+
82
+ ```python
83
+ agents_sdk_config = load_configuration_from_env(environ)
84
+
85
+ STORAGE = MemoryStorage()
86
+ CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
87
+ ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
88
+ AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
89
+
90
+ AGENT_APP = AgentApplication[TurnState](
91
+ storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
92
+ )
93
+
94
+ @AGENT_APP.activity("message")
95
+ async def on_message(context: TurnContext, state: TurnState):
96
+ await context.send_activity(f"You said: {context.activity.text}")
97
+
98
+ ...
99
+
100
+ start_server(
101
+ agent_application=AGENT_APP,
102
+ auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
103
+ )
104
+ ```
105
+
106
+
107
+ ### Error Handling
108
+
109
+ Customize error responses. Code take from the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart).
110
+
111
+ ```python
112
+ @AGENT_APP.error
113
+ async def on_error(context: TurnContext, error: Exception):
114
+ # This check writes out errors to console log
115
+ # NOTE: In production environment, you should consider logging this to Azure
116
+ # application insights.
117
+ print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
118
+ traceback.print_exc()
119
+
120
+ # Send a message to the user
121
+ await context.send_activity("The bot encountered an error or bug.")
122
+ ```
123
+
124
+ ## Features
125
+
126
+ ✅ **HTTP hosting** - Full aiohttp integration for web hosting
127
+ ✅ **JWT authentication** - Built-in security with middleware
128
+ ✅ **Agent-to-agent** - Support for multi-agent communication
129
+ ✅ **Streaming** - Real-time response streaming
130
+ ✅ **Error handling** - Comprehensive error management
131
+ ✅ **Development friendly** - Hot reload and debugging support
132
+
133
+ ## Requirements
134
+
135
+ - Python 3.10+ (supports 3.10, 3.11, 3.12, 3.13, 3.14)
136
+ - aiohttp 3.11.11+
137
+ - Microsoft Agents hosting core library
138
+
139
+ ## Best Practices
140
+
141
+ 1. **Use middleware** for cross-cutting concerns like auth and logging
142
+ 2. **Handle errors gracefully** with custom error handlers
143
+ 3. **Secure your endpoints** with JWT middleware in production
144
+ 4. **Structure routes** logically for agent communication
145
+
146
+ # Quick Links
147
+
148
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
149
+ - 📖 [Complete Documentation](https://aka.ms/agents)
150
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
151
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
152
+
153
+ # Sample Applications
154
+ |Name|Description|README|
155
+ |----|----|----|
156
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
157
+ |Auto Sign In|Simple OAuth agent using Graph and GitHub|[auto-signin](https://github.com/microsoft/Agents/blob/main/samples/python/auto-signin/README.md)|
158
+ |OBO Authorization|OBO flow to access a Copilot Studio Agent|[obo-authorization](https://github.com/microsoft/Agents/blob/main/samples/python/obo-authorization/README.md)|
159
+ |Semantic Kernel Integration|A weather agent built with Semantic Kernel|[semantic-kernel-multiturn](https://github.com/microsoft/Agents/blob/main/samples/python/semantic-kernel-multiturn/README.md)|
160
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
161
+ |Copilot Studio Client|Console app to consume a Copilot Studio Agent|[copilotstudio-client](https://github.com/microsoft/Agents/blob/main/samples/python/copilotstudio-client/README.md)|
162
+ |Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](https://github.com/microsoft/Agents/blob/main/samples/python/cards/README.md)|
@@ -13,11 +13,12 @@ async def jwt_authorization_middleware(request: Request, handler):
13
13
  auth_config: AgentAuthConfiguration = request.app["agent_configuration"]
14
14
  token_validator = JwtTokenValidator(auth_config)
15
15
  auth_header = request.headers.get("Authorization")
16
+
16
17
  if auth_header:
17
18
  # Extract the token from the Authorization header
18
19
  token = auth_header.split(" ")[1]
19
20
  try:
20
- claims = token_validator.validate_token(token)
21
+ claims = await token_validator.validate_token(token)
21
22
  request["claims_identity"] = claims
22
23
  except ValueError as e:
23
24
  print(f"JWT validation error: {e}")
@@ -44,7 +45,7 @@ def jwt_authorization_decorator(func):
44
45
  # Extract the token from the Authorization header
45
46
  token = auth_header.split(" ")[1]
46
47
  try:
47
- claims = token_validator.validate_token(token)
48
+ claims = await token_validator.validate_token(token)
48
49
  request["claims_identity"] = claims
49
50
  except ValueError as e:
50
51
  print(f"JWT validation error: {e}")
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: microsoft-agents-hosting-aiohttp
3
+ Version: 0.5.0
4
+ Summary: Integration library for Microsoft Agents with aiohttp
5
+ Author: Microsoft Corporation
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/microsoft/Agents
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: microsoft-agents-hosting-core==0.5.0
19
+ Requires-Dist: aiohttp>=3.11.11
20
+ Dynamic: license-file
21
+ Dynamic: requires-dist
22
+
23
+ # Microsoft Agents Hosting - aiohttp
24
+
25
+ [![PyPI version](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/)
26
+
27
+ 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.
28
+
29
+ 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.
30
+
31
+ # What is this?
32
+
33
+ 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.
34
+
35
+ ## Release Notes
36
+ <table style="width:100%">
37
+ <tr>
38
+ <th style="width:20%">Version</th>
39
+ <th style="width:20%">Date</th>
40
+ <th style="width:60%">Release Notes</th>
41
+ </tr>
42
+ <tr>
43
+ <td>0.5.0</td>
44
+ <td>2025-10-22</td>
45
+ <td>
46
+ <a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md">
47
+ 0.5.0 Release Notes
48
+ </a>
49
+ </td>
50
+ </tr>
51
+ </table>
52
+
53
+ ## Packages Overview
54
+
55
+ We offer the following PyPI packages to create conversational experiences based on Agents:
56
+
57
+ | Package Name | PyPI Version | Description |
58
+ |--------------|-------------|-------------|
59
+ | `microsoft-agents-activity` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-activity)](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
60
+ | `microsoft-agents-hosting-core` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-core)](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
61
+ | `microsoft-agents-hosting-aiohttp` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
62
+ | `microsoft-agents-hosting-teams` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-teams)](https://pypi.org/project/microsoft-agents-hosting-teams/) | Provides classes to host an Agent for Teams. |
63
+ | `microsoft-agents-storage-blob` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-blob)](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
64
+ | `microsoft-agents-storage-cosmos` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-cosmos)](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
65
+ | `microsoft-agents-authentication-msal` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-authentication-msal)](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
66
+
67
+ Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
68
+
69
+ | Package Name | PyPI Version | Description |
70
+ |--------------|-------------|-------------|
71
+ | `microsoft-agents-copilotstudio-client` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-copilotstudio-client)](https://pypi.org/project/microsoft-agents-copilotstudio-client/) | Direct to Engine client to interact with Agents created in CopilotStudio |
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ pip install microsoft-agents-hosting-aiohttp
77
+ ```
78
+
79
+ ## Simple Echo Agent
80
+ See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
81
+
82
+ ```python
83
+ agents_sdk_config = load_configuration_from_env(environ)
84
+
85
+ STORAGE = MemoryStorage()
86
+ CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
87
+ ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
88
+ AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
89
+
90
+ AGENT_APP = AgentApplication[TurnState](
91
+ storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
92
+ )
93
+
94
+ @AGENT_APP.activity("message")
95
+ async def on_message(context: TurnContext, state: TurnState):
96
+ await context.send_activity(f"You said: {context.activity.text}")
97
+
98
+ ...
99
+
100
+ start_server(
101
+ agent_application=AGENT_APP,
102
+ auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
103
+ )
104
+ ```
105
+
106
+
107
+ ### Error Handling
108
+
109
+ Customize error responses. Code take from the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart).
110
+
111
+ ```python
112
+ @AGENT_APP.error
113
+ async def on_error(context: TurnContext, error: Exception):
114
+ # This check writes out errors to console log
115
+ # NOTE: In production environment, you should consider logging this to Azure
116
+ # application insights.
117
+ print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
118
+ traceback.print_exc()
119
+
120
+ # Send a message to the user
121
+ await context.send_activity("The bot encountered an error or bug.")
122
+ ```
123
+
124
+ ## Features
125
+
126
+ ✅ **HTTP hosting** - Full aiohttp integration for web hosting
127
+ ✅ **JWT authentication** - Built-in security with middleware
128
+ ✅ **Agent-to-agent** - Support for multi-agent communication
129
+ ✅ **Streaming** - Real-time response streaming
130
+ ✅ **Error handling** - Comprehensive error management
131
+ ✅ **Development friendly** - Hot reload and debugging support
132
+
133
+ ## Requirements
134
+
135
+ - Python 3.10+ (supports 3.10, 3.11, 3.12, 3.13, 3.14)
136
+ - aiohttp 3.11.11+
137
+ - Microsoft Agents hosting core library
138
+
139
+ ## Best Practices
140
+
141
+ 1. **Use middleware** for cross-cutting concerns like auth and logging
142
+ 2. **Handle errors gracefully** with custom error handlers
143
+ 3. **Secure your endpoints** with JWT middleware in production
144
+ 4. **Structure routes** logically for agent communication
145
+
146
+ # Quick Links
147
+
148
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
149
+ - 📖 [Complete Documentation](https://aka.ms/agents)
150
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
151
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
152
+
153
+ # Sample Applications
154
+ |Name|Description|README|
155
+ |----|----|----|
156
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
157
+ |Auto Sign In|Simple OAuth agent using Graph and GitHub|[auto-signin](https://github.com/microsoft/Agents/blob/main/samples/python/auto-signin/README.md)|
158
+ |OBO Authorization|OBO flow to access a Copilot Studio Agent|[obo-authorization](https://github.com/microsoft/Agents/blob/main/samples/python/obo-authorization/README.md)|
159
+ |Semantic Kernel Integration|A weather agent built with Semantic Kernel|[semantic-kernel-multiturn](https://github.com/microsoft/Agents/blob/main/samples/python/semantic-kernel-multiturn/README.md)|
160
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
161
+ |Copilot Studio Client|Console app to consume a Copilot Studio Agent|[copilotstudio-client](https://github.com/microsoft/Agents/blob/main/samples/python/copilotstudio-client/README.md)|
162
+ |Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](https://github.com/microsoft/Agents/blob/main/samples/python/cards/README.md)|
@@ -1,4 +1,6 @@
1
+ LICENSE
1
2
  pyproject.toml
3
+ readme.md
2
4
  setup.py
3
5
  microsoft_agents/hosting/aiohttp/__init__.py
4
6
  microsoft_agents/hosting/aiohttp/_start_agent_process.py
@@ -0,0 +1,2 @@
1
+ microsoft-agents-hosting-core==0.5.0
2
+ aiohttp>=3.11.11
@@ -6,11 +6,18 @@ build-backend = "setuptools.build_meta"
6
6
  name = "microsoft-agents-hosting-aiohttp"
7
7
  dynamic = ["version", "dependencies"]
8
8
  description = "Integration library for Microsoft Agents with aiohttp"
9
+ readme = {file = "readme.md", content-type = "text/markdown"}
9
10
  authors = [{name = "Microsoft Corporation"}]
10
- requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ requires-python = ">=3.10"
11
14
  classifiers = [
12
15
  "Programming Language :: Python :: 3",
13
- "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Programming Language :: Python :: 3.14",
14
21
  "Operating System :: OS Independent",
15
22
  ]
16
23
 
@@ -0,0 +1,140 @@
1
+ # Microsoft Agents Hosting - aiohttp
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/)
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ # What is this?
10
+
11
+ 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.
12
+
13
+ ## Release Notes
14
+ <table style="width:100%">
15
+ <tr>
16
+ <th style="width:20%">Version</th>
17
+ <th style="width:20%">Date</th>
18
+ <th style="width:60%">Release Notes</th>
19
+ </tr>
20
+ <tr>
21
+ <td>0.5.0</td>
22
+ <td>2025-10-22</td>
23
+ <td>
24
+ <a href="https://github.com/microsoft/Agents-for-python/blob/main/changelog.md">
25
+ 0.5.0 Release Notes
26
+ </a>
27
+ </td>
28
+ </tr>
29
+ </table>
30
+
31
+ ## Packages Overview
32
+
33
+ We offer the following PyPI packages to create conversational experiences based on Agents:
34
+
35
+ | Package Name | PyPI Version | Description |
36
+ |--------------|-------------|-------------|
37
+ | `microsoft-agents-activity` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-activity)](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. |
38
+ | `microsoft-agents-hosting-core` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-core)](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. |
39
+ | `microsoft-agents-hosting-aiohttp` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. |
40
+ | `microsoft-agents-hosting-teams` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-teams)](https://pypi.org/project/microsoft-agents-hosting-teams/) | Provides classes to host an Agent for Teams. |
41
+ | `microsoft-agents-storage-blob` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-blob)](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. |
42
+ | `microsoft-agents-storage-cosmos` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-cosmos)](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. |
43
+ | `microsoft-agents-authentication-msal` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-authentication-msal)](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. |
44
+
45
+ Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
46
+
47
+ | Package Name | PyPI Version | Description |
48
+ |--------------|-------------|-------------|
49
+ | `microsoft-agents-copilotstudio-client` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-copilotstudio-client)](https://pypi.org/project/microsoft-agents-copilotstudio-client/) | Direct to Engine client to interact with Agents created in CopilotStudio |
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install microsoft-agents-hosting-aiohttp
55
+ ```
56
+
57
+ ## Simple Echo Agent
58
+ See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
59
+
60
+ ```python
61
+ agents_sdk_config = load_configuration_from_env(environ)
62
+
63
+ STORAGE = MemoryStorage()
64
+ CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
65
+ ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
66
+ AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
67
+
68
+ AGENT_APP = AgentApplication[TurnState](
69
+ storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
70
+ )
71
+
72
+ @AGENT_APP.activity("message")
73
+ async def on_message(context: TurnContext, state: TurnState):
74
+ await context.send_activity(f"You said: {context.activity.text}")
75
+
76
+ ...
77
+
78
+ start_server(
79
+ agent_application=AGENT_APP,
80
+ auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
81
+ )
82
+ ```
83
+
84
+
85
+ ### Error Handling
86
+
87
+ Customize error responses. Code take from the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart).
88
+
89
+ ```python
90
+ @AGENT_APP.error
91
+ async def on_error(context: TurnContext, error: Exception):
92
+ # This check writes out errors to console log
93
+ # NOTE: In production environment, you should consider logging this to Azure
94
+ # application insights.
95
+ print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
96
+ traceback.print_exc()
97
+
98
+ # Send a message to the user
99
+ await context.send_activity("The bot encountered an error or bug.")
100
+ ```
101
+
102
+ ## Features
103
+
104
+ ✅ **HTTP hosting** - Full aiohttp integration for web hosting
105
+ ✅ **JWT authentication** - Built-in security with middleware
106
+ ✅ **Agent-to-agent** - Support for multi-agent communication
107
+ ✅ **Streaming** - Real-time response streaming
108
+ ✅ **Error handling** - Comprehensive error management
109
+ ✅ **Development friendly** - Hot reload and debugging support
110
+
111
+ ## Requirements
112
+
113
+ - Python 3.10+ (supports 3.10, 3.11, 3.12, 3.13, 3.14)
114
+ - aiohttp 3.11.11+
115
+ - Microsoft Agents hosting core library
116
+
117
+ ## Best Practices
118
+
119
+ 1. **Use middleware** for cross-cutting concerns like auth and logging
120
+ 2. **Handle errors gracefully** with custom error handlers
121
+ 3. **Secure your endpoints** with JWT middleware in production
122
+ 4. **Structure routes** logically for agent communication
123
+
124
+ # Quick Links
125
+
126
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
127
+ - 📖 [Complete Documentation](https://aka.ms/agents)
128
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
129
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
130
+
131
+ # Sample Applications
132
+ |Name|Description|README|
133
+ |----|----|----|
134
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
135
+ |Auto Sign In|Simple OAuth agent using Graph and GitHub|[auto-signin](https://github.com/microsoft/Agents/blob/main/samples/python/auto-signin/README.md)|
136
+ |OBO Authorization|OBO flow to access a Copilot Studio Agent|[obo-authorization](https://github.com/microsoft/Agents/blob/main/samples/python/obo-authorization/README.md)|
137
+ |Semantic Kernel Integration|A weather agent built with Semantic Kernel|[semantic-kernel-multiturn](https://github.com/microsoft/Agents/blob/main/samples/python/semantic-kernel-multiturn/README.md)|
138
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
139
+ |Copilot Studio Client|Console app to consume a Copilot Studio Agent|[copilotstudio-client](https://github.com/microsoft/Agents/blob/main/samples/python/copilotstudio-client/README.md)|
140
+ |Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](https://github.com/microsoft/Agents/blob/main/samples/python/cards/README.md)|
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: microsoft-agents-hosting-aiohttp
3
- Version: 0.4.0.dev16
4
- Summary: Integration library for Microsoft Agents with aiohttp
5
- Author: Microsoft Corporation
6
- Project-URL: Homepage, https://github.com/microsoft/Agents
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.9
11
- Requires-Dist: microsoft-agents-hosting-core==0.4.0.dev16
12
- Requires-Dist: aiohttp>=3.11.11
13
- Dynamic: requires-dist
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: microsoft-agents-hosting-aiohttp
3
- Version: 0.4.0.dev16
4
- Summary: Integration library for Microsoft Agents with aiohttp
5
- Author: Microsoft Corporation
6
- Project-URL: Homepage, https://github.com/microsoft/Agents
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.9
11
- Requires-Dist: microsoft-agents-hosting-core==0.4.0.dev16
12
- Requires-Dist: aiohttp>=3.11.11
13
- Dynamic: requires-dist
@@ -1,2 +0,0 @@
1
- microsoft-agents-hosting-core==0.4.0.dev16
2
- aiohttp>=3.11.11