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.

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
| Aspect | Pydantic AI example | Sume Agent Completions |
|---|---|---|
| Cancel | In-process | POST /v1/agent-runs/{id}/cancel |
| Resume | Supported by the example | New run only, fresh thread |
| Spend ceiling | Your code | generation_spend_cap_usd required |
| Replay protection | Your code | Idempotency-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
- Pydantic model to Sume output_schema: extra forbid, no defaults
Turn a Pydantic v2 model into a valid Sume Format output_schema: extra=forbid, nullable instead of defaults, and the SumeMediaFile reference. Tested.
- Unit test Sume webhook signature checks in pytest (Python)
A pytest file for HMAC webhook verification: tamper, rotation header, stale timestamp and empty secret, written against Sume's sume-v1 scheme.
- Python 3.14.8 Agent Completions: spend cap, schema, asyncio.run
Start an Agent Completion from Python 3.14.8 with asyncio.run, a required generation_spend_cap_usd, an output_schema and an Idempotency-Key, then poll the run.
- Python 3.14.8 urllib: poll a Sume job with only the stdlib
Python 3.14.8 shipped 30 September 2026. A urllib-only loop for GET /v1/jobs/:id/status with a 20-minute client deadline and no third-party packages.
Written by Sume