Skip to content
masterclass Buddy

LangGraph · Decorator

task

The @task decorator defines a unit of work in LangGraph. Tasks can run sync or async, return futures, support retries, caching, and timeouts, and save results for checkpoint-based resumption.

Last updated

Since
1.2.19

Syntax

task(__func_or_none__: Callable[P, Awaitable[T]] | Callable[P, T] | None = None, *, name: str | None = None, retry_policy: RetryPolicy | Sequence[RetryPolicy] | None = None, cache_policy: CachePolicy[Callable[P, str | bytes]] | None = None, timeout: float | timedelta | TimeoutPolicy | None = None, **kwargs: Unpack[DeprecatedKwargs])

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • entrypoint
  • StateGraph
  • RetryPolicy
  • CachePolicy
  • TimeoutPolicy
  • NodeTimeoutError
  • checkpointer

Source: task | langgraph | LangChain Reference. Checked 2026-11-03.