> ## Documentation Index
> Fetch the complete documentation index at: https://docs.veadk.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# 列出定时任务

> 按游标分页读取任务定义与当前状态

需要使用 AgentKit CLI 0.54.0 部署并[启用定时任务](/productions/api-reference/preview/zh/harness-runtime/cronjobs/overview)的 Harness Runtime

将返回的 `next_cursor` 原样传给下一次请求。空字符串表示最后一页；不要将本接口的任务排列顺序视为创建时间排序


## OpenAPI

````yaml productions/api-reference/openapi/zh/harness-runtime.json GET /harness/cronjobs
openapi: 3.1.0
info:
  title: Harness Runtime
  version: agentkit-cli 0.54.0 / SDK 0.8.0 / ADK 2.2.0
  description: >-
    AgentKit CLI 0.54.0 部署的 Harness Runtime，基于 VeADK 1.0.8、AgentKit SDK 0.8.0 与
    Google ADK 2.2.0 核验；定时任务另需启用配置
servers:
  - url: http://localhost:8000
    description: 本地服务
security:
  - {}
  - RuntimeBearer: []
tags:
  - name: 服务与应用
  - name: 会话
  - name: 智能体运行
  - name: 制品
  - name: 记忆
  - name: 评测 · 开发服务
  - name: 调试 · 开发服务
  - name: 兼容接口
  - name: Harness 定时任务
paths:
  /harness/cronjobs:
    get:
      tags:
        - Harness Runtime cronjobs
      summary: 列出定时任务
      description: 按游标分页读取任务定义与当前状态
      operationId: harness_cronjob_list
      parameters:
        - name: cursor
          in: query
          required: false
          schema:
            type: string
            maxLength: 4096
            default: ''
            title: Cursor
          description: 上一页的 next_cursor，首次请求省略或传空字符串
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 1000
            minimum: 1
            default: 100
            title: Limit
          description: 每页最多返回的记录数，范围为 1–1000
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CronjobPage'
              example:
                items:
                  - name: daily-report
                    prompt: Summarize recent activity
                    schedule:
                      cron: 0 9 * * *
                      at: null
                      timezone: Asia/Shanghai
                    enabled: true
                    timeout_seconds: 1800
                    misfire_policy: latest
                    misfire_grace_seconds: 120
                    harness: null
                    cronjob_id: 0e58ff7f7dcbf348c252fc70e7fdb587
                    revision: 1
                    created_at: '2026-09-16T00:00:00Z'
                    updated_at: '2026-09-16T00:00:00Z'
                    next_run_at: '2026-09-16T01:00:00Z'
                    active: null
                    last_run: null
                next_cursor: ''
        '401':
          description: 部署网关要求的服务访问凭证缺失或无效，具体响应由网关决定
        '422':
          description: 请求参数、调度配置或幂等键校验失败
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CronjobRequestError'
              examples:
                field:
                  value:
                    detail:
                      - loc:
                          - path
                          - job_id
                        msg: String should match pattern
                        type: string_pattern_mismatch
                value:
                  value:
                    detail: Invalid request
      security:
        - HarnessServiceAuth: []
      x-codeSamples:
        - lang: cURL
          source: |-
            curl --request GET "${HARNESS_URL}/harness/cronjobs" \
              --header "Authorization: Bearer ${HARNESS_TOKEN}"
        - lang: Python
          source: >-
            import json

            import os

            from urllib.request import Request, urlopen


            base_url = os.environ["HARNESS_URL"]

            headers = {"Authorization": "Bearer " + os.environ["HARNESS_TOKEN"]}


            request = Request(base_url + f"/harness/cronjobs", headers=headers,
            method="GET")

            with urlopen(request) as response:
                print(json.load(response))
        - lang: JavaScript
          source: >-
            const baseUrl = process.env.HARNESS_URL;

            const headers = { Authorization: `Bearer
            ${process.env.HARNESS_TOKEN}` };

            const response = await fetch(`${baseUrl}/harness/cronjobs`, {
              method: "GET",
              headers,
            });

            if (!response.ok) throw new Error(await response.text());

            console.log(await response.json());
