Skip to content

Migrate agent dispatch onto the conversation worker #882

Description

@dcramer

Objective

Prove the shared conversation turn workflow by migrating scheduled/plugin agent-dispatch onto it and deleting the independent dispatch execution lifecycle.

agent-dispatch is the existing second durable agent runtime: it currently owns a dispatch record version, attempt counter, slice lease, callback loop, incomplete-work index, heartbeat recovery, continuation scheduling, delivery guard, and terminalization path.

Scope

  • Keep the dispatch record only for plugin-facing idempotency, request metadata, status, and result projection.
  • Append each dispatch input to the normal conversation mailbox with a stable idempotency key.
  • Before acknowledging that mailbox input, persist a small dispatch/task reference plus the exact actor, credential subject, execution destination, and completion behavior required to restore later slices.
  • Execute new and resumed dispatch turns under the normal conversation lease and worker decision loop from Unify new and resumed turns in the conversation worker #876.
  • Preserve the dispatch actor, credential subject, source, destination authority, visibility, configuration, tool context, isolated conversation identity, and stable turn identity.
  • Preserve existing Slack completion behavior while expressing it as a completion target of the shared turn workflow.
  • Recover timeout, worker loss, queue redelivery, and missing wakes through conversation execution.
  • Remove dispatch-owned execution status/lease authority, callback continuation loop, incomplete index, and core heartbeat recovery after parity.
  • Keep plugin heartbeat responsible only for discovering/scheduling plugin work.

Completion

  • Dispatch input is durable mailbox work before a queue wake is sent.
  • After mailbox acknowledgement, a later execution slice can restore dispatch authority and completion behavior from conversationId plus durable active-turn state; callback payloads are not runtime context.
  • Provider-backed conversations and dispatches use the same lease, start/resume decision, session records, terminalization, and recovery workflow.
  • Dispatch queue redelivery and stale work are idempotent.
  • One dispatch produces one terminal projection and does not post its Slack result twice.
  • Authorization blocking and credential delegation remain bounded exactly as before.
  • Existing plugin dispatch APIs and projections remain behavior-compatible.
  • The dispatch lease, callback loop, incomplete index, and heartbeat recovery are deleted.
  • Integration coverage proves success, blocked authorization, timeout continuation, duplicate wake/callback compatibility during cutover, delivery fencing, and worker recovery.

Non-goals

  • Subagent bindings, invocation-result delivery, or model-facing delegation.
  • Keeping a generic dispatch runner after migration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions