Pydantic AI cancel_and_resume vs Sume agent run cancel

Pydantic AI 2.54.0 shows cancel_and_resume. Sume Agent Completions have a different cancel: a run is cancelled by id and resumes only as a new run.

5 min readSume
All posts

Do not expect a cancelled Sume agent run to resume. Pydantic AI v2.54.0 (2026-10-03) adds a cancel_and_resume example for its own agent loop, but Sume's Agent Completions cancel a run with POST /v1/agent-runs/{id}/cancel and every new completion starts in a fresh thread.

If your Pydantic AI agent calls Sume as a tool, resume on your side and start a new Sume run with the context it needs.

Two different cancels

Pydantic AI's example cancels and continues a local run. Sume's cancel ends a remote run identified by its agrun_ id. The docs state there is no continuing by thread_id.

At a glance

Cancel and resume behaviour, read 2026-10-03.
AspectPydantic AI exampleSume Agent Completions
CancelIn-processPOST /v1/agent-runs/{id}/cancel
ResumeSupported by the exampleNew run only, fresh thread
Spend ceilingYour codegeneration_spend_cap_usd required
Replay protectionYour codeIdempotency-Key, idempotency_hit: true

A tool wrapper that behaves

Create the run with POST https://api.sume.com/v1/agent/completions. Send generation_spend_cap_usd, which is required, and an Idempotency-Key. Poll GET /v1/agent-runs/{id} or take the agent.run.terminal webhook.

If you cancel, treat the run as finished and pass any partial findings into the next instruction yourself.

curl -X POST https://api.sume.com/v1/agent/completions \
  -H "Authorization: Bearer $SUME_API_KEY" \
  -H "Idempotency-Key: run-2026-10-03-a" \
  -H "Content-Type: application/json" \
  -d '{"instruction":"Draft three product shots","generation_spend_cap_usd":5}'

Limits and what is not verified

I read the release notes, not the example code, and did not run it. The curl body shows required fields only; check the Agent Completions docs for output_schema and attachments.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume