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

# Cancel Voice Agent Test Batch

> Cancel the runs of a batch that have not started.



## OpenAPI

````yaml post /v1/agent/agents/{agent_id}/test-batches/{batch_id}/cancel
openapi: 3.1.0
info:
  title: FishAudio OpenAPI
  version: '1'
servers:
  - description: Fish Audio API
    url: https://api.fish.audio
security: []
tags: []
paths:
  /v1/agent/agents/{agent_id}/test-batches/{batch_id}/cancel:
    post:
      tags:
        - Agent Tests
      summary: Cancel Test Batch
      description: >-
        Cancel the runs of a batch that have not started. Send no body. Runs in

        status `queued` end as `cancelled`, with the time of the cancel as their

        `finished_at`, and are not billed. Runs in progress are not interrupted.

        They finish with their result and are billed, and the batch turns

        `completed` once they have. The answer is the batch with its counts
        after

        the cancel and an empty `runs`. Cancelling a batch that has completed,
        or

        that has no queued run left, changes nothing and answers 200.


        Cancelled runs are counted in the batch's `cancelled`, not in `errors`,

        so a gate on a batch's counts has to look at `cancelled` as well. A

        batch that was cancelled before anything failed has `failed` and

        `errors` both 0.
      parameters:
        - in: path
          name: agent_id
          description: ''
          required: true
          schema:
            title: Agent Id
            type: string
          deprecated: false
        - in: path
          name: batch_id
          description: ''
          required: true
          schema:
            title: Batch Id
            type: string
          deprecated: false
      responses:
        '200':
          description: Request fulfilled, document follows
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  batch_id:
                    title: Batch Id
                    type: string
                  agent_id:
                    title: Agent Id
                    type: string
                  name:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    description: The name of the batch, null when it has none.
                    title: Name
                  status:
                    description: running until every run has finished.
                    enum:
                      - running
                      - completed
                    title: Status
                    type: string
                  completed:
                    title: Completed
                    type: boolean
                  run_count:
                    description: >-
                      Every run of the batch, one per test and repeat. It is
                      `queued` + `running` + `passed` + `failed` + `errors` +
                      `cancelled`.
                    title: Run Count
                    type: integer
                  queued:
                    description: Runs that have not started.
                    title: Queued
                    type: integer
                  running:
                    description: Runs in progress.
                    title: Running
                    type: integer
                  passed:
                    title: Passed
                    type: integer
                  failed:
                    title: Failed
                    type: integer
                  errors:
                    description: Runs in status `error`, which finished without a verdict.
                    title: Errors
                    type: integer
                  cancelled:
                    description: >-
                      Runs in status `cancelled`. They are not counted in
                      `errors`.
                    title: Cancelled
                    type: integer
                  pass_rate:
                    anyOf:
                      - type: number
                      - type: 'null'
                    default: null
                    description: >-
                      passed / (passed + failed), null until a run passed or
                      failed. Runs without a verdict (`error`, `cancelled`)
                      never judged the agent and are left out.
                    title: Pass Rate
                  cancelled_at:
                    anyOf:
                      - format: date-time
                        type: string
                      - type: 'null'
                    default: null
                    description: When the batch was first cancelled, null if it never was.
                    title: Cancelled At
                  trigger_source:
                    description: 'Where the batch was started: the console or the API.'
                    enum:
                      - console
                      - api
                    title: Trigger Source
                    type: string
                  created_at:
                    description: When the first run was created.
                    format: date-time
                    title: Created At
                    type: string
                  finished_at:
                    anyOf:
                      - format: date-time
                        type: string
                      - type: 'null'
                    default: null
                    description: >-
                      When the last run finished, null until the batch
                      completed.
                    title: Finished At
                  runs:
                    description: >-
                      The runs of the batch. The list is empty where the runs
                      are left out, with `include_runs=false` and in the answers
                      to a cancel and to an update.
                    items:
                      $ref: '#/components/schemas/PublicAgentTestRun'
                    title: Runs
                    type: array
                required:
                  - batch_id
                  - agent_id
                  - status
                  - completed
                  - run_count
                  - queued
                  - running
                  - passed
                  - failed
                  - errors
                  - cancelled
                  - trigger_source
                  - created_at
                  - runs
                type: object
        '401':
          description: No permission -- see authorization schemes
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
        '404':
          description: Nothing matches the given URI
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
        '503':
          description: The server cannot process the request due to a high load
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
      security:
        - BearerAuth: []
