Skip to content

Commit e694f9b

Browse files
committed
chore(hosting): merge main session store changes
Keep the shared .NET session store from main, which already preserves composite identity boundaries. Remove superseded PR-only .NET tests and retain the Python session harness changes. Include upstream CI test fixes without rewriting contributor history. Refs #8251
2 parents 1c07b20 + d341515 commit e694f9b

204 files changed

Lines changed: 17249 additions & 3158 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/python-integration-tests.yml‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,55 @@ jobs:
8484
path: ./python/pytest.xml
8585
if-no-files-found: ignore
8686

87+
# MongoDB tests use the official disposable Atlas Local image and need no cloud credentials.
88+
python-tests-mongodb:
89+
name: Python Integration Tests - MongoDB
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 15
92+
permissions:
93+
contents: read
94+
services:
95+
mongodb:
96+
image: mongodb/mongodb-atlas-local@sha256:82da14850e350f15aae720ebba130ade6a607335877486a63252b3ad8ef3b12a
97+
ports:
98+
- 27017:27017
99+
env:
100+
MONGODB_TEST_URI: "mongodb://localhost:27017/?directConnection=true"
101+
MONGODB_TEST_DATABASE: af_vectors_test
102+
defaults:
103+
run:
104+
working-directory: python
105+
steps:
106+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
107+
with:
108+
ref: ${{ inputs.checkout-ref }}
109+
persist-credentials: false
110+
- name: Set up python and install the project
111+
uses: ./.github/actions/python-setup
112+
with:
113+
python-version: ${{ env.UV_PYTHON }}
114+
os: ${{ runner.os }}
115+
- name: Test MongoDB integration
116+
run: >
117+
uv run --directory packages/mongodb poe test-integration
118+
--junitxml=${{ github.workspace }}/python/pytest-mongodb.xml
119+
- name: Surface failing tests
120+
if: always()
121+
uses: pmeier/pytest-results-action@fdc7f18d9934e38aca411ca9557e6577bd25ca9c # v0.9.0
122+
with:
123+
path: ./python/pytest-mongodb.xml
124+
summary: true
125+
display-options: fEX
126+
fail-on-empty: false
127+
title: MongoDB integration test results
128+
- name: Upload test results
129+
if: always()
130+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
131+
with:
132+
name: test-results-mongodb
133+
path: ./python/pytest-mongodb.xml
134+
if-no-files-found: ignore
135+
87136
# Unit tests: all non-integration tests across all packages
88137
python-tests-unit:
89138
name: Python Integration Tests - Unit
@@ -630,6 +679,7 @@ jobs:
630679
python-tests-foundry-hosting,
631680
python-tests-cosmos,
632681
python-tests-qdrant,
682+
python-tests-mongodb,
633683
python-tests-github-copilot,
634684
python-tests-postgres,
635685
python-tests-redis,
@@ -697,6 +747,7 @@ jobs:
697747
python-tests-foundry-hosting,
698748
python-tests-cosmos,
699749
python-tests-qdrant,
750+
python-tests-mongodb,
700751
python-tests-github-copilot,
701752
python-tests-postgres,
702753
python-tests-redis,

‎.github/workflows/python-merge-tests.yml‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
foundryHostingChanged: ${{ steps.filter.outputs.foundry_hosting }}
4141
cosmosChanged: ${{ steps.filter.outputs.cosmos }}
4242
qdrantChanged: ${{ steps.filter.outputs.qdrant }}
43+
mongodbChanged: ${{ steps.filter.outputs.mongodb }}
4344
redisChanged: ${{ steps.filter.outputs.redis }}
4445
githubCopilotChanged: ${{ steps.filter.outputs.github_copilot }}
4546
postgresChanged: ${{ steps.filter.outputs.postgres }}
@@ -91,6 +92,10 @@ jobs:
9192
- 'python/packages/qdrant/**'
9293
- '.github/workflows/python-merge-tests.yml'
9394
- '.github/workflows/python-integration-tests.yml'
95+
mongodb:
96+
- 'python/packages/mongodb/**'
97+
- '.github/workflows/python-merge-tests.yml'
98+
- '.github/workflows/python-integration-tests.yml'
9499
redis:
95100
- 'python/packages/redis/**'
96101
- 'python/packages/core/agent_framework/redis/**'
@@ -159,6 +164,60 @@ jobs:
159164
path: ./python/pytest.xml
160165
if-no-files-found: ignore
161166

