Skip to content

Instantly share code, notes, and snippets.

@ccarvalho-eng
Created May 16, 2026 16:56
Show Gist options
  • Select an option

  • Save ccarvalho-eng/04ae0c1a9b6d549de9906c6df206f4b6 to your computer and use it in GitHub Desktop.

Select an option

Save ccarvalho-eng/04ae0c1a9b6d549de9906c6df206f4b6 to your computer and use it in GitHub Desktop.

A workflow run becomes a durable workflow agent. The agent owns orchestration state for one run: current projection, runnable steps, dependency readiness, pause/resume/cancel decisions, and terminal status. It does not “do” step work directly. It records durable intent and coordinates dispatch.

A dispatch agent owns queue-side execution intent: scheduled attempts, claims, leases, heartbeats, retries, completion, and stale worker recovery.

IntentLedger can then become the default durable executor underneath that dispatch side, while Squid Mesh keeps the executor boundary pluggable.

flowchart TD
  Host[Host app / API / Scheduler] --> SM[Squid Mesh public API]

  SM --> WR[Workflow Run Agent]
  WR --> J[(Durable Journal / Jido.Storage)]
  WR --> P[Run Projection]

  WR -->|append runnable intent| DA[Dispatch Agent]
  DA --> J
  DA -->|enqueue / claim / heartbeat / complete| IL[IntentLedger Executor]

  IL --> Worker[Step Worker]
  Worker --> Step[Step / Action / Tool]
  Step --> Worker

  Worker -->|result / failure / retry signal| IL
  IL --> DA
  DA -->|attempt completed / failed / retry scheduled| J
  J --> WR

  WR -->|next runnable / pause / complete / fail| J
  WR --> Inspect[Inspection / Explanation Read Model]
Loading

A slightly more concrete “one run” view:

sequenceDiagram
  participant Host
  participant WorkflowAgent as Workflow Run Agent
  participant Journal as Durable Journal
  participant DispatchAgent as Dispatch Agent
  participant Ledger as IntentLedger
  participant Worker as Step Worker

  Host->>WorkflowAgent: start run
  WorkflowAgent->>Journal: append run_started
  WorkflowAgent->>Journal: append attempt_scheduled intent
  WorkflowAgent->>DispatchAgent: schedule runnable

  DispatchAgent->>Journal: append attempt_scheduled
  DispatchAgent->>Ledger: enqueue durable work

  Ledger->>Worker: deliver attempt
  Worker->>Ledger: heartbeat / complete / fail
  Ledger->>DispatchAgent: attempt result

  DispatchAgent->>Journal: append attempt_completed or attempt_failed
  WorkflowAgent->>Journal: read/rebuild projection
  WorkflowAgent->>WorkflowAgent: decide next transition

  alt more steps
      WorkflowAgent->>DispatchAgent: schedule next runnable
  else terminal
      WorkflowAgent->>Journal: append run_completed or run_failed
  end
Loading

And the mental model:

flowchart LR
    W[Workflow Definition] --> A[Workflow Run Agent]
    A -->|decides what should happen| Intent[Durable Intent]
    Intent --> D[Dispatch Agent]
    D -->|decides who may execute| Claim[Claim + Lease + Heartbeat]
    Claim --> Exec[Executor / IntentLedger]
    Exec --> Result[Step Result]
    Result --> A
Loading

So: workflow as agent means the workflow run becomes the durable decision-maker. IntentLedger as executor means step execution, leases, redelivery, and worker recovery move to a dedicated durable execution layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment