Async Tasks (SEP-1686) — Call-Now, Fetch-Later for Long-Running Work

Real agent work takes minutes to hours: CI runs, deep-research synthesis, batch exports. Synchronous tool calls drop connections, time out, or block the UI. SEP-1686, merged in 2025-11-25, adds a Tasks primitive: any request can be augmented to become a task, and the result can be fetched later or streamed via state notifications. Drift-risk note: Tasks are experimental through H1 2026; SDK surface is still being designed around the spec.

Build 1.3 hr Python (stdlib, async task state machine)

Prerequisites: Phase 13 · 07 (MCP server), Phase 13 · 09 (transports)

#Learning Objectives

  • Identify when to promote a tool from synchronous to task-augmented (>30 seconds of server-side work).
  • Walk the task lifecycle: working → input_required → completed / failed / cancelled.
  • Persist task state so crashes do not lose in-flight work.
  • Poll tasks/status and fetch tasks/result correctly.
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.