Skip to content

.NET: Preserve hosted session key boundaries - #8263

Open
Ricky-7-Yan wants to merge 1 commit into
microsoft:mainfrom
Ricky-7-Yan:issue-8251-composite-session-keys
Open

.NET: Preserve hosted session key boundaries#8263
Ricky-7-Yan wants to merge 1 commit into
microsoft:mainfrom
Ricky-7-Yan:issue-8251-composite-session-keys

Conversation

@Ricky-7-Yan

Copy link
Copy Markdown
Contributor

Motivation & Context

Hosted session stores must preserve the boundaries between agent, user, and conversation identifiers. Delimiter-based string keys allow distinct identifier tuples containing : to collapse to the same cache entry, which can mix session state across requests.

Description & Review Guide

  • What are the major changes? Python Invocations hosting now serializes hosted session/user identifiers as a compact JSON array, including the standalone break-glass example. The .NET Foundry in-memory store now uses a strongly typed composite key. Focused regression tests cover distinct colliding tuples and repeated-request continuity.
  • What is the impact of these changes? Distinct hosted identifier combinations remain isolated while existing local-mode keys and same-tuple session reuse stay unchanged.
  • What do you want reviewers to focus on? Please review the hosted key representation and the compatibility of null/empty agent and user components in the .NET store.

Related Issue

Fixes #8251

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Signed-off-by: Ricky-7-Yan <2314530442@qq.com>
Copilot AI balanced review requested due to automatic review settings September 10, 2026 16:49
@agent-framework-automation agent-framework-automation Bot added python Usage: [Issues, PRs], Target: Python .NET Usage: [Issues, PRs], Target: .Net labels Sep 10, 2026
@github-actions github-actions Bot changed the title .NET & Python: Preserve hosted session key boundaries Python: .NET & Python: Preserve hosted session key boundaries Sep 10, 2026
@github-actions github-actions Bot changed the title Python: .NET & Python: Preserve hosted session key boundaries .NET: .NET & Python: Preserve hosted session key boundaries Sep 10, 2026
@Ricky-7-Yan
Ricky-7-Yan marked this pull request as ready for review September 10, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementations preserve identifier boundaries and existing null, empty, and local-mode behavior with focused regression coverage.

Pull request overview

Preserves hosted session isolation by replacing ambiguous delimiter-based keys with boundary-safe representations.

Changes:

  • Serializes Python hosted identifiers as compact JSON arrays.
  • Uses a typed composite key for the .NET in-memory store.
  • Adds regression tests for collision isolation and session continuity.
File summaries
File Description
python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/main.py Updates the sample’s hosted session key format.
python/packages/foundry_hosting/tests/test_invocations.py Tests collision isolation and repeated-session reuse.
python/packages/foundry_hosting/agent_framework_foundry_hosting/_invocations.py Generates unambiguous hosted partition keys.
dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/InMemoryAgentSessionStoreTests.cs Verifies composite identifier boundaries.
dotnet/src/Microsoft.Agents.AI.Foundry.Hosting/InMemoryAgentSessionStore.cs Replaces concatenated keys with a typed record key.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@Ricky-7-Yan Ricky-7-Yan changed the title .NET: .NET & Python: Preserve hosted session key boundaries .NET: Preserve hosted session key boundaries Sep 10, 2026

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

(to other reviewers, I've only reviewed the dotnet side of things)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Hosted session harness: preserve composite identifier boundaries

3 participants