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.
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
AgentSessionalready represents that conversation continuity, allow the delegated Foundry user identity to be attached when theAgentSessionis 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:
Subsequent calls that reuse this
AgentSessionshould send the stored user identity without requiring per-runChatOptions.Expected behavior
AgentSessionstate so it survives serialization.x-ms-user-identityautomatically on every run that uses the session.AgentSessioninstances, even when they share one Foundryagent_session_id.Related discussion: #8227.