components:
  schemas:
    CronjobPage:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/Cronjob'
          description: 当前页记录
        next_cursor:
          type: string
          description: 下一页游标，空字符串表示没有后续页面
      required:
        - items
        - next_cursor
    CronjobRequestError:
      type: object
      properties:
        detail:
          anyOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/CronjobValidationError'
          description: 业务校验错误说明或字段校验错误列表
      required:
        - detail
    Cronjob:
      type: object
      properties:
        name:
          type: string
          maxLength: 128
          minLength: 1
          title: Name
          description: 任务名称，1–128 个字符
        prompt:
          type: string
          maxLength: 65536
          minLength: 1
          title: Prompt
          description: 每次执行发送给智能体的消息，1–65536 个字符
        schedule:
          $ref: '#/components/schemas/CronjobSchedule'
          description: 触发计划
        harness:
          anyOf:
            - $ref: '#/components/schemas/CronjobHarnessPublicOverrides'
            - type: 'null'
        enabled:
          type: boolean
          title: Enabled
          description: 是否启用后续调度
        timeout_seconds:
          type: integer
          maximum: 10800
          minimum: 1
          title: Timeout Seconds
          description: 单次执行超时，单位为秒；超时记为 failed，不自动重试该次执行
        misfire_policy:
          type: string
          enum:
            - latest
            - skip
          title: Misfire Policy
          description: latest 补跑最近一次错过的触发；skip 仅在该次触发未超出宽限时间时执行。两者均不逐次补跑所有历史触发
        misfire_grace_seconds:
          type: integer
          maximum: 86400
          minimum: 0
          title: Misfire Grace Seconds
          description: skip 策略允许的最大延迟，单位为秒
        cronjob_id:
          type: string
          description: 所属任务 ID
          pattern: ^[a-f0-9]{32}$
        revision:
          type: integer
          description: 任务修订号
        created_at:
          type: string
          description: 任务创建时间，UTC
          format: date-time
        updated_at:
          type: string
          description: 任务最近更新时间，UTC
          format: date-time
        next_run_at:
          anyOf:
            - type: string
              description: 下次计划触发时间，UTC；没有后续触发时为 null
              format: date-time
            - type: 'null'
        active:
          anyOf:
            - $ref: '#/components/schemas/CronjobRun'
            - type: 'null'
          description: 当前排队、运行中或正在保存最终结果的执行
        last_run:
          anyOf:
            - $ref: '#/components/schemas/CronjobRunSummary'
            - type: 'null'
          description: 最近已保存到历史的执行摘要
      required:
        - name
        - prompt
        - schedule
        - harness
        - enabled
        - timeout_seconds
        - misfire_policy
        - misfire_grace_seconds
        - cronjob_id
        - revision
        - created_at
        - updated_at
        - next_run_at
        - active
        - last_run
    CronjobValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
          description: 校验失败字段的位置
        msg:
          type: string
          title: Message
          description: 校验失败原因
        type:
          type: string
          title: Error Type
          description: 校验错误代码
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    CronjobSchedule:
      properties:
        cron:
          anyOf:
            - type: string
            - type: 'null'
          title: Cron
          description: 五字段 cron 表达式，依次为分钟、小时、日、月、星期；必须有未来八年内的触发时间
        at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: At
          description: 包含时区偏移的 ISO 8601 时间；启用任务时必须在未来，与 cron 二选一
        timezone:
          type: string
          title: Timezone
          default: Asia/Shanghai
          description: IANA 时区名称，用于解释 cron；at 使用其自身的偏移，但此字段仍须是有效时区
      additionalProperties: false
      type: object
      title: Schedule
      description: 周期或一次性计划，cron 与 at 必须且只能选择一个非 null 值
      oneOf:
        - required:
            - cron
          properties:
            cron:
              type: string
            at:
              type: 'null'
        - required:
            - at
          properties:
            at:
              type: string
              format: date-time
            cron:
              type: 'null'
    CronjobHarnessPublicOverrides:
      properties:
        model_name:
          type: string
          title: Model Name
          description: 本次任务使用的推理模型名称
        tools:
          type: string
          title: Tools
          description: >-
            逗号分隔的内置工具名称；CLI 0.54.0 默认部署支持的 13
            个名称、用途与依赖见[内置工具](/productions/api-reference/preview/zh/harness-runtime/tools)
        mcp_servers:
          type: array
          items:
            $ref: '#/components/schemas/CronjobMcpServerPublic'
          description: 任务使用的 MCP 服务，凭证已脱敏
        skills:
          type: string
          title: Skills
          description: 逗号分隔的 SkillHub slug、技能空间 ID 或空间:技能引用
        system_prompt:
          type: string
          title: System Prompt
          description: 任务执行时使用的智能体指令
        runtime:
          type: string
          enum:
            - adk
            - codex
          title: Runtime
          description: 智能体运行后端
        registry_space_id:
          type: string
          title: Registry Space Id
          description: A2A 智能体注册空间 ID
        registry_endpoint:
          type: string
          title: Registry Endpoint
          description: A2A 智能体注册服务地址
        registry_region:
          type: string
          title: Registry Region
          description: A2A 智能体注册服务区域
        registry_top_k:
          type: integer
          minimum: 1
          title: Registry Top K
          description: 检索的候选智能体数量，至少为 1
        max_llm_calls:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Max Llm Calls
          description: 单次执行最大模型调用次数，至少为 1
      additionalProperties: false
      type: object
      title: CronjobHarnessPublicOverrides
      description: 该任务每次执行时应用的配置，仅应用显式提供的字段，未提供字段继承已部署智能体
    CronjobRun:
      type: object
      properties:
        cronjob_id:
          type: string
          description: 所属任务 ID
          pattern: ^[a-f0-9]{32}$
        run_id:
          type: string
          description: 执行 ID，用于读取或取消该次执行
          pattern: ^[0-9]{13}-[a-f0-9]{20}$
        revision:
          type: integer
          description: 本次执行使用的任务修订号
        scheduled_at:
          type: string
          description: 计划触发时间，UTC
          format: date-time
        created_at:
          type: string
          description: 执行记录创建时间，UTC
          format: date-time
        prompt:
          type: string
          description: 本次执行的消息
        harness:
          anyOf:
            - $ref: '#/components/schemas/CronjobHarnessPublicOverrides'
            - type: 'null'
        timeout_seconds:
          type: integer
          description: 本次执行的超时秒数
        state:
          type: string
          description: 执行状态
          enum:
            - queued
            - running
            - succeeded
            - failed
            - cancelled
            - skipped
            - interrupted
        owner:
          anyOf:
            - type: string
              description: 执行本次任务的副本标识；尚未开始时为 null
            - type: 'null'
        started_at:
          anyOf:
            - type: string
              description: 执行开始时间，UTC；尚未开始时为 null
              format: date-time
            - type: 'null'
        completed_at:
          anyOf:
            - type: string
              description: 执行结束时间，UTC；尚未结束时为 null
              format: date-time
            - type: 'null'
        lease_until:
          anyOf:
            - type: string
              description: 当前执行有效期截止时间，UTC；尚未开始时为 null
              format: date-time
            - type: 'null'
        cancel_requested:
          type: boolean
          description: 是否已请求取消本次执行
        output:
          type: string
          description: 执行输出；失败时为空。成功输出最大 1 MiB
        error:
          type: string
          description: 失败、取消、跳过或中断的说明；无错误时为空字符串
        coalesced_from:
          type: string
          description: 补跑合并涉及的最早错过时间，UTC；仅发生触发合并时提供
          format: date-time
      required:
        - cronjob_id
        - run_id
        - revision
        - scheduled_at
        - created_at
        - prompt
        - harness
        - timeout_seconds
        - state
        - owner
        - started_at
        - completed_at
        - lease_until
        - cancel_requested
        - output
        - error
    CronjobRunSummary:
      type: object
      properties:
        run_id:
          type: string
          description: 执行 ID，用于读取或取消该次执行
          pattern: ^[0-9]{13}-[a-f0-9]{20}$
        state:
          type: string
          description: 执行状态
          enum:
            - succeeded
            - failed
            - cancelled
            - skipped
            - interrupted
        scheduled_at:
          type: string
          description: 计划触发时间，UTC
          format: date-time
        completed_at:
          anyOf:
            - type: string
              description: 执行结束时间，UTC；尚未结束时为 null
              format: date-time
            - type: 'null'
        error:
          type: string
          description: 失败、取消、跳过或中断的说明；无错误时为空字符串
      required:
        - run_id
        - state
        - scheduled_at
        - completed_at
        - error
    CronjobMcpServerPublic:
      properties:
        protocol:
          type: string
          enum:
            - streamable-http
            - sse
          title: Protocol
          description: MCP 传输协议
        endpoint:
          type: string
          title: Endpoint
          description: HTTP(S) 地址，不允许用户名、密码、URL 片段或控制字符
        api_key:
          anyOf:
            - type: string
            - type: 'null'
          description: 已配置的非空凭证返回 ********；未提供凭证时可省略或为 null
      additionalProperties: false
      type: object
      required:
        - endpoint
      title: CronjobMcpServerPublic
      description: 该任务可连接的远程 MCP 服务
  securitySchemes:
    RuntimeBearer:
      type: http
      scheme: bearer
      description: 本地未配置网关时可不提供；云部署使用 Runtime API Key 或部署要求的用户池 JWT，不能使用模型 API Key
    HarnessServiceAuth:
      type: http
      scheme: bearer
      description: 服务鉴权 Harness 的 Runtime 访问凭证，例如 Runtime API Key；共享 OAuth 部署不支持后台定时任务

````