BetaAgentsOperations Class
Warning
DO NOT instantiate this class directly.
Instead, you should access the following operations through
<xref:beta.agents> attribute.
Constructor
BetaAgentsOperations(*args, **kwargs)
Methods
| create_session |
Creates a new session for an agent endpoint. The endpoint resolves the backing agent version
from |
| delete_session |
Deletes a session synchronously. Returns 204 No Content when the session is deleted or does not exist. |
| delete_session_file |
Delete a file or directory from the session sandbox. If |
| download_session_file |
Download a file from the session sandbox as a binary stream. |
| get_session |
Retrieves a session by ID. |
| get_session_files |
List files and directories at a given path in the session sandbox. Returns only the immediate children of the specified directory (non-recursive). |
| get_session_log_stream |
Streams console logs (stdout / stderr) for a specific hosted agent session as a Server-Sent Events (SSE) stream. Each SSE frame contains:
Example SSE frames:
The stream remains open until the client disconnects or the server terminates the connection. Clients should handle reconnection as needed. |
| list_sessions |
Returns a list of sessions for the specified agent. |
| patch_agent_details |
Updates an agent endpoint. |
| upload_session_file |
Upload a file to the session sandbox. Accepts either a |
create_session
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.
async create_session(agent_name: str, body: ~collections.abc.MutableMapping[str, ~typing.Any] | ~typing.IO[bytes] = <object object>, *, isolation_key: str, version_indicator: ~azure.ai.projects.models._models.VersionIndicator = <object object>, agent_session_id: str | None = None, **kwargs: ~typing.Any) -> AgentSessionResource
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent to create a session for. Required. |
|
body
|
Is either a JSON type or a IO[bytes] type. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
isolation_key
|
Isolation key used by the agent endpoint to enforce session ownership for session-mutating operations. Required. |
|
version_indicator
|
Determines which agent version backs the session. Required. Default value: <object object at 0x00000210BA37F9C0>
|
|
agent_session_id
|
Optional caller-provided session ID. If specified, it must be unique within the agent endpoint. Auto-generated if omitted. Default value is None. Default value: None
|
Returns
| Type | Description |
|---|---|
|
AgentSessionResource. The AgentSessionResource is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
delete_session
Deletes a session synchronously. Returns 204 No Content when the session is deleted or does not exist.
async delete_session(agent_name: str, session_id: str, *, isolation_key: str, **kwargs: Any) -> None
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent. Required. |
|
session_id
Required
|
The session identifier. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
isolation_key
|
Isolation key used by the agent endpoint to enforce session ownership for session-mutating operations. Required. |
Returns
| Type | Description |
|---|---|
|
None |
Exceptions
| Type | Description |
|---|---|
delete_session_file
Delete a file or directory from the session sandbox. If recursive is false (default) and
the target is a non-empty directory, the API returns 409 Conflict.
async delete_session_file(agent_name: str, agent_session_id: str, *, path: str, recursive: bool | None = None, **kwargs: Any) -> None
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent. Required. |
|
agent_session_id
Required
|
The session ID. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
path
|
The file or directory path to delete, relative to the session home directory. Required. |
|
recursive
|
Whether to recursively delete directory contents. Defaults to false. Default value is None. Default value: None
|
Returns
| Type | Description |
|---|---|
|
None |
Exceptions
| Type | Description |
|---|---|
download_session_file
Download a file from the session sandbox as a binary stream.
async download_session_file(agent_name: str, agent_session_id: str, *, path: str, **kwargs: Any) -> AsyncIterator[bytes]
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent. Required. |
|
agent_session_id
Required
|
The session ID. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
path
|
The file path to download from the sandbox, relative to the session home directory. Required. |
Returns
| Type | Description |
|---|---|
|
AsyncIterator[bytes] |
Exceptions
| Type | Description |
|---|---|
get_session
Retrieves a session by ID.
async get_session(agent_name: str, session_id: str, **kwargs: Any) -> AgentSessionResource
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent. Required. |
|
session_id
Required
|
The session identifier. Required. |
Returns
| Type | Description |
|---|---|
|
AgentSessionResource. The AgentSessionResource is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
get_session_files
List files and directories at a given path in the session sandbox. Returns only the immediate children of the specified directory (non-recursive).
async get_session_files(agent_name: str, agent_session_id: str, *, path: str, **kwargs: Any) -> SessionDirectoryListResponse
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent. Required. |
|
agent_session_id
Required
|
The session ID. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
path
|
The directory path to list, relative to the session home directory. Required. |
Returns
| Type | Description |
|---|---|
|
SessionDirectoryListResponse. The SessionDirectoryListResponse is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
get_session_log_stream
Streams console logs (stdout / stderr) for a specific hosted agent session as a Server-Sent Events (SSE) stream.
Each SSE frame contains:
event: always "log"
data: a plain-text log line (currently JSON-formatted, but the schema is not contractual and may include additional keys or change format over time; clients should treat it as an opaque string)
Example SSE frames:
event: log
data: {"timestamp":"2026-03-10T09:33:17.121Z","stream":"stdout","message":"Starting FoundryCBAgent server on port 8088"}
event: log
data: {"timestamp":"2026-03-10T09:33:17.130Z","stream":"stderr","message":"INFO: Application startup complete."}
event: log
data: {"timestamp":"2026-03-10T09:34:52.714Z","stream":"status","message":"Successfully connected to container"}
event: log
data: {"timestamp":"2026-03-10T09:35:52.714Z","stream":"status","message":"No logs since last 60 seconds"}
The stream remains open until the client disconnects or the server terminates the connection. Clients should handle reconnection as needed.
async get_session_log_stream(agent_name: str, agent_version: str, session_id: str, **kwargs: Any) -> SessionLogEvent
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the hosted agent. Required. |
|
agent_version
Required
|
The version of the agent. Required. |
|
session_id
Required
|
The session ID (maps to an ADC sandbox). Required. |
Returns
| Type | Description |
|---|---|
|
SessionLogEvent. The SessionLogEvent is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
list_sessions
Returns a list of sessions for the specified agent.
list_sessions(agent_name: str, *, limit: int | None = None, order: str | PageOrder | None = None, before: str | None = None, **kwargs: Any) -> AsyncItemPaged[AgentSessionResource]
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
limit
|
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Default value is None. Default value: None
|
|
order
|
Sort order by the Default value: None
|
|
before
|
A cursor for use in pagination. Default value: None
|
Returns
| Type | Description |
|---|---|
|
An iterator like instance of AgentSessionResource |
Exceptions
| Type | Description |
|---|---|
patch_agent_details
Updates an agent endpoint.
async patch_agent_details(agent_name: str, body: ~collections.abc.MutableMapping[str, ~typing.Any] | ~typing.IO[bytes] = <object object>, *, agent_endpoint: ~azure.ai.projects.models._models.AgentEndpoint | None = None, agent_card: ~azure.ai.projects.models._models.AgentCard | None = None, **kwargs: ~typing.Any) -> AgentDetails
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent to retrieve. Required. |
|
body
|
Is either a JSON type or a IO[bytes] type. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
agent_endpoint
|
The endpoint configuration for the agent. Default value is None. Default value: None
|
|
agent_card
|
Optional agent card for the agent. Default value is None. Default value: None
|
Returns
| Type | Description |
|---|---|
|
AgentDetails. The AgentDetails is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
upload_session_file
Upload a file to the session sandbox.
Accepts either a bytes buffer or a local file path (str).
When a file path is provided the file is read from disk and its contents
are forwarded to the service. Maximum file size is 50 MB. Uploads
exceeding this limit return 413 Payload Too Large.
async upload_session_file(agent_name: str, session_id: str, content_or_file_path: bytes | str, *, path: str, **kwargs: Any) -> SessionFileWriteResponse
Parameters
| Name | Description |
|---|---|
|
agent_name
Required
|
The name of the agent. Required. |
|
session_id
Required
|
The session ID. Required. |
|
content_or_file_path
Required
|
The binary content to upload, or the full path to a local file whose contents should be uploaded. Required. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
path
|
The destination file path within the sandbox, relative to the session home directory. Required. |
Returns
| Type | Description |
|---|---|
|
SessionFileWriteResponse. The SessionFileWriteResponse is compatible with MutableMapping |
Exceptions
| Type | Description |
|---|---|
|
If content_or_file_path is a |