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

# Cancel a running turn in a session

> Cancel the running last turn for a session.



## OpenAPI

````yaml /gateway-agent-harness-openapi.json post /v1/agents/sessions/{sessionId}/cancel
openapi: 3.1.0
info:
  title: TrueFoundry Agent Harness
  description: Stateful agent execution API.
  version: 0.1.0
servers:
  - url: '{scheme}://{gatewayBaseURL}/{tenantName}'
    variables:
      scheme:
        default: https
        enum:
          - http
          - https
      gatewayBaseURL:
        default: gateway.truefoundry.ai
        description: Gateway host. Override for self-hosted deployments.
      tenantName:
        default: truefoundry
        description: Tenant identifier
    description: Gateway base URL (per-tenant)
security:
  - AuthorizationBearer: []
paths:
  /v1/agents/sessions/{sessionId}/cancel:
    post:
      tags:
        - Agent Harness
      summary: Cancel a running turn in a session
      description: Cancel the running last turn for a session.
      parameters:
        - schema:
            type: string
            minLength: 1
            description: Session identifier (<ulid>.<zone>).
            example: 01arz3ndektsv4rrffq69g5fav.g
          required: true
          name: sessionId
          in: path
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelSessionRequest'
      responses:
        '200':
          description: Turn cancelled.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelSessionResponse'
        '400':
          description: Redis store unavailable or invalid session id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
        '412':
          description: >-
            Requested action cannot be performed on session because it is no
            longer usable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
        '424':
          description: Timed out waiting for cancellation on remote executor.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestErrorResponse'
components:
  schemas:
    CancelSessionRequest:
      type: object
      properties: {}
    CancelSessionResponse:
      type: object
      properties: {}
    RequestErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type:
                - string
                - 'null'
            param:
              type:
                - string
                - 'null'
          required:
            - message
      required:
        - error
  securitySchemes:
    AuthorizationBearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````