ThreadRun Class
Data representing a single evaluation run of an agent thread.
Constructor
ThreadRun(*args: Any, **kwargs: Any)
Variables
| Name | Description |
|---|---|
|
id
|
The identifier, which can be referenced in API endpoints. Required. |
|
object
|
The object type, which is always 'thread.run'. Required. Default value is "thread.run". |
|
thread_id
|
The ID of the thread associated with this run. Required. |
|
agent_id
|
The ID of the agent associated with the thread this run was performed against. Required. |
|
status
|
The status of the agent thread run. Required. Known values are: "queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", and "expired". |
|
required_action
|
The details of the action required for the agent thread run to continue. |
|
last_error
|
The last error, if any, encountered by this agent thread run. Required. |
|
model
|
The ID of the model to use. Required. |
|
instructions
|
The overridden system instructions used for this agent thread run. Required. |
|
tools
|
The overridden enabled tools used for this agent thread run. Required. |
|
created_at
|
The Unix timestamp, in seconds, representing when this object was created. Required. |
|
expires_at
|
The Unix timestamp, in seconds, representing when this item expires. Required. |
|
started_at
|
The Unix timestamp, in seconds, representing when this item was started. Required. |
|
completed_at
|
The Unix timestamp, in seconds, representing when this completed. Required. |
|
cancelled_at
|
The Unix timestamp, in seconds, representing when this was cancelled. Required. |
|
failed_at
|
The Unix timestamp, in seconds, representing when this failed. Required. |
|
incomplete_details
|
Details on why the run is incomplete. Will be |
|
usage
|
Usage statistics related to the run. This value will be |
|
temperature
|
The sampling temperature used for this run. If not set, defaults to 1. |
|
top_p
|
The nucleus sampling value used for this run. If not set, defaults to 1. |
|
max_prompt_tokens
|
The maximum number of prompt tokens specified to have been used over the course of the run. Required. |
|
max_completion_tokens
|
The maximum number of completion tokens specified to have been used over the course of the run. Required. |
|
truncation_strategy
|
The strategy to use for dropping messages as the context windows moves forward. Required. |
|
tool_choice
|
Controls whether or not and which tool is called by the model. Required. Is one of the following types: str, Union[str, "_models.AgentsToolChoiceOptionMode"], AgentsNamedToolChoice |
|
response_format
|
The response format of the tool calls used in this run. Required. Is one of the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, ResponseFormatJsonSchemaType |
|
metadata
|
A 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. |
|
tool_resources
|
Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. |
|
parallel_tool_calls
|
Determines if tools can be executed in parallel within the run. Required. |
Methods
| as_dict |
Return a dict that can be turned into json using json.dump. |
| clear |
Remove all items from D. |
| copy | |
| get |
Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any |
| items | |
| keys | |
| pop |
Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given. |
| popitem |
Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty. |
| setdefault |
Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any |
| update |
Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs. |
| values |
as_dict
Return a dict that can be turned into json using json.dump.
as_dict(*, exclude_readonly: bool = False) -> Dict[str, Any]
Keyword-Only Parameters
| Name | Description |
|---|---|
|
exclude_readonly
|
Whether to remove the readonly properties. Default value: False
|
Returns
| Type | Description |
|---|---|
|
A dict JSON compatible object |
clear
Remove all items from D.
clear() -> None
copy
copy() -> Model
get
Get the value for key if key is in the dictionary, else default. :param str key: The key to look up. :param any default: The value to return if key is not in the dictionary. Defaults to None :returns: D[k] if k in D, else d. :rtype: any
get(key: str, default: Any = None) -> Any
Parameters
| Name | Description |
|---|---|
|
key
Required
|
|
|
default
|
Default value: None
|
items
items() -> ItemsView[str, Any]
Returns
| Type | Description |
|---|---|
|
set-like object providing a view on D's items |
keys
keys() -> KeysView[str]
Returns
| Type | Description |
|---|---|
|
a set-like object providing a view on D's keys |
pop
Removes specified key and return the corresponding value. :param str key: The key to pop. :param any default: The value to return if key is not in the dictionary :returns: The value corresponding to the key. :rtype: any :raises KeyError: If key is not found and default is not given.
pop(key: str, default: ~typing.Any = <object object>) -> Any
Parameters
| Name | Description |
|---|---|
|
key
Required
|
|
|
default
|
|
popitem
Removes and returns some (key, value) pair :returns: The (key, value) pair. :rtype: tuple :raises KeyError: if D is empty.
popitem() -> Tuple[str, Any]
setdefault
Same as calling D.get(k, d), and setting D[k]=d if k not found :param str key: The key to look up. :param any default: The value to set if key is not in the dictionary :returns: D[k] if k in D, else d. :rtype: any
setdefault(key: str, default: ~typing.Any = <object object>) -> Any
Parameters
| Name | Description |
|---|---|
|
key
Required
|
|
|
default
|
|
update
Updates D from mapping/iterable E and F. :param any args: Either a mapping object or an iterable of key-value pairs.
update(*args: Any, **kwargs: Any) -> None
values
values() -> ValuesView[Any]
Returns
| Type | Description |
|---|---|
|
an object providing a view on D's values |
Attributes
agent_id
The ID of the agent associated with the thread this run was performed against. Required.
agent_id: str
cancelled_at
The Unix timestamp, in seconds, representing when this was cancelled. Required.
cancelled_at: datetime
completed_at
The Unix timestamp, in seconds, representing when this completed. Required.
completed_at: datetime
created_at
The Unix timestamp, in seconds, representing when this object was created. Required.
created_at: datetime
expires_at
The Unix timestamp, in seconds, representing when this item expires. Required.
expires_at: datetime
failed_at
The Unix timestamp, in seconds, representing when this failed. Required.
failed_at: datetime
id
The identifier, which can be referenced in API endpoints. Required.
id: str
incomplete_details
Details on why the run is incomplete. Will be null if the run is not incomplete. Required.
incomplete_details: _models.IncompleteRunDetails
instructions
The overridden system instructions used for this agent thread run. Required.
instructions: str
last_error
The last error, if any, encountered by this agent thread run. Required.
last_error: _models.RunError
max_completion_tokens
The maximum number of completion tokens specified to have been used over the course of the run. Required.
max_completion_tokens: int
max_prompt_tokens
The maximum number of prompt tokens specified to have been used over the course of the run. Required.
max_prompt_tokens: int
metadata
A 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.
metadata: Dict[str, str]
model
The ID of the model to use. Required.
model: str
object
The object type, which is always 'thread.run'. Required. Default value is "thread.run".
object: Literal['thread.run']
parallel_tool_calls
Determines if tools can be executed in parallel within the run. Required.
parallel_tool_calls: bool
required_action
The details of the action required for the agent thread run to continue.
required_action: _models.RequiredAction | None
response_format
The response format of the tool calls used in this run. Required. Is one of the following types: str, Union[str, "_models.AgentsResponseFormatMode"], AgentsResponseFormat, ResponseFormatJsonSchemaType
response_format: _types.AgentsResponseFormatOption
started_at
The Unix timestamp, in seconds, representing when this item was started. Required.
started_at: datetime
status
"queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", and "expired".
status: str | _models.RunStatus
temperature
The sampling temperature used for this run. If not set, defaults to 1.
temperature: float | None
thread_id
The ID of the thread associated with this run. Required.
thread_id: str
tool_choice
Controls 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_choice: _types.AgentsToolChoiceOption
tool_resources
Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis.
tool_resources: _models.ToolResources | None
tools
The overridden enabled tools used for this agent thread run. Required.
tools: List[_models.ToolDefinition]
top_p
The nucleus sampling value used for this run. If not set, defaults to 1.
top_p: float | None
truncation_strategy
The strategy to use for dropping messages as the context windows moves forward. Required.
truncation_strategy: _models.TruncationObject
usage
Usage 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.
usage: _models.RunCompletionUsage