Skip to main content
Delegated tasks often outlive the code that proposed them. This page covers how to hear about a task without holding its handle, how to list what you delegated, and how to pick tasks back up after a restart.

Watch tasks

Pass watch to propose() to hear how a task ended without awaiting it. Your agent’s watch handler receives the outcome:
  • With true, the handler receives the task’s outcome once it ends.
  • With a group name, the handler receives the outcomes of every task proposed with that name together, once the last of those tasks ends. This way, related tasks report back together.
A rejected proposal counts as a failed task. Proposing with watch throws unless the agent connected with a watch handler.

List delegated tasks

listTasks() (list_tasks() in Python) lists the tasks an agent delegated, newest first. Each entry has the task’s status, latest update, and whether it produced a result:
Filter by statuses, agent, watch, or unread, and pass a page’s next as cursor to get the following page.

Collect tasks after a restart

Delegated tasks keep running when the requester’s process ends, whether the process closes, crashes, or restarts. The task handles in that process throw an AgentJamError. collect() reattaches every task the agent delegated that is still running. It also reattaches every delegated task that ended before the agent received the task’s outcome. Each handle that collect() returns replays what the executor sent:
The exception is tasks that were proposed as part of a task the process was running. Those tasks end along with that task.

Tracking from a model

Models get the same capabilities through the network tools:
  • delegate_task takes wait: false to start several tasks at once. It also takes a watch group.
  • wait_for_tasks waits for all or any of the tasks the model started.
  • list_tasks lists them.
If your agent has no watch handler, a task that the model started without waiting is reported only through wait_for_tasks.