microsoft-agents-hosting-aiohttp 0.5.0.dev5__tar.gz → 0.5.0.dev7__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.dev7/PKG-INFO +139 -0
  2. microsoft_agents_hosting_aiohttp-0.5.0.dev7/microsoft_agents_hosting_aiohttp.egg-info/PKG-INFO +139 -0
  3. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents_hosting_aiohttp.egg-info/SOURCES.txt +1 -0
  4. microsoft_agents_hosting_aiohttp-0.5.0.dev7/microsoft_agents_hosting_aiohttp.egg-info/requires.txt +2 -0
  5. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/pyproject.toml +1 -0
  6. microsoft_agents_hosting_aiohttp-0.5.0.dev7/readme.md +122 -0
  7. microsoft_agents_hosting_aiohttp-0.5.0.dev5/PKG-INFO +0 -15
  8. microsoft_agents_hosting_aiohttp-0.5.0.dev5/microsoft_agents_hosting_aiohttp.egg-info/PKG-INFO +0 -15
  9. microsoft_agents_hosting_aiohttp-0.5.0.dev5/microsoft_agents_hosting_aiohttp.egg-info/requires.txt +0 -2
  10. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/LICENSE +0 -0
  11. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/__init__.py +0 -0
  12. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/_start_agent_process.py +0 -0
  13. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/agent_http_adapter.py +0 -0
  14. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/app/__init__.py +0 -0
  15. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/app/streaming/__init__.py +0 -0
  16. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/app/streaming/citation.py +0 -0
  17. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/app/streaming/citation_util.py +0 -0
  18. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/app/streaming/streaming_response.py +0 -0
  19. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/channel_service_route_table.py +0 -0
  20. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/cloud_adapter.py +0 -0
  21. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents/hosting/aiohttp/jwt_authorization_middleware.py +0 -0
  22. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents_hosting_aiohttp.egg-info/dependency_links.txt +0 -0
  23. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/microsoft_agents_hosting_aiohttp.egg-info/top_level.txt +0 -0
  24. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/setup.cfg +0 -0
  25. {microsoft_agents_hosting_aiohttp-0.5.0.dev5 → microsoft_agents_hosting_aiohttp-0.5.0.dev7}/setup.py +0 -0
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: microsoft-agents-hosting-aiohttp
3
+ Version: 0.5.0.dev7
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: Operating System :: OS Independent
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: microsoft-agents-hosting-core==0.5.0.dev7
14
+ Requires-Dist: aiohttp>=3.11.11
15
+ Dynamic: license-file
16
+ Dynamic: requires-dist
17
+
18
+ # Microsoft Agents Hosting - aiohttp
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/)
21
+
22
+ 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.
23
+
24
+ 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.
25
+
26
+ # What is this?
27
+
28
+ 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.
29
+
30
+ ## Packages Overview
31
+
32
+ We offer the following PyPI packages to create conversational experiences based on Agents:
33
+
34
+ | Package Name | PyPI Version | Description |
35
+ |--------------|-------------|-------------|
36
+ | `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. |
37
+ | `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. |
38
+ | `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. |
39
+ | `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. |
40
+ | `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. |
41
+ | `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. |
42
+ | `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. |
43
+
44
+ Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
45
+
46
+ | Package Name | PyPI Version | Description |
47
+ |--------------|-------------|-------------|
48
+ | `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 |
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install microsoft-agents-hosting-aiohttp
54
+ ```
55
+
56
+ ## Simple Echo Agent
57
+ See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
58
+
59
+ ```python
60
+ agents_sdk_config = load_configuration_from_env(environ)
61
+
62
+ STORAGE = MemoryStorage()
63
+ CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
64
+ ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
65
+ AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
66
+
67
+ AGENT_APP = AgentApplication[TurnState](
68
+ storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
69
+ )
70
+
71
+ @AGENT_APP.activity("message")
72
+ async def on_message(context: TurnContext, state: TurnState):
73
+ await context.send_activity(f"You said: {context.activity.text}")
74
+
75
+ ...
76
+
77
+ start_server(
78
+ agent_application=AGENT_APP,
79
+ auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
80
+ )
81
+ ```
82
+
83
+
84
+ ### Error Handling
85
+
86
+ Customize error responses. Code take from the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart).
87
+
88
+ ```python
89
+ @AGENT_APP.error
90
+ async def on_error(context: TurnContext, error: Exception):
91
+ # This check writes out errors to console log
92
+ # NOTE: In production environment, you should consider logging this to Azure
93
+ # application insights.
94
+ print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
95
+ traceback.print_exc()
96
+
97
+ # Send a message to the user
98
+ await context.send_activity("The bot encountered an error or bug.")
99
+ ```
100
+
101
+ ## Features
102
+
103
+ ✅ **HTTP hosting** - Full aiohttp integration for web hosting
104
+ ✅ **JWT authentication** - Built-in security with middleware
105
+ ✅ **Agent-to-agent** - Support for multi-agent communication
106
+ ✅ **Streaming** - Real-time response streaming
107
+ ✅ **Error handling** - Comprehensive error management
108
+ ✅ **Development friendly** - Hot reload and debugging support
109
+
110
+ ## Requirements
111
+
112
+ - Python 3.9+
113
+ - aiohttp 3.11.11+
114
+ - Microsoft Agents hosting core library
115
+
116
+ ## Best Practices
117
+
118
+ 1. **Use middleware** for cross-cutting concerns like auth and logging
119
+ 2. **Handle errors gracefully** with custom error handlers
120
+ 3. **Secure your endpoints** with JWT middleware in production
121
+ 4. **Structure routes** logically for agent communication
122
+
123
+ # Quick Links
124
+
125
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
126
+ - 📖 [Complete Documentation](https://aka.ms/agents)
127
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
128
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
129
+
130
+ # Sample Applications
131
+ |Name|Description|README|
132
+ |----|----|----|
133
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
134
+ |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)|
135
+ |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)|
136
+ |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)|
137
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
138
+ |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)|
139
+ |Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](https://github.com/microsoft/Agents/blob/main/samples/python/cards/README.md)|
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: microsoft-agents-hosting-aiohttp
3
+ Version: 0.5.0.dev7
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: Operating System :: OS Independent
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: microsoft-agents-hosting-core==0.5.0.dev7
14
+ Requires-Dist: aiohttp>=3.11.11
15
+ Dynamic: license-file
16
+ Dynamic: requires-dist
17
+
18
+ # Microsoft Agents Hosting - aiohttp
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/)
21
+
22
+ 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.
23
+
24
+ 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.
25
+
26
+ # What is this?
27
+
28
+ 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.
29
+
30
+ ## Packages Overview
31
+
32
+ We offer the following PyPI packages to create conversational experiences based on Agents:
33
+
34
+ | Package Name | PyPI Version | Description |
35
+ |--------------|-------------|-------------|
36
+ | `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. |
37
+ | `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. |
38
+ | `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. |
39
+ | `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. |
40
+ | `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. |
41
+ | `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. |
42
+ | `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. |
43
+
44
+ Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
45
+
46
+ | Package Name | PyPI Version | Description |
47
+ |--------------|-------------|-------------|
48
+ | `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 |
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install microsoft-agents-hosting-aiohttp
54
+ ```
55
+
56
+ ## Simple Echo Agent
57
+ See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
58
+
59
+ ```python
60
+ agents_sdk_config = load_configuration_from_env(environ)
61
+
62
+ STORAGE = MemoryStorage()
63
+ CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
64
+ ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
65
+ AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
66
+
67
+ AGENT_APP = AgentApplication[TurnState](
68
+ storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
69
+ )
70
+
71
+ @AGENT_APP.activity("message")
72
+ async def on_message(context: TurnContext, state: TurnState):
73
+ await context.send_activity(f"You said: {context.activity.text}")
74
+
75
+ ...
76
+
77
+ start_server(
78
+ agent_application=AGENT_APP,
79
+ auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
80
+ )
81
+ ```
82
+
83
+
84
+ ### Error Handling
85
+
86
+ Customize error responses. Code take from the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart).
87
+
88
+ ```python
89
+ @AGENT_APP.error
90
+ async def on_error(context: TurnContext, error: Exception):
91
+ # This check writes out errors to console log
92
+ # NOTE: In production environment, you should consider logging this to Azure
93
+ # application insights.
94
+ print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
95
+ traceback.print_exc()
96
+
97
+ # Send a message to the user
98
+ await context.send_activity("The bot encountered an error or bug.")
99
+ ```
100
+
101
+ ## Features
102
+
103
+ ✅ **HTTP hosting** - Full aiohttp integration for web hosting
104
+ ✅ **JWT authentication** - Built-in security with middleware
105
+ ✅ **Agent-to-agent** - Support for multi-agent communication
106
+ ✅ **Streaming** - Real-time response streaming
107
+ ✅ **Error handling** - Comprehensive error management
108
+ ✅ **Development friendly** - Hot reload and debugging support
109
+
110
+ ## Requirements
111
+
112
+ - Python 3.9+
113
+ - aiohttp 3.11.11+
114
+ - Microsoft Agents hosting core library
115
+
116
+ ## Best Practices
117
+
118
+ 1. **Use middleware** for cross-cutting concerns like auth and logging
119
+ 2. **Handle errors gracefully** with custom error handlers
120
+ 3. **Secure your endpoints** with JWT middleware in production
121
+ 4. **Structure routes** logically for agent communication
122
+
123
+ # Quick Links
124
+
125
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
126
+ - 📖 [Complete Documentation](https://aka.ms/agents)
127
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
128
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
129
+
130
+ # Sample Applications
131
+ |Name|Description|README|
132
+ |----|----|----|
133
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
134
+ |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)|
135
+ |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)|
136
+ |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)|
137
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
138
+ |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)|
139
+ |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,5 +1,6 @@
1
1
  LICENSE
