AgentAdministrationClient.CreateSessionAsync Method

Definition

Creates a new session for an agent endpoint. The endpoint resolves the backing agent version from version_indicator and enforces session ownership using the provided isolation key for session-mutating operations.

public virtual System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.Agents.ProjectAgentSession>> CreateSessionAsync(string agentName, Azure.AI.Projects.Agents.VersionIndicator versionIndicator, string agentSessionId = default, string userIsolationKey = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateSessionAsync : string * Azure.AI.Projects.Agents.VersionIndicator * string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.Agents.ProjectAgentSession>>
override this.CreateSessionAsync : string * Azure.AI.Projects.Agents.VersionIndicator * string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.Agents.ProjectAgentSession>>
Public Overridable Function CreateSessionAsync (agentName As String, versionIndicator As VersionIndicator, Optional agentSessionId As String = Nothing, Optional userIsolationKey As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ClientResult(Of ProjectAgentSession))

Parameters

agentName
String

The name of the agent to create a session for.

versionIndicator
VersionIndicator

Determines which agent version backs the session.

agentSessionId
String

Optional caller-provided session ID. If specified, it must be unique within the agent endpoint. Auto-generated if omitted.

userIsolationKey
String

Opaque per-user isolation key used to scope endpoint-scoped data (responses, conversations, sessions) to a specific end user.

cancellationToken
CancellationToken

The cancellation token that can be used to cancel the operation.

Returns

Exceptions

agentName or versionIndicator is null.

agentName is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Applies to