claude -p killed by timeout or systemd: the Sume job keeps running
A supervisor that kills claude -p does not cancel the Sume job it started. List jobs, then wait or cancel before retrying, or you pay twice.

If timeout, systemd or another supervisor kills a headless claude -p session, any Sume job it already submitted keeps running and keeps billing. Sume's docs are explicit that a client-side timeout does not cancel a job: you have only stopped watching (Jobs and results, read 2026-10-04). Before you rerun the wrapper, find the job and either wait for it or cancel it.
What changed in Claude Code 2.1.288
The 2.1.288 changelog entry says it fixed headless (-p and SDK) sessions occasionally ignoring SIGTERM when a supervisor such as timeout or systemd sends SIGCONT alongside it (Claude Code changelog, read 2026-10-04). Before the fix a supervised session could outlive its stop signal. After it, the session ends when asked, which makes the question about what it left behind more important, not less.
What the killed session left behind
A generation job is created on the Sume side the moment the paid call is accepted. The job then runs on its own. Killing the process that submitted it does not change its status, and the job is billed as it would be if you were watching.
| Situation | Job state | What to do |
|---|---|---|
| Killed before submit | No job exists | Safe to rerun |
| Killed after submit, during the wait | Job queued or running | Find the id, then wait or cancel |
| Killed after completion | Job completed and billed | Read the result; do not resubmit |
Find it, then decide
List recent jobs with jobs_list over MCP or GET /v1/jobs, then read the one you want with jobs_status. If you still want the output, wait on it. If you do not, cancel it explicitly. Cancelling a job that is already canceled is idempotent and returns the same canceled job, and a job that cannot be canceled runs to completion.
#!/usr/bin/env bash
set -uo pipefail
: "${SUME_API_KEY:?set SUME_API_KEY}"
timeout 900 claude -p "Render the teaser with Sume and wait for the result"
status=$?
if [ "$status" -ne 0 ]; then
echo "claude exited with $status; check Sume jobs before retrying" >&2
curl -sS "https://api.sume.com/v1/jobs" \
-H "Authorization: Bearer $SUME_API_KEY"
fiMake the rerun safe
Give the paid call a deterministic idempotency_key, so the rerun lands on the same key and does not submit a second paid job. On the hosted MCP the key is required on write and paid tools. Do not resubmit the original paid request just because a local timeout fired; read the job first.
- Log the job id as soon as the submit returns.
- Run the wait step with
jobs_wait, which holds at most 55 seconds per call, and loop. - Cancel only when you are sure you do not want the output.
Sources
Related posts
More in Developers
- claude plugin validate: a clean .mcp.json entry for Sume
Claude Code v2.1.281 makes claude plugin validate check .mcp.json entries. A Sume entry needs only the URL https://mcp.sume.com/mcp and no secret.
- Cloudflare AI Search bills from Nov 1: split retrieval from renders
Cloudflare's October 1 changelog makes AI Search GA with usage billing from November 1, 2026. How to keep retrieval costs separate from Sume render costs.
- Cloudflare Sandbox SDK 1.0: run the Sume SDK inside one
The @sume-com/sdk has no runtime dependencies and needs only fetch and WebCrypto, so it can run in a sandbox. Pass the key as an env var, server-side only.
- Cloudflare Worker for Sume webhooks: log fields a dashboard needs
Cloudflare added Workers Observability to Custom Dashboards on Oct 1. A Sume webhook Worker should log event, job_id, outcome and the secret fingerprint.
Written by Sume