{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/azure-ai-foundry/json-schema/azure-ai-foundry-thread-run-schema.json",
  "title": "ThreadRun",
  "description": "Data representing a single evaluation run of an agent thread.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_superseded/azure-ai-foundry-threads-api-openapi.yml#/components/schemas/ThreadRun",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "The identifier, which can be referenced in API endpoints."
    },
    "object": {
      "type": "string",
      "description": "The object type, which is always 'thread.run'.",
      "enum": [
        "thread.run"
      ],
      "x-ms-enum": {
        "modelAsString": false
      }
    },
    "thread_id": {
      "type": "string",
      "description": "The ID of the thread associated with this run.",
      "x-ms-client-name": "threadId"
    },
    "assistant_id": {
      "type": "string",
      "description": "The ID of the agent associated with the thread this run was performed against.",
      "x-ms-client-name": "assistantId"
    },
    "status": {
      "$ref": "#/$defs/RunStatus",
      "description": "The status of the agent thread run."
    },
    "required_action": {
      "$ref": "#/$defs/RequiredAction",
      "description": "The details of the action required for the agent thread run to continue.",
      "x-ms-client-name": "requiredAction"
    },
    "last_error": {
      "$ref": "#/$defs/RunError",
      "description": "The last error, if any, encountered by this agent thread run.",
      "x-ms-client-name": "lastError"
    },
    "model": {
      "type": "string",
      "description": "The ID of the model to use."
    },
    "instructions": {
      "type": "string",
      "description": "The overridden system instructions used for this agent thread run."
    },
    "tools": {
      "type": "array",
      "description": "The overridden enabled tools used for this agent thread run.",
      "default": [],
      "items": {
        "$ref": "#/$defs/ToolDefinition"
      }
    },
    "created_at": {
      "type": "integer",
      "format": "unixtime",
      "description": "The Unix timestamp, in seconds, representing when this object was created.",
      "x-ms-client-name": "createdAt"
    },
    "expires_at": {
      "type": [
        "integer",
        "null"
      ],
      "format": "unixtime",
      "description": "The Unix timestamp, in seconds, representing when this item expires.",
      "x-ms-client-name": "expiresAt"
    },
    "started_at": {
      "type": [
        "integer",
        "null"
      ],
      "format": "unixtime",
      "description": "The Unix timestamp, in seconds, representing when this item was started.",
      "x-ms-client-name": "startedAt"
    },
    "completed_at": {
      "type": [
        "integer",
        "null"
      ],
      "format": "unixtime",
      "description": "The Unix timestamp, in seconds, representing when this completed.",
      "x-ms-client-name": "completedAt"
    },
    "cancelled_at": {
      "type": [
        "integer",
        "null"
      ],
      "format": "unixtime",
      "description": "The Unix timestamp, in seconds, representing when this was cancelled.",
      "x-ms-client-name": "cancelledAt"
    },
    "failed_at": {
      "type": [
        "integer",
        "null"
      ],
      "format": "unixtime",
      "description": "The Unix timestamp, in seconds, representing when this failed.",
      "x-ms-client-name": "failedAt"
    },
    "incomplete_details": {
      "$ref": "#/$defs/IncompleteRunDetails",
      "description": "Details on why the run is incomplete. Will be `null` if the run is not incomplete.",
      "x-ms-client-name": "incompleteDetails"
    },
    "usage": {
      "$ref": "#/$defs/RunCompletionUsage",
      "description": "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.)."
    },
    "temperature": {
      "type": [
        "number",
        "null"
      ],
      "format": "float",
      "description": "The sampling temperature used for this run. If not set, defaults to 1."
    },
    "top_p": {
      "type": [
        "number",
        "null"
      ],
      "format": "float",
      "description": "The nucleus sampling value used for this run. If not set, defaults to 1.",
      "x-ms-client-name": "topP"
    },
    "max_prompt_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int32",
      "description": "The maximum number of prompt tokens specified to have been used over the course of the run.",
      "minimum": 256,
      "x-ms-client-name": "maxPromptTokens"
    },
    "max_completion_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int32",
      "description": "The maximum number of completion tokens specified to have been used over the course of the run.",
      "minimum": 256,
      "x-ms-client-name": "maxCompletionTokens"
    },
    "truncation_strategy": {
      "$ref": "#/$defs/TruncationObject",
      "description": "The strategy to use for dropping messages as the context windows moves forward.",
      "x-ms-client-name": "truncationStrategy"
    },
    "tool_choice": {
      "$ref": "#/$defs/AgentsToolChoiceOption",
      "description": "Controls whether or not and which tool is called by the model.",
      "x-ms-client-name": "toolChoice"
    },
    "response_format": {
      "$ref": "#/$defs/AgentsResponseFormatOption",
      "description": "The response format of the tool calls used in this run.",
      "x-ms-client-name": "responseFormat"
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "description": "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.",
      "additionalProperties": {
        "type": "string"
      }
    },
    "tool_resources": {
      "$ref": "#/$defs/ToolResources",
      "description": "Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis",
      "x-ms-client-name": "toolResources"
    },
    "parallel_tool_calls": {
      "type": "boolean",
      "description": "Determines if tools can be executed in parallel within the run.",
      "x-ms-client-name": "parallelToolCalls"
    }
  },
  "required": [
    "id",
    "object",
    "thread_id",
    "assistant_id",
    "status",
    "last_error",
    "model",
    "instructions",
    "tools",
    "created_at",
    "expires_at",
    "started_at",
    "completed_at",
    "cancelled_at",
    "failed_at",
    "incomplete_details",
    "usage",
    "max_prompt_tokens",
    "max_completion_tokens",
    "truncation_strategy",
    "tool_choice",
    "response_format",
    "metadata",
    "parallel_tool_calls"
  ],
  "$defs": {
    "AISearchIndexResource": {
      "type": "object",
      "description": "A AI Search Index resource.",
      "properties": {
        "index_connection_id": {
          "type": "string",
          "description": "An index connection id in an IndexResource attached to this agent.",
          "x-ms-client-name": "indexConnectionId"
        },
        "index_name": {
          "type": "string",
          "description": "The name of an index in an IndexResource attached to this agent.",
          "x-ms-client-name": "indexName"
        },
        "query_type": {
          "$ref": "#/$defs/AzureAISearchQueryType",
          "description": "Type of query in an AIIndexResource attached to this agent.",
          "x-ms-client-name": "queryType"
        },
        "top_k": {
          "type": "integer",
          "format": "int32",
          "description": "Number of documents to retrieve from search and present to the model.",
          "x-ms-client-name": "topK"
        },
        "filter": {
          "type": "string",
          "description": "filter string for search resource."
        },
        "index_asset_id": {
          "type": "string",
          "description": "Index asset id for search resource.",
          "x-ms-client-name": "indexAssetId"
        }
      }
    },
    "AgentsResponseFormatOption": {},
    "AgentsToolChoiceOption": {},
    "AzureAISearchQueryType": {
      "type": "string",
      "description": "Available query types for Azure AI Search tool.",
      "enum": [
        "simple",
        "semantic",
        "vector",
        "vector_simple_hybrid",
        "vector_semantic_hybrid"
      ],
      "x-ms-enum": {
        "name": "AzureAISearchQueryType",
        "modelAsString": true,
        "values": [
          {
            "name": "simple",
            "value": "simple",
            "description": "Query type `simple`"
          },
          {
            "name": "semantic",
            "value": "semantic",
            "description": "Query type `semantic`"
          },
          {
            "name": "vector",
            "value": "vector",
            "description": "Query type `vector`"
          },
          {
            "name": "vector_simple_hybrid",
            "value": "vector_simple_hybrid",
            "description": "Query type `vector_simple_hybrid`"
          },
          {
            "name": "vector_semantic_hybrid",
            "value": "vector_semantic_hybrid",
            "description": "Query type `vector_semantic_hybrid`"
          }
        ]
      }
    },
    "AzureAISearchToolResource": {
      "type": "object",
      "description": "A set of index resources used by the `azure_ai_search` tool.",
      "properties": {
        "indexes": {
          "type": "array",
          "description": "The indices attached to this agent. There can be a maximum of 1 index\nresource attached to the agent.",
          "maxItems": 1,
          "items": {
            "$ref": "#/$defs/AISearchIndexResource"
          },
          "x-ms-client-name": "indexList"
        }
      }
    },
    "CodeInterpreterToolResource": {
      "type": "object",
      "description": "A set of resources that are used by the `code_interpreter` tool.",
      "properties": {
        "file_ids": {
          "type": "array",
          "description": "A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files\nassociated with the tool.",
          "default": [],
          "maxItems": 20,
          "items": {
            "type": "string"
          },
          "x-ms-client-name": "fileIds"
        },
        "data_sources": {
          "type": "array",
          "description": "The data sources to be used. This option is mutually exclusive with the `fileIds` property.",
          "maxItems": 20,
          "items": {
            "$ref": "#/$defs/VectorStoreDataSource"
          },
          "x-ms-client-name": "dataSources"
        }
      }
    },
    "FileSearchToolResource": {
      "type": "object",
      "description": "A set of resources that are used by the `file_search` tool.",
      "properties": {
        "vector_store_ids": {
          "type": "array",
          "description": "The ID of the vector store attached to this agent. There can be a maximum of 1 vector\nstore attached to the agent.",
          "maxItems": 1,
          "items": {
            "type": "string"
          },
          "x-ms-client-name": "vectorStoreIds"
        },
        "vector_stores": {
          "type": "array",
          "description": "The list of vector store configuration objects from Azure.\nThis list is limited to one element.\nThe only element of this list contains the list of azure asset IDs used by the search tool.",
          "maxItems": 1,
          "items": {
            "$ref": "#/$defs/VectorStoreConfigurations"
          },
          "x-ms-client-name": "vectorStores"
        }
      }
    },
    "IncompleteDetailsReason": {
      "type": "string",
      "description": "The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.",
      "enum": [
        "max_completion_tokens",
        "max_prompt_tokens"
      ],
      "x-ms-enum": {
        "name": "IncompleteDetailsReason",
        "modelAsString": true,
        "values": [
          {
            "name": "maxCompletionTokens",
            "value": "max_completion_tokens",
            "description": "Maximum completion tokens exceeded"
          },
          {
            "name": "maxPromptTokens",
            "value": "max_prompt_tokens",
            "description": "Maximum prompt tokens exceeded"
          }
        ]
      }
    },
    "IncompleteRunDetails": {
      "type": "object",
      "description": "Details on why the run is incomplete. Will be `null` if the run is not incomplete.",
      "properties": {
        "reason": {
          "$ref": "#/$defs/IncompleteDetailsReason",
          "description": "The reason why the run is incomplete. This indicates which specific token limit was reached during the run."
        }
      },
      "required": [
        "reason"
      ]
    },
    "RequiredAction": {
      "type": "object",
      "description": "An abstract representation of a required action for an agent thread run to continue.",
      "properties": {
        "type": {
          "type": "string",
          "description": "The object type."
        }
      },
      "required": [
        "type"
      ]
    },
    "RunCompletionUsage": {
      "type": "object",
      "description": "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.).",
      "properties": {
        "completion_tokens": {
          "type": "integer",
          "format": "int64",
          "description": "Number of completion tokens used over the course of the run.",
          "x-ms-client-name": "completionTokens"
        },
        "prompt_tokens": {
          "type": "integer",
          "format": "int64",
          "description": "Number of prompt tokens used over the course of the run.",
          "x-ms-client-name": "promptTokens"
        },
        "total_tokens": {
          "type": "integer",
          "format": "int64",
          "description": "Total number of tokens used (prompt + completion).",
          "x-ms-client-name": "totalTokens"
        }
      },
      "required": [
        "completion_tokens",
        "prompt_tokens",
        "total_tokens"
      ]
    },
    "RunError": {
      "type": "object",
      "description": "The details of an error as encountered by an agent thread run.",
      "properties": {
        "code": {
          "type": "string",
          "description": "The status for the error."
        },
        "message": {
          "type": "string",
          "description": "The human-readable text associated with the error."
        }
      },
      "required": [
        "code",
        "message"
      ]
    },
    "RunStatus": {
      "type": "string",
      "description": "Possible values for the status of an agent thread run.",
      "enum": [
        "queued",
        "in_progress",
        "requires_action",
        "cancelling",
        "cancelled",
        "failed",
        "completed",
        "expired"
      ],
      "x-ms-enum": {
        "name": "RunStatus",
        "modelAsString": true,
        "values": [
          {
            "name": "queued",
            "value": "queued",
            "description": "Represents a run that is queued to start."
          },
          {
            "name": "inProgress",
            "value": "in_progress",
            "description": "Represents a run that is in progress."
          },
          {
            "name": "requiresAction",
            "value": "requires_action",
            "description": "Represents a run that needs another operation, such as tool output submission, to continue."
          },
          {
            "name": "cancelling",
            "value": "cancelling",
            "description": "Represents a run that is in the process of cancellation."
          },
          {
            "name": "cancelled",
            "value": "cancelled",
            "description": "Represents a run that has been cancelled."
          },
          {
            "name": "failed",
            "value": "failed",
            "description": "Represents a run that failed."
          },
          {
            "name": "completed",
            "value": "completed",
            "description": "Represents a run that successfully completed."
          },
          {
            "name": "expired",
            "value": "expired",
            "description": "Represents a run that expired before it could otherwise finish."
          }
        ]
      }
    },
    "ToolDefinition": {
      "type": "object",
      "description": "An abstract representation of an input tool definition that an agent can use.",
      "properties": {
        "type": {
          "type": "string",
          "description": "The object type."
        }
      },
      "required": [
        "type"
      ]
    },
    "ToolResources": {
      "type": "object",
      "description": "A set of resources that are used by the agent's tools. The resources are specific to the type of\ntool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search`\ntool requires a list of vector store IDs.",
      "properties": {
        "code_interpreter": {
          "$ref": "#/$defs/CodeInterpreterToolResource",
          "description": "Resources to be used by the `code_interpreter` tool consisting of file IDs.",
          "x-ms-client-name": "codeInterpreter"
        },
        "file_search": {
          "$ref": "#/$defs/FileSearchToolResource",
          "description": "Resources to be used by the `file_search` tool consisting of vector store IDs.",
          "x-ms-client-name": "fileSearch"
        },
        "azure_ai_search": {
          "$ref": "#/$defs/AzureAISearchToolResource",
          "description": "Resources to be used by the `azure_ai_search` tool consisting of index IDs and names.",
          "x-ms-client-name": "azureAISearch"
        }
      }
    },
    "TruncationObject": {
      "type": "object",
      "description": "Controls for how a thread will be truncated prior to the run. Use this to control the initial\ncontext window of the run.",
      "properties": {
        "type": {
          "type": "string",
          "description": "The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will\nbe truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread\nwill be dropped to fit the context length of the model, `max_prompt_tokens`.",
          "default": "auto",
          "enum": [
            "auto",
            "last_messages"
          ],
          "x-ms-enum": {
            "name": "TruncationStrategy",
            "modelAsString": true,
            "values": [
              {
                "name": "auto",
                "value": "auto",
                "description": "Default value. Messages in the middle of the thread will be dropped to fit the context length of the model."
              },
              {
                "name": "lastMessages",
                "value": "last_messages",
                "description": "The thread will truncate to the `lastMessages` count of recent messages."
              }
            ]
          }
        },
        "last_messages": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32",
          "description": "The number of most recent messages from the thread when constructing the context for the run.",
          "minimum": 1,
          "x-ms-client-name": "lastMessages"
        }
      },
      "required": [
        "type"
      ]
    },
    "VectorStoreConfiguration": {
      "type": "object",
      "description": "Vector storage configuration is the list of data sources, used when multiple\nfiles can be used for the enterprise file search.",
      "properties": {
        "data_sources": {
          "type": "array",
          "description": "Data sources",
          "items": {
            "$ref": "#/$defs/VectorStoreDataSource"
          },
          "x-ms-client-name": "dataSources"
        }
      },
      "required": [
        "data_sources"
      ]
    },
    "VectorStoreConfigurations": {
      "type": "object",
      "description": "The structure, containing the list of vector storage configurations i.e. the list of azure asset IDs.",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name",
          "x-ms-client-name": "storeName"
        },
        "configuration": {
          "$ref": "#/$defs/VectorStoreConfiguration",
          "description": "Configurations",
          "x-ms-client-name": "storeConfiguration"
        }
      },
      "required": [
        "name",
        "configuration"
      ]
    },
    "VectorStoreDataSource": {
      "type": "object",
      "description": "The structure, containing Azure asset URI path and the asset type of the file used as a data source\nfor the enterprise file search.",
      "properties": {
        "uri": {
          "type": "string",
          "description": "Asset URI.",
          "x-ms-client-name": "assetIdentifier"
        },
        "type": {
          "$ref": "#/$defs/VectorStoreDataSourceAssetType",
          "description": "The asset type",
          "x-ms-client-name": "assetType"
        }
      },
      "required": [
        "uri",
        "type"
      ]
    },
    "VectorStoreDataSourceAssetType": {
      "type": "string",
      "description": "Type of vector storage asset. Asset type may be a uri_asset, in this case it should contain asset URI ID,\nin the case of id_asset it should contain the data ID.",
      "enum": [
        "uri_asset",
        "id_asset"
      ],
      "x-ms-enum": {
        "name": "VectorStoreDataSourceAssetType",
        "modelAsString": true,
        "values": [
          {
            "name": "uri_asset",
            "value": "uri_asset",
            "description": "Azure URI"
          },
          {
            "name": "id_asset",
            "value": "id_asset",
            "description": "The data ID"
          }
        ]
      }
    }
  }
}