2
2
  pyproject.toml
3
+ readme.md
3
4
  setup.py
4
5
  microsoft_agents/hosting/aiohttp/__init__.py
5
6
  microsoft_agents/hosting/aiohttp/_start_agent_process.py
@@ -0,0 +1,2 @@
1
+ microsoft-agents-hosting-core==0.5.0.dev7
2
+ aiohttp>=3.11.11
@@ -6,6 +6,7 @@ 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
11
  license = "MIT"
11
12
  license-files = ["LICENSE"]
@@ -0,0 +1,122 @@
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
+ ## Packages Overview
14
+
15
+ We offer the following PyPI packages to create conversational experiences based on Agents:
16
+
17
+ | Package Name | PyPI Version | Description |
18
+ |--------------|-------------|-------------|
19
+ | `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. |
20
+ | `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. |
21
+ | `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. |
22
+ | `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. |
23
+ | `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. |
24
+ | `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. |
25
+ | `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. |
26
+
27
+ Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
28
+
29
+ | Package Name | PyPI Version | Description |
30
+ |--------------|-------------|-------------|
31
+ | `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 |
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install microsoft-agents-hosting-aiohttp
37
+ ```
38
+
39
+ ## Simple Echo Agent
40
+ See the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) for full working code.
41
+
42
+ ```python
43
+ agents_sdk_config = load_configuration_from_env(environ)
44
+
45
+ STORAGE = MemoryStorage()
46
+ CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)
47
+ ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)
48
+ AUTHORIZATION = Authorization(STORAGE, CONNECTION_MANAGER, **agents_sdk_config)
49
+
50
+ AGENT_APP = AgentApplication[TurnState](
51
+ storage=STORAGE, adapter=ADAPTER, authorization=AUTHORIZATION, **agents_sdk_config
52
+ )
53
+
54
+ @AGENT_APP.activity("message")
55
+ async def on_message(context: TurnContext, state: TurnState):
56
+ await context.send_activity(f"You said: {context.activity.text}")
57
+
58
+ ...
59
+
60
+ start_server(
61
+ agent_application=AGENT_APP,
62
+ auth_configuration=CONNECTION_MANAGER.get_default_connection_configuration(),
63
+ )
64
+ ```
65
+
66
+
67
+ ### Error Handling
68
+
69
+ Customize error responses. Code take from the [Quickstart sample](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart).
70
+
71
+ ```python
72
+ @AGENT_APP.error
73
+ async def on_error(context: TurnContext, error: Exception):
74
+ # This check writes out errors to console log
75
+ # NOTE: In production environment, you should consider logging this to Azure
76
+ # application insights.
77
+ print(f"\n [on_turn_error] unhandled error: {error}", file=sys.stderr)
78
+ traceback.print_exc()
79
+
80
+ # Send a message to the user
81
+ await context.send_activity("The bot encountered an error or bug.")
82
+ ```
83
+
84
+ ## Features
85
+
86
+ ✅ **HTTP hosting** - Full aiohttp integration for web hosting
87
+ ✅ **JWT authentication** - Built-in security with middleware
88
+ ✅ **Agent-to-agent** - Support for multi-agent communication
89
+ ✅ **Streaming** - Real-time response streaming
90
+ ✅ **Error handling** - Comprehensive error management
91
+ ✅ **Development friendly** - Hot reload and debugging support
92
+
93
+ ## Requirements
94
+
95
+ - Python 3.9+
96
+ - aiohttp 3.11.11+
97
+ - Microsoft Agents hosting core library
98
+
99
+ ## Best Practices
100
+
101
+ 1. **Use middleware** for cross-cutting concerns like auth and logging
102
+ 2. **Handle errors gracefully** with custom error handlers
103
+ 3. **Secure your endpoints** with JWT middleware in production
104
+ 4. **Structure routes** logically for agent communication
105
+
106
+ # Quick Links
107
+
108
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
109
+ - 📖 [Complete Documentation](https://aka.ms/agents)
110
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
111
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
112
+
113
+ # Sample Applications
114
+ |Name|Description|README|
115
+ |----|----|----|
116
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
117
+ |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)|
118
+ |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)|
119
+ |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)|
120
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
121
+ |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)|
122
+ |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,15 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: microsoft-agents-hosting-aiohttp
3
- Version: 0.5.0.dev5
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: Operating System :: OS Independent
10
- Requires-Python: >=3.9
11
- License-File: LICENSE
12
- Requires-Dist: microsoft-agents-hosting-core==0.5.0.dev5
13
- Requires-Dist: aiohttp>=3.11.11
14
- Dynamic: license-file
15
- Dynamic: requires-dist
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: microsoft-agents-hosting-aiohttp
3
- Version: 0.5.0.dev5
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: Operating System :: OS Independent
10
- Requires-Python: >=3.9
11
- License-File: LICENSE
12
- Requires-Dist: microsoft-agents-hosting-core==0.5.0.dev5
13
- Requires-Dist: aiohttp>=3.11.11
14
- Dynamic: license-file
15
- Dynamic: requires-dist
@@ -1,2 +0,0 @@
1
- microsoft-agents-hosting-core==0.5.0.dev5
2
- aiohttp>=3.11.11