{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/trajectory/json-schema/trajectory-task-spec-schema.json",
  "title": "TaskSpec",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/trajectory-diagnostics-api-openapi.yml#/components/schemas/TaskSpec",
  "properties": {
    "name": {
      "type": "string",
      "title": "Name"
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Id"
    },
    "split": {
      "anyOf": [
        {
          "$ref": "#/$defs/TaskSplit"
        },
        {
          "type": "null"
        }
      ]
    },
    "input_messages": {
      "items": {
        "$ref": "#/$defs/BenchmarkMessage"
      },
      "type": "array",
      "title": "Input Messages",
      "description": "Messages stored on the task. For SDK evaluation and training, your agent script must pass messages to the model; this field does not do that automatically."
    },
    "reference_trajectory_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Reference Trajectory Id"
    },
    "image": {
      "type": "null",
      "title": "Image"
    },
    "runtime": {
      "anyOf": [
        {
          "$ref": "#/$defs/RuntimeSpec"
        },
        {
          "type": "null"
        }
      ]
    },
    "run_command": {
      "type": "string",
      "title": "Run Command",
      "description": "For SDK evaluation and training, the command to run your agent in the sandbox, e.g. `python /app/agent.py`; include the executable, not only its arguments. Your script must call the model, run any tools, log a reward, and finalize the trajectory before exiting."
    },
    "env_vars": {
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "$ref": "#/$defs/SecretRef"
          }
        ]
      },
      "type": "object",
      "title": "Env Vars",
      "description": "Keys must match [A-Za-z_][A-Za-z0-9_]* and cannot start with TRAJECTORY_ or use MODEL_ENDPOINT_ID, MODEL_ENDPOINT_ACCESS_TOKEN, or MODEL_ENDPOINT_URL."
    },
    "env_resources": {
      "$ref": "#/$defs/EnvResources"
    },
    "spec": {
      "additionalProperties": true,
      "type": "object",
      "title": "Spec"
    },
    "task_spec_uri": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Task Spec Uri"
    },
    "tags": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Tags",
      "description": "Up to 20 distinct, non-empty task tags of at most 64 characters each."
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "name",
    "run_command"
  ],
  "$defs": {
    "BenchmarkMessage": {
      "properties": {
        "role": {
          "type": "string",
          "title": "Role"
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content"
        },
        "tool_calls": {
          "items": {
            "$ref": "#/$defs/ToolCall"
          },
          "type": "array",
          "title": "Tool Calls"
        },
        "tool_response": {
          "anyOf": [
            {
              "$ref": "#/$defs/ToolResponse"
            },
            {
              "type": "null"
            }
          ]
        },
        "tool_definitions": {
          "items": {
            "$ref": "#/$defs/ToolDefinition"
          },
          "type": "array",
          "title": "Tool Definitions"
        },
        "usage": {
          "anyOf": [
            {
              "$ref": "#/$defs/MessageUsage"
            },
            {
              "type": "null"
            }
          ]
        },
        "finish_reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Finish Reason"
        },
        "metadata": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Metadata"
        },
        "reasoning": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reasoning"
        },
        "reasoning_details": {
          "title": "Reasoning Details"
        },
        "tokens": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tokens"
        },
        "token_masks": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Token Masks"
        },
        "logprobs": {
          "anyOf": [
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Logprobs"
        },
        "trainable_status": {
          "type": "string",
          "enum": [
            "trainable",
            "not_trainable",
            "superseded",
            "summarization_boundary"
          ],
          "title": "Trainable Status",
          "default": "not_trainable"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "role"
      ],
      "title": "BenchmarkMessage"
    },
    "EnvResources": {
      "properties": {
        "docker_engine": {
          "type": "boolean",
          "title": "Docker Engine",
          "description": "Require a Docker-capable sandbox. The user image must provide Docker and the harness; the harness owns nested containers and grading.",
          "default": false
        },
        "cpus": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cpus"
        },
        "memory_mb": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Memory Mb"
        },
        "gpus": {
          "type": "integer",
          "title": "Gpus",
          "default": 0
        },
        "network_mode": {
          "$ref": "#/$defs/NetworkMode",
          "default": "no-network"
        },
        "allowed_hosts": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Allowed Hosts"
        },
        "agent_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Agent User"
        },
        "env": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object",
          "title": "Env"
        },
        "setup_commands": {
          "items": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "type": "array",
          "title": "Setup Commands"
        },
        "mcp_servers": {
          "items": {
            "$ref": "#/$defs/McpServerSpec"
          },
          "type": "array",
          "title": "Mcp Servers"
        },
        "allow_internet": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Allow Internet"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "EnvResources"
    },
    "GeneratedToolInfo": {
      "properties": {
        "provider": {
          "type": "string",
          "title": "Provider"
        },
        "model": {
          "type": "string",
          "title": "Model"
        },
        "messages": {
          "items": {
            "$ref": "#/$defs/BenchmarkMessage"
          },
          "type": "array",
          "title": "Messages"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "provider",
        "model",
        "messages"
      ],
      "title": "GeneratedToolInfo"
    },
    "ImageSpec": {
      "properties": {
        "dockerfile_path": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Dockerfile Path"
        },
        "image_ref": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Image Ref"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "ImageSpec"
    },
    "McpServerSpec": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "transport": {
          "type": "string",
          "enum": [
            "sse",
            "streamable-http",
            "stdio"
          ],
          "title": "Transport",
          "default": "sse"
        },
        "url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Url"
        },
        "command": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Command"
        },
        "args": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Args"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name"
      ],
      "title": "McpServerSpec"
    },
    "MessageUsage": {
      "properties": {
        "prompt_tokens": {
          "type": "integer",
          "title": "Prompt Tokens",
          "default": 0
        },
        "completion_tokens": {
          "type": "integer",
          "title": "Completion Tokens",
          "default": 0
        },
        "total_tokens": {
          "type": "integer",
          "title": "Total Tokens",
          "default": 0
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "MessageUsage"
    },
    "NetworkMode": {
      "type": "string",
      "enum": [
        "no-network",
        "public",
        "allowlist"
      ],
      "title": "NetworkMode"
    },
    "RuntimeSpec": {
      "properties": {
        "runtime_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Runtime Id"
        },
        "source": {
          "anyOf": [
            {
              "$ref": "#/$defs/ImageSpec"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "RuntimeSpec"
    },
    "SecretRef": {
      "properties": {
        "secret_ref": {
          "type": "string",
          "title": "Secret Ref",
          "description": "Organization secret name. The containing env_vars key names the runtime variable."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "secret_ref"
      ],
      "title": "SecretRef"
    },
    "TaskSplit": {
      "type": "string",
      "enum": [
        "train",
        "test"
      ],
      "title": "TaskSplit"
    },
    "ToolCall": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "arguments": {
          "additionalProperties": true,
          "type": "object",
          "title": "Arguments"
        },
        "id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Id"
        },
        "raw_string": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Raw String"
        },
        "argument_encoding": {
          "type": "string",
          "enum": [
            "json",
            "xml"
          ],
          "title": "Argument Encoding",
          "default": "json"
        },
        "is_parsed_successfully": {
          "type": "boolean",
          "title": "Is Parsed Successfully",
          "default": true
        },
        "parser_error_msg": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Parser Error Msg"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "arguments"
      ],
      "title": "ToolCall"
    },
    "ToolDefinition": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "description": {
          "type": "string",
          "title": "Description"
        },
        "parameters": {
          "additionalProperties": true,
          "type": "object",
          "title": "Parameters"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "description",
        "parameters"
      ],
      "title": "ToolDefinition"
    },
    "ToolResponse": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "arguments": {
          "additionalProperties": true,
          "type": "object",
          "title": "Arguments"
        },
        "response": {
          "title": "Response"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Error"
        },
        "raw_name_args": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Raw Name Args"
        },
        "metadata": {
          "anyOf": [
            {
              "$ref": "#/$defs/ToolResponseMetadata"
            },
            {
              "type": "null"
            }
          ]
        },
        "duration_seconds": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Duration Seconds"
        },
        "is_env_done": {
          "type": "boolean",
          "title": "Is Env Done",
          "default": false
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "name",
        "arguments"
      ],
      "title": "ToolResponse"
    },
    "ToolResponseMetadata": {
      "properties": {
        "generated_tool_info": {
          "anyOf": [
            {
              "$ref": "#/$defs/GeneratedToolInfo"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "ToolResponseMetadata"
    }
  }
}