microsoft-agents-storage-cosmos 0.4.0.dev18__py3-none-any.whl → 0.5.0__py3-none-any.whl

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.
@@ -2,7 +2,7 @@
2
2
  # Licensed under the MIT License.
3
3
 
4
4
  from typing import TypeVar, Union
5
- from threading import Lock
5
+ import asyncio
6
6
 
7
7
  from azure.cosmos import (
8
8
  documents,
@@ -49,7 +49,7 @@ class CosmosDBStorage(AsyncStorageBase):
49
49
  self._container: ContainerProxy = None
50
50
  self._compatability_mode_partition_key: bool = False
51
51
  # Lock used for synchronizing container creation
52
- self._lock: Lock = Lock()
52
+ self._lock: asyncio.Lock = asyncio.Lock()
53
53
 
54
54
  def _create_client(self) -> CosmosClient:
55
55
  if self._config.url:
@@ -164,8 +164,8 @@ class CosmosDBStorage(AsyncStorageBase):
164
164
 
165
165
  async def initialize(self) -> None:
166
166
  if not self._container:
167
- with self._lock:
168
- # in case another thread attempted to initialize just before acquiring the lock
167
+ async with self._lock:
168
+ # in case another async task attempted to initialize just before acquiring the lock
169
169
  if self._container:
170
170
  return
171
171
 
@@ -42,7 +42,8 @@ class CosmosDBStorageConfig:
42
42
  """
43
43
  config_file: str = kwargs.get("filename", "")
44
44
  if config_file:
45
- kwargs = json.load(open(config_file))
45
+ with open(config_file) as f:
46
+ kwargs = json.load(f)
46
47
  self.cosmos_db_endpoint: str = cosmos_db_endpoint or kwargs.get(
47
48
  "cosmos_db_endpoint", ""
48
49
  )
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: microsoft-agents-storage-cosmos
3
+ Version: 0.5.0
4
+ Summary: A Cosmos DB storage library for Microsoft Agents
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: azure-core
20
+ Requires-Dist: azure-cosmos
21
+ Dynamic: license-file
22
+ Dynamic: requires-dist
23
+
24
+ # Microsoft Agents Storage - Cosmos DB
25
+
26
+ [![PyPI version](https://img.shields.io/pypi/v/microsoft-agents-storage-cosmos)](https://pypi.org/project/microsoft-agents-storage-cosmos/)
27
+
28
+ Azure Cosmos DB storage integration for Microsoft 365 Agents SDK. This library provides enterprise-grade persistent storage for conversation state, user data, and custom agent information using Azure Cosmos DB's globally distributed, multi-model database service.
29
+
30
+ This library implements the storage interface for the Microsoft 365 Agents SDK using Azure Cosmos DB as the backend. It provides automatic partitioning, global distribution, and low-latency access to your agent data. Perfect for production deployments requiring high availability, scalability, and multi-region support.
31
+
32
+ # What is this?
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
+ **Why Cosmos DB?**
74
+ - 🌍 Global distribution with multi-region writes
75
+ - ⚡ Single-digit millisecond latency
76
+ - 📈 Automatic and instant scalability
77
+ - 🔄 Multiple consistency models
78
+ - 💪 99.999% availability SLA
79
+
80
+ ## Installation
81
+
82
+ ```bash
83
+ pip install microsoft-agents-storage-cosmos
84
+ ```
85
+
86
+
87
+ ## Environment Setup
88
+
89
+ ### Local Development with Cosmos DB Emulator
90
+
91
+ Install and run the Azure Cosmos DB Emulator for local testing:
92
+
93
+ **Download:** [Azure Cosmos DB Emulator](https://docs.microsoft.com/azure/cosmos-db/local-emulator)
94
+
95
+
96
+ ## Best Practices
97
+
98
+ 1. **Use Managed Identity in Production** - Avoid storing auth keys in code or environment variables
99
+ 2. **Initialize Once** - Call `storage.initialize()` during app startup, not per request
100
+ 3. **Batch Operations** - Read/write multiple items together when possible
101
+ 4. **Monitor RU Consumption** - Use Azure Monitor to track Request Units usage
102
+ 5. **Set Appropriate Throughput** - Start with 400 RU/s, scale up based on metrics
103
+ 6. **Use Session Consistency** - Default consistency level for most scenarios
104
+ 7. **Implement Retry Logic** - Handle transient failures with exponential backoff
105
+ 8. **Partition Wisely** - Current implementation uses `/id` partitioning (automatic)
106
+ 9. **Enable Diagnostics** - Configure Azure diagnostic logs for troubleshooting
107
+ 10. **Test with Emulator** - Use local emulator for development and testing
108
+
109
+ ## Key Classes Reference
110
+
111
+ - **`CosmosDBStorage`** - Main storage implementation using Azure Cosmos DB
112
+ - **`CosmosDBStorageConfig`** - Configuration settings for connection and behavior
113
+ - **`StoreItem`** - Base class for data models (inherit to create custom types)
114
+
115
+ # Quick Links
116
+
117
+ - 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents)
118
+ - 📖 [Complete Documentation](https://aka.ms/agents)
119
+ - 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python)
120
+ - 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues)
121
+
122
+ # Sample Applications
123
+
124
+ |Name|Description|README|
125
+ |----|----|----|
126
+ |Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)|
127
+ |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)|
128
+ |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)|
129
+ |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)|
130
+ |Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)|
131
+ |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)|
132
+ |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,9 @@
1
+ microsoft_agents/storage/cosmos/__init__.py,sha256=2JVNhbohUB-Pm8LmgagHQH3vlEgljpUzbfPhdOS-rCQ,174
2
+ microsoft_agents/storage/cosmos/cosmos_db_storage.py,sha256=yqU51Ji0wceuHKtppa2oQDrBqXI0LFi69OPGDe2mh8o,6529
3
+ microsoft_agents/storage/cosmos/cosmos_db_storage_config.py,sha256=a2-s7Kj5RbYnVU0CyB60dEG501-oRcSXZTQ--_QlISA,4143
4
+ microsoft_agents/storage/cosmos/key_ops.py,sha256=2wnSdSpKzwoCvw4giNn68pBDOa1Gc1jyvEhk2tc_gPQ,1747
5
+ microsoft_agents_storage_cosmos-0.5.0.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
6
+ microsoft_agents_storage_cosmos-0.5.0.dist-info/METADATA,sha256=u1ByfBV70g-7zaj18gdV-jh075E3_5j2db0WpubfAqE,7774
7
+ microsoft_agents_storage_cosmos-0.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ microsoft_agents_storage_cosmos-0.5.0.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
9
+ microsoft_agents_storage_cosmos-0.5.0.dist-info/RECORD,,
@@ -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
@@ -1,14 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: microsoft-agents-storage-cosmos
3
- Version: 0.4.0.dev18
4
- Summary: A Cosmos DB storage library for Microsoft Agents
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.dev18
12
- Requires-Dist: azure-core
13
- Requires-Dist: azure-cosmos
14
- Dynamic: requires-dist
@@ -1,8 +0,0 @@
1
- microsoft_agents/storage/cosmos/__init__.py,sha256=2JVNhbohUB-Pm8LmgagHQH3vlEgljpUzbfPhdOS-rCQ,174
2
- microsoft_agents/storage/cosmos/cosmos_db_storage.py,sha256=jcyLaaGtnvbjAjjVoNygQQy96Qhj9a8wURU50XVMHUk,6515
3
- microsoft_agents/storage/cosmos/cosmos_db_storage_config.py,sha256=JS2dQnwCjR1XfEIeJnQGJHhMwxeBmUNwWANqRte10N4,4114
4
- microsoft_agents/storage/cosmos/key_ops.py,sha256=2wnSdSpKzwoCvw4giNn68pBDOa1Gc1jyvEhk2tc_gPQ,1747
5
- microsoft_agents_storage_cosmos-0.4.0.dev18.dist-info/METADATA,sha256=-oz1aTexCX_Nrcj-QEEN3JQvwtp791BBpqy9tpZpH_U,532
6
- microsoft_agents_storage_cosmos-0.4.0.dev18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- microsoft_agents_storage_cosmos-0.4.0.dev18.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
8
- microsoft_agents_storage_cosmos-0.4.0.dev18.dist-info/RECORD,,