Skip to main content

runs

Creates, updates, deletes, gets or lists a runs resource.

Overview

Nameruns
TypeResource
Idazure.ai_agents.runs

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier, which can be referenced in API endpoints. Required.
assistant_idstringThe ID of the agent associated with the thread this run was performed against. Required.
thread_idstringThe ID of the thread associated with this run. Required.
cancelled_atstring (date-time)The Unix timestamp, in seconds, representing when this was cancelled. Required.
completed_atstring (date-time)The Unix timestamp, in seconds, representing when this completed. Required.
created_atstring (date-time)The Unix timestamp, in seconds, representing when this object was created. Required.
expires_atstring (date-time)The Unix timestamp, in seconds, representing when this item expires. Required.
failed_atstring (date-time)The Unix timestamp, in seconds, representing when this failed. Required.
incomplete_detailsobjectDetails on why the run is incomplete. Will be null if the run is not incomplete. Required.
instructionsstringThe overridden system instructions used for this agent thread run. Required.
last_errorobjectThe last error, if any, encountered by this agent thread run. Required.
max_completion_tokensintegerThe maximum number of completion tokens specified to have been used over the course of the run. Required.
max_prompt_tokensintegerThe maximum number of prompt tokens specified to have been used over the course of the run. Required.
metadataobjectA set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. Required.
modelstringThe ID of the model to use. Required.
objectstringThe object type, which is always 'thread.run'. Required. Default value is "thread.run".
parallel_tool_callsbooleanDetermines if tools can be executed in parallel within the run. Required.
required_actionobjectThe details of the action required for the agent thread run to continue.
response_formatobjectThe response format of the tool calls used in this run. Required. Is one of the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, ResponseFormatJsonSchemaType
started_atstring (date-time)The Unix timestamp, in seconds, representing when this item was started. Required.
statusstringThe status of the agent thread run. Required. Known values are: "queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", and "expired". (queued, in_progress, requires_action, cancelling, cancelled, failed, completed, expired)
temperaturenumberThe sampling temperature used for this run. If not set, defaults to 1.
tool_choiceobjectControls whether or not and which tool is called by the model. Required. Is one of the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], AgentsNamedToolChoice
tool_resourcesobjectOverride the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis.
toolsarrayThe overridden enabled tools used for this agent thread run. Required.
top_pnumberThe nucleus sampling value used for this run. If not set, defaults to 1.
truncation_strategyobjectThe strategy to use for dropping messages as the context windows moves forward. Required.
usageobjectUsage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.). Required.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectthread_id, run_id, endpointGets an existing run from an existing thread.
listselectthread_id, endpointlimit, order, after, beforeGets a list of runs for a specified thread.
createinsertthread_id, endpointinclude[]Creates a new run for an agent thread.
updateexecthread_id, run_id, endpointModifies an existing thread run.
submit_tool_outputsexecthread_id, run_id, endpointSubmits outputs from tools as requested by tool calls in a run.
cancelexecthread_id, run_id, endpointCancels a run of an in‐progress thread.

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
endpointstringThe service endpoint host (no scheme), e.g. myaccount.table.cosmos.azure.com:443 - value of the client endpoint parameter. (default: )
run_idstringIdentifier of the run. Required.
thread_idstringIdentifier of the thread. Required.
afterstring
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.
include[]arrayA list of additional fields to include in the response. Currently the only supported value is step_details.tool_calls[*].file_search.results[*].content to fetch the file search result content. 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 and desc for descending order. Known values are: "asc" and "desc". Default value is None.

SELECT examples

Gets an existing run from an existing thread.

SELECT
id,
assistant_id,
thread_id,
cancelled_at,
completed_at,
created_at,
expires_at,
failed_at,
incomplete_details,
instructions,
last_error,
max_completion_tokens,
max_prompt_tokens,
metadata,
model,
object,
parallel_tool_calls,
required_action,
response_format,
started_at,
status,
temperature,
tool_choice,
tool_resources,
tools,
top_p,
truncation_strategy,
usage
FROM azure.ai_agents.runs
WHERE thread_id = '{{ thread_id }}' -- required
AND run_id = '{{ run_id }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

Creates a new run for an agent thread.

INSERT INTO azure.ai_agents.runs (
thread_id,
endpoint,
include[]
)
SELECT
'{{ thread_id }}',
'{{ endpoint }}',
'{{ include[] }}'
RETURNING
id,
assistant_id,
thread_id,
cancelled_at,
completed_at,
created_at,
expires_at,
failed_at,
incomplete_details,
instructions,
last_error,
max_completion_tokens,
max_prompt_tokens,
metadata,
model,
object,
parallel_tool_calls,
required_action,
response_format,
started_at,
status,
temperature,
tool_choice,
tool_resources,
tools,
top_p,
truncation_strategy,
usage
;

Lifecycle Methods

Modifies an existing thread run.

EXEC azure.ai_agents.runs.update 
@thread_id='{{ thread_id }}' --required,
@run_id='{{ run_id }}' --required,
@endpoint='{{ endpoint }}' --required
;