167+
# MongoDB tests use the official disposable Atlas Local image and need no cloud credentials.
168+
python-tests-mongodb:
169+
name: Python Integration Tests - MongoDB
170+
needs: paths-filter
171+
if: >
172+
needs.paths-filter.outputs.pythonChanges == 'true' &&
173+
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' ||
174+
needs.paths-filter.outputs.mongodbChanged == 'true' ||
175+
needs.paths-filter.outputs.coreChanged == 'true')
176+
runs-on: ubuntu-latest
177+
timeout-minutes: 15
178+
permissions:
179+
contents: read
180+
services:
181+
mongodb:
182+
image: mongodb/mongodb-atlas-local@sha256:82da14850e350f15aae720ebba130ade6a607335877486a63252b3ad8ef3b12a
183+
ports:
184+
- 27017:27017
185+
env:
186+
MONGODB_TEST_URI: "mongodb://localhost:27017/?directConnection=true"
187+
MONGODB_TEST_DATABASE: af_vectors_test
188+
defaults:
189+
run:
190+
working-directory: python
191+
steps:
192+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
193+
with:
194+
persist-credentials: false
195+
- name: Set up python and install the project
196+
uses: ./.github/actions/python-setup
197+
with:
198+
python-version: ${{ env.UV_PYTHON }}
199+
os: ${{ runner.os }}
200+
- name: Test MongoDB integration
201+
run: >
202+
uv run --directory packages/mongodb poe test-integration
203+
--junitxml=${{ github.workspace }}/python/pytest-mongodb.xml
204+
- name: Surface failing tests
205+
if: always()
206+
uses: pmeier/pytest-results-action@fdc7f18d9934e38aca411ca9557e6577bd25ca9c # v0.9.0
207+
with:
208+
path: ./python/pytest-mongodb.xml
209+
summary: true
210+
display-options: fEX
211+
fail-on-empty: false
212+
title: MongoDB integration test results
213+
- name: Upload test results
214+
if: always()
215+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
216+
with:
217+
name: test-results-mongodb
218+
path: ./python/pytest-mongodb.xml
219+
if-no-files-found: ignore
220+
162221
# Unit tests: always run all non-integration tests across all packages
163222
python-tests-unit:
164223
name: Python Tests - Unit
@@ -831,6 +890,7 @@ jobs:
831890
python-tests-foundry-hosting,
832891
python-tests-cosmos,
833892
python-tests-qdrant,
893+
python-tests-mongodb,
834894
python-tests-github-copilot,
835895
python-tests-postgres,
836896
python-tests-redis,
@@ -895,6 +955,7 @@ jobs:
895955
python-tests-foundry-hosting,
896956
python-tests-cosmos,
897957
python-tests-qdrant,
958+
python-tests-mongodb,
898959
python-tests-github-copilot,
899960
python-tests-postgres,
900961
python-tests-redis,

‎docs/decisions/0031-hosted-per-user-session-storage-isolation.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ Negative:
101101
- Encryption at rest and quota enforcement remain platform concerns.
102102
- Non-Foundry hosting layers can adopt an equivalent scheme independently.
103103

104+
## Update (2026-09-01): contract promoted to Abstractions
105+
106+
[ADR-0039](0039-shared-agent-session-store.md) promotes this `AgentSessionStore` contract to
107+
`Microsoft.Agents.AI.Abstractions` and makes it the common contract for Foundry Hosting and conventional
108+
Hosting. It supersedes the required `userId` parameter with `AgentSessionStoreKey.Partitions`. Foundry
109+
Hosting adds the resolved user identity as a named partition before loading or saving a session.
110+
104111
## Update (2026-07-01): local runs no longer fail closed; sample dev provider removed
105112

106113
Superseding the ADR-0026/0030 behavior where a `null` result from `HostedSessionIsolationKeyProvider`

‎docs/decisions/0032-dotnet-hosting-protocol-helpers.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ informed: []
1111

1212
Realizes the helper-first direction of [ADR-0027](0027-hosting-channels.md) for .NET.
1313

14+
> **Update (2026-09-01):** [ADR-0039](0039-shared-agent-session-store.md) supersedes the
15+
> `AgentSessionStore` portion of this decision. The protocol helper and workflow decisions remain accepted.
16+
1417
## Context and Problem Statement
1518

