Skip to main content

agents

Creates, updates, deletes, gets or lists an agents resource.

Overview

Nameagents
TypeResource
Idazure.ai_projects.agents

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
datastringThe event payload as plain text. Currently JSON-formatted but the schema is not contractual and may change. Required.
eventstringThe SSE event type. Currently log, but additional event types may be added in the future. Clients should ignore unrecognized event types. Required. "log" (log)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_session_log_streamselectagent_name, agent_version, session_id, endpointStream console logs for a hosted agent session. 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: .. code-block:: 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.
list_session_filesselectagent_name, agent_session_id, endpointpath, limit, order, after, beforeList session files. Returns files and directories at the specified path in the session sandbox. The response includes only the immediate children of the target directory and defaults to the session home directory when no path is supplied.
get_versionselectagent_name, agent_version, endpointGet an agent version. Retrieves the specified version of an agent by its agent name and version identifier.
get_sessionselectagent_name, session_id, endpointGet a session. Retrieves the details of a hosted agent session by agent name and session identifier.
getselectagent_name, endpointGet an agent. Retrieves an agent definition by its unique name.
listselectendpointkind, limit, order, after, beforeList agents. Returns a paged collection of agent resources.
deletedeleteagent_name, endpointforceDelete an agent. Deletes an agent. For hosted agents, if any version has active sessions, the request is rejected with HTTP 409 unless force is set to true. When force is true, all associated sessions are cascade-deleted along with the agent and its versions.
update_detailsexecagent_name, endpointUpdate an agent endpoint. Applies a merge-patch update to the specified agent endpoint configuration.
list_versionsexecagent_name, endpointlimit, order, after, before, include_draftsList agent versions. Returns a paged collection of versions for the specified agent.
create_versionexecagent_name, endpointCreate an agent version. Creates a new version for the specified agent and returns the created version resource.
list_sessionsexecagent_name, endpointlimit, order, after, beforeList sessions for an agent. Returns a paged collection of sessions associated with the specified agent endpoint.
create_sessionexecagent_name, endpointCreate a 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 user identity for session-mutating operations.
delete_session_fileexecagent_name, agent_session_id, path, endpointrecursiveDelete a session file. Deletes the specified file or directory from the session sandbox. When recursive is false, deleting a non-empty directory returns 409 Conflict.
delete_versionexecagent_name, agent_version, endpointforceDelete an agent version. Deletes a specific version of an agent. For hosted agents, if the version has active sessions, the request is rejected with HTTP 409 unless force is set to true. When force is true, all sessions associated with this version are cascade-deleted.
delete_sessionexecagent_name, session_id, endpointDelete a session. Deletes a session synchronously. Returns 204 No Content when the session is deleted or does not exist.
create_version_from_manifestexecagent_name, endpointCreate an agent version from manifest. Imports the provided manifest to create a new version for the specified agent.
download_codeexecagent_name, endpointagent_versionDownload agent code. Downloads the code zip for a code-based hosted agent. Returns the previously-uploaded zip (application/zip). If agent_version is supplied, returns that version's code zip; otherwise returns the latest version's code zip. The SHA-256 digest of the returned bytes matches the content_hash on the resolved version's code_configuration.
enableexecagent_name, endpointEnable an agent. Enables the specified agent, allowing it to accept new sessions and process requests. This operation is idempotent — enabling an already-enabled agent returns success with no side effects.
disableexecagent_name, endpointDisable an agent. Disables the specified agent, preventing it from accepting new sessions or processing requests. Existing active sessions are allowed to drain gracefully but no new sessions can be created. This operation is idempotent — disabling an already-disabled agent returns success with no side effects.
stop_sessionexecagent_name, session_id, endpointStop a session. Terminates the specified hosted agent session and returns 204 No Content when the request succeeds.
upload_session_fileexecagent_name, agent_session_id, path, endpointUpload a session file. Uploads binary file content to the specified path in the session sandbox. The service stores the file relative to the session home directory and rejects payloads larger than 50 MB.
download_session_fileexecagent_name, agent_session_id, path, endpointDownload a session file. Downloads the file at the specified sandbox path as a binary stream. The path is resolved relative to the session home directory.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
agent_namestringThe name of the agent. Required.
agent_session_idstringThe session ID. Required.
agent_versionstringThe version of the agent to delete. Required.
endpointstringThe service endpoint host (no scheme), e.g. myaccount.table.cosmos.azure.com:443 - value of the client endpoint parameter. (default: )
pathstringThe file path to download from the sandbox, relative to the session home directory. Required.
session_idstringThe session identifier. Required.
afterstring
agent_versionstringThe version of the agent whose code zip should be downloaded. If omitted, the latest version's code zip is returned. Default value is None.
beforestringA cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. Default value is None.
forcebooleanFor Hosted Agents, if true, force-deletes the version even if it has active sessions, cascading deletion to all associated sessions. The service defaults to false if a value is not specified by the caller. This value is not relevant for other Agent types. Default value is None.
include_draftsboolean(Preview) Whether to include draft versions in the listing. The service defaults to false if a value is not specified by the caller (only non-draft versions are returned). Default value is None.
kindstringFilter agents by kind. If not provided, all agents are returned. Known values are: "prompt", "hosted", "workflow", and "external". Default value is None.
limitintegerA 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.
orderstringSort order by the created_at timestamp of the objects. asc for ascending order anddesc for descending order. Known values are: "asc" and "desc". Default value is None.
pathstringThe directory path to list, relative to the session home directory. Defaults to the home directory if not provided. Default value is None.
recursivebooleanWhether to recursively delete directory contents. The service defaults to false if a value is not specified by the caller. Default value is None.

SELECT examples

Stream console logs for a hosted agent session. 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: .. code-block:: 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.

SELECT
data,
event
FROM azure.ai_projects.agents
WHERE agent_name = '{{ agent_name }}' -- required
AND agent_version = '{{ agent_version }}' -- required
AND session_id = '{{ session_id }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

DELETE examples

Delete an agent. Deletes an agent. For hosted agents, if any version has active sessions, the request is rejected with HTTP 409 unless force is set to true. When force is true, all associated sessions are cascade-deleted along with the agent and its versions.

DELETE FROM azure.ai_projects.agents
WHERE agent_name = '{{ agent_name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND force = '{{ force }}'
;

Lifecycle Methods

Update an agent endpoint. Applies a merge-patch update to the specified agent endpoint configuration.

EXEC azure.ai_projects.agents.update_details 
@agent_name='{{ agent_name }}' --required,
@endpoint='{{ endpoint }}' --required
;