You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Bug]: CosmosHistoryProvider generates an orphan GUID for empty session_id #9975
CosmosHistoryProvider._session_partition_key generates a fresh random GUID on every call when session_id is None/empty. Because save_messages, get_messages, and clear each call it independently, saving with an empty session id writes to one partition while later reads/clears target different partitions. The stored messages become silently unreachable (orphaned) and can never be listed or cleared.
Expected Behavior
A missing/empty session_id should raise ValueError, aligning with the Redis (scoped) and VectorStore providers, instead of silently writing orphaned data.
Steps to Reproduce
Configure CosmosHistoryProvider.
Save messages with an empty session_id.
Attempt to read/clear with the same empty session_id.
Minimal Reproduction
# save_messages(session_id=None, ...) writes to partition A# get_messages(session_id=None, ...) reads from partition B -> empty
🤖 Automated triage reproduction notes(agent-authored — trust but verify)
Agent analysis
The bug occurs in python/packages/azure-cosmos/agent_framework_azure_cosmos/_history_provider.py::_session_partition_key at lines 301-311 when session_id is None or empty. save_messages, get_messages, and clear independently generate different partition GUIDs. Minimal repro: construct the provider with a mocked container and assert that get_messages(None) and get_messages("") raise ValueError; both currently proceed and log generated GUIDs.
The existing pinned test test_none_session_id_generates_guid_partition_key explicitly asserts the generated key != "default" — a shared default partition is already encoded as not-the-intended-direction for Cosmos; what is left undecided is what empty-id writes should do. Rejecting closes the read/write incoherence described here (durable RU-billed writes to a partition no later call can ever address).
Activity
github-actions commentedon Nov 2, 2026
🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
The bug occurs in
python/packages/azure-cosmos/agent_framework_azure_cosmos/_history_provider.py::_session_partition_keyat lines 301-311 whensession_idisNoneor empty.save_messages,get_messages, andclearindependently generate different partition GUIDs. Minimal repro: construct the provider with a mocked container and assert thatget_messages(None)andget_messages("")raiseValueError; both currently proceed and log generated GUIDs.python/packages/azure-cosmos/tests/test_cosmos_history_provider.py1.0.0b261030Wilson0511 commentedon Nov 9, 2026
Cross-referencing the sibling census while this awaits triage — the data supports the proposed
ValueErrordirection:session_idbehaviorInMemoryHistoryProvidersession_identirely (state-keyed)FileHistoryProvider_session_file_stem:session_id or DEFAULT_SESSION_FILE_STEM)_redis_key:session_id or 'default')ValueError("session_id must be a non-empty string...")VectorStoreHistoryProvider_validate_session_id("must be a non-empty string")CosmosHistoryProviderTwo notes for the decision:
ValueErroraligns with where the family has converged.test_none_session_id_generates_guid_partition_keyexplicitly asserts the generated key!= "default"— a shared default partition is already encoded as not-the-intended-direction for Cosmos; what is left undecided is what empty-id writes should do. Rejecting closes the read/write incoherence described here (durable RU-billed writes to a partition no later call can ever address).