LAYER 05 · Scale beyond one agent

Workflow engine and durable schedules

The model writes bounded orchestration scripts; schedules deliver future reminders as normal follow-ups to the same session

22 min3 source anchorsupstream@47f9438
worker-thread script + agent() fan-out + durable wakeup
The question this chapter resolves

Why can workflow, job, and schedule not collapse into one background-task concept?

Build intuition

A workflow is the director's shooting plan, a job is the live camera status, and a schedule is the future call sheet that restarts work.

MECHANISM

Mechanism

Each context has one ctx.workflowEngine implementation. worker-thread runs model code in an isolated VM with agent(), phase(), JSON args, and total/concurrency limits.

Schedules persist after/at/every records inside one session and deliver due reminders as ordinary followups. Repetition is fixed-rate, at least five minutes, and missed intervals collapse to the latest due occurrence.

Step 1 of 6

Submit script and meta

Plain-JSON identity and args are schema-validated first.

INVARIANTS

What extensions must preserve

  • Workflow result never rejects; it settles with a closed stopReason
  • Dispose force-terminates a stuck worker after bounded grace
  • Schedule never implicitly reads environment time zone
FAILURE MODES

The tempting wrong turns

  • ×Evaluating workflow meta as code
  • ×Replaying every missed schedule interval into a storm
  • ×Treating dispatch as user acknowledgement
VERIFY IN SOURCE

Do not trust the conclusion—verify it

These anchors are pinned to official deepseek-harness@47f9438; account for later breaking changes when reading current upstream.

KNOWLEDGE CHECK

Pause for ten seconds before revealing

Why must Schedule at strings include a UTC offset?

Why the next chapter follows

The system still needs external capability discovery. Skills, MCP, LSP, and Web enter through distinct seams rather than bypassing the tool pipeline.

Learn DeepSeek Harness

An independent learning project. Explanations derive from source; upstream remains authoritative.