Share via


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, string isolationKey, Azure.AI.Projects.Agents.VersionIndicator versionIndicator, string agentSessionId = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateSessionAsync : string * string * Azure.AI.Projects.Agents.VersionIndicator * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.Agents.ProjectAgentSession>>
override this.CreateSessionAsync : string * string * Azure.AI.Projects.Agents.VersionIndicator * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.ClientModel.ClientResult<Azure.AI.Projects.Agents.ProjectAgentSession>>
Public Overridable Function CreateSessionAsync (agentName As String, isolationKey As String, versionIndicator As VersionIndicator, Optional agentSessionId 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.

isolationKey
String

Isolation key used by the agent endpoint to enforce session ownership for session-mutating operations.

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.

cancellationToken
CancellationToken

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

Returns

Exceptions

agentName, isolationKey or versionIndicator is null.

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

Service returned a non-success status code.

Applies to