Skip to content

Commit f852551

Browse files
fix cross partition query
1 parent 659314a commit f852551

3 files changed

Lines changed: 489 additions & 458 deletions

File tree

python/packages/azure-cosmos/agent_framework_azure_cosmos/_history_provider.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ async def list_sessions(self) -> list[str]:
211211
parameters: list[dict[str, object]] = [
212212
{"name": "@source_id", "value": self.source_id}
213213
]
214-
items = self._container_proxy.query_items( # type: ignore[union-attr]
215-
query=query, parameters=parameters, enable_cross_partition_query=True
216-
)
214+
# without a partition key, it is automatically a cross-partition query
215+
items = self._container_proxy.query_items(query=query, parameters=parameters) # type: ignore[union-attr]
217216

218217
session_ids: set[str] = set()
219218
async for item in items:

python/packages/azure-cosmos/tests/test_cosmos_history_provider.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@
99
from typing import Any
1010
from unittest.mock import AsyncMock, MagicMock, patch
1111

12+
import agent_framework_azure_cosmos._history_provider as history_provider_module
1213
import pytest
1314
from agent_framework import AgentResponse, Message
1415
from agent_framework._sessions import AgentSession, SessionContext
1516
from agent_framework.exceptions import SettingNotFoundError
17+
from agent_framework_azure_cosmos._history_provider import CosmosHistoryProvider
1618
from azure.cosmos.aio import CosmosClient
1719
from azure.cosmos.exceptions import CosmosResourceNotFoundError
1820

19-
import agent_framework_azure_cosmos._history_provider as history_provider_module
20-
from agent_framework_azure_cosmos._history_provider import CosmosHistoryProvider
21-
22-
2321
skip_if_cosmos_integration_tests_disabled = pytest.mark.skipif(
2422
any(
2523
os.getenv(name, "") == ""
@@ -209,7 +207,6 @@ async def test_list_sessions_returns_unique_sorted_ids(self, mock_container: Mag
209207
kwargs = mock_container.query_items.call_args.kwargs
210208
assert kwargs["query"] == "SELECT DISTINCT VALUE c.session_id FROM c WHERE c.source_id = @source_id"
211209
assert kwargs["parameters"] == [{"name": "@source_id", "value": "mem"}]
212-
assert kwargs["enable_cross_partition_query"] is True
213210

214211

215212
class TestCosmosHistoryProviderSaveMessages:

0 commit comments

Comments
 (0)