Skip to content

.NET: Make Foundry delegated user identity sticky on AgentSession #8291

Description

Description

Foundry hosted user identity is currently supplied for every run through ChatOptions.WithFoundryHostedAgentUserIdentity(...).

A Responses conversation created for one delegated user cannot be continued by another delegated user, even when both users share the same Foundry hosted session. Because an Agent Framework AgentSession already represents that conversation continuity, allow the delegated Foundry user identity to be attached when the AgentSession is created and reused automatically on later runs.

Proposed experience

Extend the Foundry hosted session creation API so an application can provide both the hosted session identifier and delegated user identity once:

ChatClientAgentSession session = await agent.CreateFoundryHostedAgentSessionAsync(
    hostedSessionId: hostedSessionId,
    userIdentity: userId);

Subsequent calls that reuse this AgentSession should send the stored user identity without requiring per-run ChatOptions.

Expected behavior

  • Store the delegated user identity in the AgentSession state so it survives serialization.
  • Send x-ms-user-identity automatically on every run that uses the session.
  • Reject a conflicting per-run user identity instead of silently changing the identity associated with the conversation.
  • Preserve the existing per-run API for callers that do not want session-sticky identity.
  • Document that separate users require separate AgentSession instances, even when they share one Foundry agent_session_id.
  • Add unit and live integration coverage for serialization, automatic reuse, and conflict handling.

Related discussion: #8227.

Activity

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

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .Net

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions