Skip to main content
Glama

Cancel a job (free)

codex_job_cancel
Idempotent

Cancel a running background Codex job, gracefully stopping it and removing its worktree. Idempotent and free, with cleanup warnings for any leftover paths; retries are safe.

Instructions

Cancel a running background Codex job.

Asks the worker to shut down gracefully so it tears down its throwaway worktree, then force-kills it if it overstays, and marks the job cancelled (cancelled jobs cannot be resumed). If the worktree could not be removed, cleanup_warnings names the leftover path. Already-terminal jobs are returned unchanged, so cancel is idempotent — a retry after a lost response is safe. Free — no model call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idYesThe job_id from an *_async call or a sync call's meta.job_id; recover lost ids with codex_job_list. Control characters are rejected, not stripped.
workspace_rootNoAbsolute path to the target repo root — pass it (or an MCP root) to target the intended repo; otherwise the call falls back to the server's own cwd and sets meta.workspace_warning. On an active call it selects where Codex works, not what it can read — it is not a read boundary.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed3 schema fields changedv0.19.0
    • changedInput schema / properties / job_id / description
      Previous value: -"The job_id from an *_async call or a sync call's meta.job_id; recover lost ids with codex_job_list."New value: +"The job_id from an *_async call or a sync call's meta.job_id; recover lost ids with codex_job_list. Control characters are rejected, not stripped."
    • addedInput schema / properties / job_id / pattern
      Added value: +"^[^\\x00-\\x1F\\x7F-\\x9F]*$"
    • changedInput schema / properties / workspace_root / description
      Previous value: -"Absolute path to the target repo root — pass it (or an MCP root) to target the intended repo; otherwise the call falls back to the server's own cwd and sets meta.workspace_warning."New value: +"Absolute path to the target repo root — pass it (or an MCP root) to target the intended repo; otherwise the call falls back to the server's own cwd and sets meta.workspace_warning. On an active call it selects where Codex works, not what it can read — it is not a read boundary."
  2. Changed2 schema fields changedv0.17.0
    • changedInput schema / properties / workspace_root / description
      Previous value: -"Absolute path to the target repository root. Pass it (or rely on an MCP root) so the call targets the intended repo; otherwise it falls back to the server's own cwd and meta.workspace_warning is set."New value: +"Absolute path to the target repo root — pass it (or an MCP root) to target the intended repo; otherwise the call falls back to the server's own cwd and sets meta.workspace_warning."
    • changedOutput schema / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "cleanup_warnings": {
      -        "items": {
      -          "type": "string"
      -        },
      -        "type": "array"
      -      },
      -      "deadline_seconds": {
      -        "type": "integer"
      -      },
      -      "detail": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "elapsed_ms": {
      -        "type": "integer"
      -      },
      -      "event_age_ms": {
      -        "anyOf": [
      -          {
      -            "type": "integer"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "events_seen": {
      -        "type": "integer"
      -      },
      -      "expires_at": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "fingerprint": {
      -        "type": "string"
      -      },
      -      "job_id": {
      -        "type": "string"
      -      },
      -      "kind": {
      -        "type": "string"
      -      },
      -      "last_event_at": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "ok": {
      -        "const": true,
      -        "type": "boolean"
      -      },
      -      "poll_after_ms": {
      -        "type": "integer"
      -      },
      -      "result_available": {
      -        "type": "boolean"
      -      },
      -      "server_version": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "started_at": {
      -        "type": "string"
      -      },
      -      "status": {
      -        "enum": [
      -          "running",
      -          "done",
      -          "failed",
      -          "cancelled",
      -          "timeout"
      -        ],
      -        "type": "string"
      -      },
      -      "ttl_seconds": {
      -        "type": "integer"
      -      },
      -      "workspace": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "cwd": {
      -            "type": "string"
      -          },
      -          "workspace_source": {
      -            "anyOf": [
      -              {
      -                "type": "string"
      -              },
      -              {
      -                "type": "null"
      -              }
      -            ]
      -          },
      -          "workspace_warning": {
      -            "anyOf": [
      -              {
      -                "type": "string"
      -              },
      -              {
      -                "type": "null"
      -              }
      -            ]
      -          }
      -        },
      -        "required": [
      -          "cwd"
      -        ],
      -        "type": "object"
      -      }
      -    },
      -    "required": [
      -      "job_id",
      -      "kind",
      -      "status",
      -      "started_at",
      -      "elapsed_ms",
      -      "deadline_seconds",
      -      "ttl_seconds",
      -      "workspace"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "properties": {
      -      "error": {
      -        "description": "Populated error envelope; full schema at resource codex://error-envelope",
      -        "type": "object"
      -      },
      -      "meta": {
      -        "type": "object"
      -      },
      -      "ok": {
      -        "const": false
      -      }
      -    },
      -    "required": [
      -      "ok",
      -      "error",
      -      "meta"
      -    ],
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "cleanup_warnings": {
      +        "items": {
      +          "type": "string"
      +        },
      +        "type": "array"
      +      },
      +      "deadline_seconds": {
      +        "type": "integer"
      +      },
      +      "detail": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "elapsed_ms": {
      +        "type": "integer"
      +      },
      +      "event_age_ms": {
      +        "anyOf": [
      +          {
      +            "type": "integer"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "events_seen": {
      +        "type": "integer"
      +      },
      +      "expires_at": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "fingerprint": {
      +        "type": "string"
      +      },
      +      "job_id": {
      +        "type": "string"
      +      },
      +      "kind": {
      +        "type": "string"
      +      },
      +      "last_event_at": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "ok": {
      +        "const": true,
      +        "type": "boolean"
      +      },
      +      "poll_after_ms": {
      +        "type": "integer"
      +      },
      +      "result_available": {
      +        "type": "boolean"
      +      },
      +      "result_ok": {
      +        "anyOf": [
      +          {
      +            "type": "boolean"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "server_version": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "started_at": {
      +        "type": "string"
      +      },
      +      "status": {
      +        "enum": [
      +          "running",
      +          "done",
      +          "failed",
      +          "cancelled",
      +          "timeout"
      +        ],
      +        "type": "string"
      +      },
      +      "ttl_seconds": {
      +        "type": "integer"
      +      },
      +      "workspace": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "cwd": {
      +            "type": "string"
      +          },
      +          "workspace_source": {
      +            "anyOf": [
      +              {
      +                "type": "string"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          },
      +          "workspace_warning": {
      +            "anyOf": [
      +              {
      +                "type": "string"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          }
      +        },
      +        "required": [
      +          "cwd"
      +        ],
      +        "type": "object"
      +      }
      +    },
      +    "required": [
      +      "job_id",
      +      "kind",
      +      "status",
      +      "started_at",
      +      "elapsed_ms",
      +      "deadline_seconds",
      +      "ttl_seconds",
      +      "result_ok",
      +      "workspace"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "properties": {
      +      "error": {
      +        "description": "Populated error envelope; full schema at resource codex://error-envelope",
      +        "type": "object"
      +      },
      +      "meta": {
      +        "type": "object"
      +      },
      +      "ok": {
      +        "const": false
      +      }
      +    },
      +    "required": [
      +      "ok",
      +      "error",
      +      "meta"
      +    ],
      +    "type": "object"
      +  }
      +]
  3. Changed1 schema field changedv0.11.0
    • changedOutput schema / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "cleanup_warnings": {
      -        "items": {
      -          "type": "string"
      -        },
      -        "type": "array"
      -      },
      -      "deadline_seconds": {
      -        "type": "integer"
      -      },
      -      "detail": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "elapsed_ms": {
      -        "type": "integer"
      -      },
      -      "event_age_ms": {
      -        "anyOf": [
      -          {
      -            "type": "integer"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "events_seen": {
      -        "type": "integer"
      -      },
      -      "expires_at": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "fingerprint": {
      -        "type": "string"
      -      },
      -      "job_id": {
      -        "type": "string"
      -      },
      -      "kind": {
      -        "type": "string"
      -      },
      -      "last_event_at": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ]
      -      },
      -      "ok": {
      -        "const": true,
      -        "type": "boolean"
      -      },
      -      "poll_after_ms": {
      -        "type": "integer"
      -      },
      -      "result_available": {
      -        "type": "boolean"
      -      },
      -      "started_at": {
      -        "type": "string"
      -      },
      -      "status": {
      -        "enum": [
      -          "running",
      -          "done",
      -          "failed",
      -          "cancelled",
      -          "timeout"
      -        ],
      -        "type": "string"
      -      },
      -      "ttl_seconds": {
      -        "type": "integer"
      -      },
      -      "workspace": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "cwd": {
      -            "type": "string"
      -          },
      -          "workspace_source": {
      -            "anyOf": [
      -              {
      -                "type": "string"
      -              },
      -              {
      -                "type": "null"
      -              }
      -            ]
      -          },
      -          "workspace_warning": {
      -            "anyOf": [
      -              {
      -                "type": "string"
      -              },
      -              {
      -                "type": "null"
      -              }
      -            ]
      -          }
      -        },
      -        "required": [
      -          "cwd"
      -        ],
      -        "type": "object"
      -      }
      -    },
      -    "required": [
      -      "job_id",
      -      "kind",
      -      "status",
      -      "started_at",
      -      "elapsed_ms",
      -      "deadline_seconds",
      -      "ttl_seconds",
      -      "workspace"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "properties": {
      -      "error": {
      -        "description": "Populated error envelope; full schema at resource codex://error-envelope",
      -        "type": "object"
      -      },
      -      "meta": {
      -        "type": "object"
      -      },
      -      "ok": {
      -        "const": false
      -      }
      -    },
      -    "required": [
      -      "ok",
      -      "error",
      -      "meta"
      -    ],
      -    "type": "object"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "cleanup_warnings": {
      +        "items": {
      +          "type": "string"
      +        },
      +        "type": "array"
      +      },
      +      "deadline_seconds": {
      +        "type": "integer"
      +      },
      +      "detail": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "elapsed_ms": {
      +        "type": "integer"
      +      },
      +      "event_age_ms": {
      +        "anyOf": [
      +          {
      +            "type": "integer"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "events_seen": {
      +        "type": "integer"
      +      },
      +      "expires_at": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "fingerprint": {
      +        "type": "string"
      +      },
      +      "job_id": {
      +        "type": "string"
      +      },
      +      "kind": {
      +        "type": "string"
      +      },
      +      "last_event_at": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "ok": {
      +        "const": true,
      +        "type": "boolean"
      +      },
      +      "poll_after_ms": {
      +        "type": "integer"
      +      },
      +      "result_available": {
      +        "type": "boolean"
      +      },
      +      "server_version": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ]
      +      },
      +      "started_at": {
      +        "type": "string"
      +      },
      +      "status": {
      +        "enum": [
      +          "running",
      +          "done",
      +          "failed",
      +          "cancelled",
      +          "timeout"
      +        ],
      +        "type": "string"
      +      },
      +      "ttl_seconds": {
      +        "type": "integer"
      +      },
      +      "workspace": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "cwd": {
      +            "type": "string"
      +          },
      +          "workspace_source": {
      +            "anyOf": [
      +              {
      +                "type": "string"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          },
      +          "workspace_warning": {
      +            "anyOf": [
      +              {
      +                "type": "string"
      +              },
      +              {
      +                "type": "null"
      +              }
      +            ]
      +          }
      +        },
      +        "required": [
      +          "cwd"
      +        ],
      +        "type": "object"
      +      }
      +    },
      +    "required": [
      +      "job_id",
      +      "kind",
      +      "status",
      +      "started_at",
      +      "elapsed_ms",
      +      "deadline_seconds",
      +      "ttl_seconds",
      +      "workspace"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "properties": {
      +      "error": {
      +        "description": "Populated error envelope; full schema at resource codex://error-envelope",
      +        "type": "object"
      +      },
      +      "meta": {
      +        "type": "object"
      +      },
      +      "ok": {
      +        "const": false
      +      }
      +    },
      +    "required": [
      +      "ok",
      +      "error",
      +      "meta"
      +    ],
      +    "type": "object"
      +  }
      +]
  4. Changed2 schema fields changedv0.8.0
    • changedInput schema / properties / job_id / description
      Previous value: -"The job_id returned by an *_async call (codex_*_async); recover lost ids with codex_job_list."New value: +"The job_id from an *_async call or a sync call's meta.job_id; recover lost ids with codex_job_list."
    • addedOutput schema / $schema
      Added value: +"https://json-schema.org/draft/2020-12/schema"
  5. First observedv0.5.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Description is rich in behavioral disclosures beyond annotations. It explains the graceful shutdown then force-kill sequence, mentions teardown of worktree, notes that cancelled jobs cannot be resumed, mentions cleanup_warnings for leftover paths, and explicitly states idempotence (retry after lost response is safe). While annotations include idempotentHint=true, the description adds meaningful context about what idempotence means here and how it's implemented. It also mentions 'Free — no model call', which is a cost-related behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is well-structured with clear sentences. It front-loads the action ('Cancel a running background Codex job'), then details the mechanism, then states idempotence and cost. Every sentence earns its place. It's slightly long but each sentence provides distinct value. Could argue for 5, but it's a bit verbose in the middle section.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that the tool has annotations (idempotentHint, destructiveHint=false), a full output schema, and 100% schema coverage, the description is remarkably complete. It explains behavior, failure modes, idempotence, and cost. The only thing it doesn't spell out explicitly is when to use this vs codex_job_consume_result or others, but the title and first sentence already disambiguate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the schema itself already provides detailed descriptions for both parameters. The description goes beyond by telling the agent what job_id is for (from *_async call or meta.job_id), how to recover lost ids, and explains that workspace_root selects where Codex works, not a read boundary. It also preemptively warns about control characters being rejected. This adds meaningful guidance on how to use the parameters correctly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description states exactly what the tool does: cancel a running background Codex job. Uses specific verb 'Cancel' and identifies the resource (background Codex job). Distinguishes from siblings like codex_job_status (which presumably just checks status) and other job-related tools. The 'free' aspect is highlighted in the title and description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description provides clear context for when to use ('running background job') and implicitly excludes already-terminal jobs by stating they are returned unchanged. It doesn't explicitly name alternatives, but the sibling list is long and this tool's scope is clear. It also gives a hint about recovering lost ids with codex_job_list, which is a usage pointer.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/briandconnelly/codex-in-claude'

If you have feedback or need assistance with the MCP directory API, please join our Discord server