components:
  schemas:
    PublicAgentTestRun:
      properties:
        run_id:
          title: Run Id
          type: string
        test_id:
          title: Test Id
          type: string
        agent_id:
          title: Agent Id
          type: string
        batch_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Batch Id
        test_type:
          enum:
            - next_reply
            - tool
            - simulation
          title: Test Type
          type: string
        repeat_index:
          default: 0
          description: Which repeat of the test in its batch this run is.
          title: Repeat Index
          type: integer
        status:
          enum:
            - queued
            - running
            - passed
            - failed
            - error
            - cancelled
          title: Status
          type: string
        needs_review:
          default: false
          description: The judge could not decide, or a tool call had no mock answer.
          title: Needs Review
          type: boolean
        error:
          default: ''
          title: Error
          type: string
        judge:
          anyOf:
            - $ref: '#/components/schemas/AgentTestJudge'
            - type: 'null'
          default: null
          description: >-
            The model that judged the run and the reasoning level it judged at.
            Null on a `tool` test, which has no judge, on a run that ended
            before its judge was asked, and on `next_reply` runs from before the
            field existed. Simulation runs from before the judge could be chosen
            have a null level.
        usage:
          $ref: '#/components/schemas/PublicAgentTestRunUsage'
        created_at:
          format: date-time
          title: Created At
          type: string
        started_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          default: null
          title: Started At
        finished_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          default: null
          title: Finished At
        agent_reply:
          default: ''
          description: The reply a scripted test judged.
          title: Agent Reply
          type: string
        judge_reasoning:
          default: ''
          title: Judge Reasoning
          type: string
        config_hash:
          default: ''
          description: The agent draft's config hash the run tested.
          title: Config Hash
          type: string
        latency_ms:
          default: 0
          title: Latency Ms
          type: integer
        simulation_result:
          anyOf:
            - $ref: '#/components/schemas/AgentTestSimulationResult'
            - type: 'null'
          default: null
        channel:
          anyOf:
            - enum:
                - web_voice
                - phone_inbound
                - phone_outbound
              type: string
            - type: 'null'
          default: null
          description: The channel the run played.
          title: Channel
        turns_used:
          default: 0
          title: Turns Used
          type: integer
        ended_by:
          anyOf:
            - enum:
                - agent
                - user
                - transfer
                - max_turns
                - timeout
                - error
              type: string
            - type: 'null'
          default: null
          title: Ended By
        mock_gaps:
          items:
            $ref: '#/components/schemas/AgentTestMockGap'
          title: Mock Gaps
          type: array
      required:
        - run_id
        - test_id
        - agent_id
        - test_type
        - status
        - created_at
      title: PublicAgentTestRun
      type: object
    AgentTestJudge:
      additionalProperties: false
      description: |-
        The model that judges a `next_reply` or `simulation` test, and how much
        it reasons before its verdict.
      properties:
        model:
          description: >-
            One of the models `GET /v1/agent/llm-models` lists with
            `test_judge`.
          maxLength: 200
          minLength: 1
          title: Model
          type: string
        reasoning_level:
          anyOf:
            - enum:
                - 'off'
                - low
                - medium
                - high
                - very_high
              type: string
            - type: 'null'
          default: null
          description: >-
            One of the levels `test_judge.reasoning_levels` lists for the model.
            Null reasons at the model's default level.
          title: Reasoning Level
      required:
        - model
      title: AgentTestJudge
      type: object
    PublicAgentTestRunUsage:
      properties:
        agent_replies:
          default: 0
          title: Agent Replies
          type: integer
        cost_usd:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          description: >-
            What the run was charged in USD. `0` on a finished run that is not
            charged. Null until the run's charge is settled.
          title: Cost Usd
        platform_fee:
          anyOf:
            - $ref: '#/components/schemas/PublicAgentTestRunPlatformFee'
            - type: 'null'
          default: null
          description: The fee per agent reply. Null unless charged.
        llm:
          description: >-
            LLM tokens, one entry per participant and model, by token category.
            With `platform_fee` they add up to `cost_usd`. Empty unless charged.
          items:
            $ref: '#/components/schemas/PublicAgentTestRunLLMCharge'
          title: Llm
          type: array
      title: PublicAgentTestRunUsage
      type: object
    AgentTestSimulationResult:
      description: |-
        The simulation run's result: what was said, what the agent called,
        the deterministic assertions and the judge's per-condition verdicts.
      properties:
        transcript:
          items:
            $ref: '#/components/schemas/AgentTestTranscriptMessage'
          title: Transcript
          type: array
        tool_calls:
          items:
            $ref: '#/components/schemas/AgentTestToolCallRecord'
          title: Tool Calls
          type: array
        assertions:
          items:
            $ref: '#/components/schemas/AgentTestAssertionResult'
          title: Assertions
          type: array
        conditions:
          items:
            $ref: '#/components/schemas/AgentTestConditionResult'
          title: Conditions
          type: array
        summary:
          default: ''
          title: Summary
          type: string
        passed:
          default: false
          title: Passed
          type: boolean
        llm_endpoint_errors:
          items:
            $ref: '#/components/schemas/AgentSessionLlmEndpointError'
          title: Llm Endpoint Errors
          type: array
      title: AgentTestSimulationResult
      type: object
    AgentTestMockGap:
      description: |-
        Calls of one tool the test prepared no answer for. A run with a
        gap never passes cleanly: it fails with needs_review.
      properties:
        tool_name:
          title: Tool Name
          type: string
        tool_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Tool Id
        tool_type:
          anyOf:
            - enum:
                - webhook
                - client
                - integration
                - system
              type: string
            - type: 'null'
          default: null
          title: Tool Type
        source:
          enum:
            - missing
            - unmatched
          title: Source
          type: string
        calls:
          default: 0
          title: Calls
          type: integer
      required:
        - tool_name
        - source
      title: AgentTestMockGap
      type: object
    PublicAgentTestRunPlatformFee:
      properties:
        rate_usd:
          description: USD per agent reply.
          title: Rate Usd
          type: string
        amount_usd:
          description: '`agent_replies` times `rate_usd`.'
          title: Amount Usd
          type: string
      required:
        - rate_usd
        - amount_usd
      title: PublicAgentTestRunPlatformFee
      type: object
    PublicAgentTestRunLLMCharge:
      properties:
        participant:
          description: 'Whose tokens: the agent, the simulated user, or the judge.'
          enum:
            - agent
            - simulated_user
            - judge
          title: Participant
          type: string
        model:
          title: Model
          type: string
        amount_usd:
          description: What these tokens charged, in USD.
          title: Amount Usd
          type: string
        input:
          anyOf:
            - $ref: '#/components/schemas/PublicAgentTestRunTokenCharge'
            - type: 'null'
          default: null
        cache_read:
          anyOf:
            - $ref: '#/components/schemas/PublicAgentTestRunTokenCharge'
            - type: 'null'
          default: null
        cache_write_5m:
          anyOf:
            - $ref: '#/components/schemas/PublicAgentTestRunTokenCharge'
            - type: 'null'
          default: null
        cache_write_1h:
          anyOf:
            - $ref: '#/components/schemas/PublicAgentTestRunTokenCharge'
            - type: 'null'
          default: null
        output:
          anyOf:
            - $ref: '#/components/schemas/PublicAgentTestRunTokenCharge'
            - type: 'null'
          default: null
      required:
        - participant
        - model
        - amount_usd
      title: PublicAgentTestRunLLMCharge
      type: object
    AgentTestTranscriptMessage:
      properties:
        role:
          enum:
            - user
            - agent
          title: Role
          type: string
        text:
          default: ''
          title: Text
          type: string
        turn_id:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Turn Id
        node_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Node Id
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Created At
        seq:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Seq
      required:
        - role
      title: AgentTestTranscriptMessage
      type: object
    AgentTestToolCallRecord:
      description: >-
        One tool the agent invoked during the simulation, as the runtime ledger
        recorded it.
      properties:
        id:
          default: ''
          title: Id
          type: string
        tool_name:
          default: ''
          title: Tool Name
          type: string
        tool_source:
          default: ''
          title: Tool Source
          type: string
        input:
          additionalProperties:
            $ref: '#/components/schemas/JsonValue'
          title: Input
          type: object
        status:
          default: ''
          title: Status
          type: string
        output:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Output
        error:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Error
        mocked:
          default: false
          title: Mocked
          type: boolean
        mock_source:
          anyOf:
            - enum:
                - test
                - tool
                - missing
                - unmatched
                - real
              type: string
            - type: 'null'
          default: null
          title: Mock Source
        node_id:
          default: ''
          title: Node Id
          type: string
        turn_id:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Turn Id
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Created At
        seq:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Seq
      title: AgentTestToolCallRecord
      type: object
    AgentTestAssertionResult:
      properties:
        kind:
          enum:
            - tool_call
            - forbidden_tool
            - ended_by
          title: Kind
          type: string
        target:
          title: Target
          type: string
        tool_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Tool Id
        tool_type:
          anyOf:
            - enum:
                - webhook
                - client
                - integration
                - system
              type: string
            - type: 'null'
          default: null
          title: Tool Type
        passed:
          title: Passed
          type: boolean
        detail:
          default: ''
          title: Detail
          type: string
      required:
        - kind
        - target
        - passed
      title: AgentTestAssertionResult
      type: object
    AgentTestConditionResult:
      properties:
        name:
          title: Name
          type: string
        result:
          enum:
            - success
            - failure
            - unknown
          title: Result
          type: string
        rationale:
          default: ''
          title: Rationale
          type: string
      required:
        - name
        - result
      title: AgentTestConditionResult
      type: object
    AgentSessionLlmEndpointError:
      description: |-
        One failed reply from the customer's own LLM endpoint, after the
        platform's single retry within the request, or one reply the model's
        provider refused (a platform model's included).

        - http_error: the endpoint answered with a non-2xx status.
        - timeout: no response within the request timeout.
        - connection_error: the request got no answer. `reason` is dns_failed,
          connection_refused, connection_reset, tls_failed, address_not_allowed
          (an address the platform does not call) or unknown.
        - invalid_response: a 2xx response that was not a usable reply. `reason`
          is not_event_stream (a streamed request answered with something else),
          stream_incomplete (the stream ended without a finish_reason, usage or
          output), empty_reply (no text and no tool call), refused (the model's
          provider finished the reply as a refusal, a content filter or a policy
          block: `response_body` is what it said) or unknown.
      properties:
        occurred_at:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Occurred At
        turn_id:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Turn Id
        type:
          enum:
            - http_error
            - timeout
            - connection_error
            - invalid_response
          title: Type
          type: string
        reason:
          anyOf:
            - enum:
                - dns_failed
                - connection_refused
                - connection_reset
                - tls_failed
                - address_not_allowed
                - not_event_stream
                - stream_incomplete
                - empty_reply
                - refused
                - unknown
              type: string
            - type: 'null'
          default: null
          title: Reason
        status_code:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Status Code
        response_body:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Response Body
        duration_ms:
          anyOf:
            - type: integer
            - type: 'null'
          default: null
          title: Duration Ms
        consecutive_failures:
          title: Consecutive Failures
          type: integer
      required:
        - type
        - consecutive_failures
      title: AgentSessionLlmEndpointError
      type: object
    PublicAgentTestRunTokenCharge:
      properties:
        tokens:
          title: Tokens
          type: integer
        amount_usd:
          title: Amount Usd
          type: string
      required:
        - tokens
        - amount_usd
      title: PublicAgentTestRunTokenCharge
      type: object
    JsonValue: {}
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.