1619
[ADR-0027](0027-hosting-channels.md) refocused the (Python) hosting design away from a channel
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
status: proposed
3+
contact: rogerbarreto
4+
date: 2026-09-01
5+
deciders: rogerbarreto
6+
consulted: []
7+
informed: []
8+
---
9+
10+
# Shared AgentSessionStore abstraction
11+
12+
## Context and Problem Statement
13+
14+
.NET has two public `AgentSessionStore` abstract classes. `Microsoft.Agents.AI.Hosting` defines a store
15+
whose lookup creates a session when no value exists. `Microsoft.Agents.AI.Foundry.Hosting` defines a store
16+
whose lookup returns `null`, accepts an explicit user partition, and provides a separate convenience method
17+
that creates a session when needed. The types cannot be used interchangeably, so storage integrations depend
18+
on a specific hosting protocol package instead of the core agent abstractions.
19+
20+
## Decision Drivers
21+
22+
- One storage contract must work across all hosting packages.
23+
- Storage implementations must depend only on `Microsoft.Agents.AI.Abstractions`.
24+
- A lookup must distinguish a missing value from a stored value without creating state as a side effect.
25+
- The contract must support any number of isolation dimensions without privileging user identity.
26+
- Existing Foundry storage behavior and per-user isolation must remain unchanged.
27+
28+
## Considered Options
29+
30+
1. Promote the Foundry Hosting contract to `Microsoft.Agents.AI.Abstractions`.
31+
2. Promote the conventional Hosting contract and adapt Foundry Hosting to it.
32+
3. Add a third contract and keep adapters for both existing contracts.
33+
4. Represent session identity as an immutable key with arbitrary named partitions.
34+
35+
## Decision Outcome
36+
37+
Chosen option: **Promote the Foundry Hosting contract to `Microsoft.Agents.AI.Abstractions`**.
38+
39+
`AgentSessionStore` moves to the `Microsoft.Agents.AI` namespace and keeps the Foundry Hosting behavior:
40+
41+
- The abstraction and every public implementation start as experimental under diagnostic `MAAI001`.
42+
- `GetSessionAsync` returns `AgentSession?` and returns `null` when no session is stored.
43+
- `GetOrCreateSessionAsync` performs the explicit lookup or creation operation.
44+
- `SaveSessionAsync` and both lookup methods receive an `AgentSessionStoreKey`.
45+
- `AgentSessionStoreKey.SessionId` identifies the logical session.
46+
- `AgentSessionStoreKey.Partitions` holds zero or more named isolation dimensions. Every partition is
47+
part of identity and implementations cannot ignore unknown partitions.
48+
- Keys without partitions expose `Partitions = null`, avoiding dictionary allocations. Omitted, null,
49+
and empty constructor inputs all represent the same unpartitioned identity.
50+
- Partition order does not affect identity. Physical encoding remains the responsibility of each store.
51+
- `GetService(Type, object?)` and `GetService<TService>(object?)` retain service discovery from conventional
52+
Hosting. Stores can expose themselves, underlying implementations, or additional capabilities.
53+
- `DeleteSessionAsync` is not part of the shared contract.
54+
55+
The duplicate types in `Microsoft.Agents.AI.Hosting` and `Microsoft.Agents.AI.Foundry.Hosting` are removed.
56+
Both packages reference the shared type directly.
57+
58+
`DelegatingAgentSessionStore` lives in the `Microsoft.Agents.AI` package beside `ChatClientAgent`, providing
59+
the common decorator base without requiring a hosting-protocol package. Its service queries check the
60+
outer instance first, then forward to the inner store. Hosting registration uses this discovery to
61+
recognize existing isolation even when other decorators surround it, avoiding a second isolation wrapper.
62+
63+
The conventional Hosting implementations adopt the same behavior. `IsolationKeyScopedAgentSessionStore`
64+
adds the value from `AgentIsolationKeyProvider` under the `isolation` partition while preserving existing
65+
partitions. Protocol-specific hosting can add named partitions such as `user`, `tenant`, or `chat` before
66+
loading the session. `AIHostAgent` uses `GetOrCreateSessionAsync` when it needs a ready session.
67+
68+
Azure Blob Storage, filesystem storage, and Foundry State Store each encode the session id and every
69+
partition into their own collision-safe physical key. Version 1 Azure
70+
Blob keys are not read because the package is still preview and the previous format cannot distinguish
71+
all partition combinations safely.
72+
73+
Provider-specific metadata does not belong in `AgentSessionStoreKey`. For example, Foundry item tags can
74+
be exposed by an overload or options type on `FoundryAgentSessionStore` without adding tags to Abstractions.
75+
76+
## Consequences
77+
78+
Positive:
79+
80+
- Storage implementations can be shared by Foundry Hosting, conventional Hosting, and future protocols.
81+
- Missing session handling is explicit and consistent.
82+
- Isolation dimensions are explicit, composable, and independent from any hosting protocol.
83+
- `Microsoft.Agents.AI.Abstractions` owns the contract alongside `AIAgent` and `AgentSession`.
84+
85+
Negative:
86+
87+
- This is a source-breaking change for implementations of the preview Hosting contract.
88+
- Callers must construct an `AgentSessionStoreKey`; unpartitioned sessions use only `SessionId`.
89+
- Consumers that need deletion must use a storage-specific API until a separate shared deletion capability is defined.
90+
91+
## More Information
92+
93+
- [ADR-0031](0031-hosted-per-user-session-storage-isolation.md) records the earlier Foundry-specific user partition.
94+
- [ADR-0032](0032-dotnet-hosting-protocol-helpers.md) records the previous conventional Hosting contract.

0 commit comments

Comments
 (0)