Skip to main content
How to cancel long-running ABP operations before they complete.

Overview

Cancellation allows agents to abort long-running operations before they complete. This is essential for operations like:
  • PDF generation for large documents (5-60 seconds)
  • AI operations like summarization (3-30 seconds)
  • Image processing (2-20 seconds)
  • Large file exports (10-120 seconds)
Without cancellation, agents must either wait for completion or disconnect entirely (losing the session).

Why Cancellation Matters

Design Rationale

Without cancellation, agents face a dilemma:
  • Wait: User might cancel the request, but operation keeps running
  • Disconnect: Loses the entire session, must reconnect for next operation
With cancellation, agents can abort specific operations while maintaining the session.

Design Decisions

What We Explicitly Chose NOT to Do

  1. No partial results — Half-processed outputs are typically useless for browser operations
  2. No cancellable capability flag — Adds complexity without clear benefit
  3. No progress-token-based cancellation — Ties cancellation to progress, but you might want to cancel without tracking progress

Protocol Specification

Call ID

Every capability call includes a callId for identification:
If callId is not provided, the agent-side library MUST generate a unique identifier (e.g., UUID).

Cancel Request (Agent → App)

Cancel Response (App → Agent)

Modified Call Response

When a call is cancelled, its response includes a cancelled flag:
The recommended agent-side API uses the standard AbortSignal pattern:

Why AbortSignal?

Developers already use this pattern with fetch():

App-Side Implementation

Apps implement cancellation using AbortController internally:

Example: Cancellable PDF Generation

Transport-Specific Handling

Puppeteer/Playwright

postMessage

WebSocket

Edge Cases

Timing Considerations

  • Cancel arrives before operation starts: Operation is skipped, response has cancelled: true
  • Cancel arrives during operation: Operation is aborted, response has cancelled: true
  • Cancel arrives after completion: Cancel response has cancelled: false, original result is returned

Relationship to Timeout

The timeout option in calls is complementary to cancellation: Both result in cancelled: true in the response. Apps cannot distinguish between timeout-triggered and signal-triggered cancellation (and SHOULD NOT need to).

Using Both Together

Message Flow

Next Steps

Building ABP Apps

Build apps with cancellation support

API Reference

Full API specification

Error Handling

Cancellation error codes