Scenario 2 · History-owned orchestration

Move orchestration state into Temporal

The agent protocol stays the same. Temporal records its decisions, completed results, and next step outside the Worker process.

Direct Codex call
Activity
Investigation method
Child Workflow
Process snapshot
Workflow state
Process restart
Workflow replay
01

Code change · Process start → Workflow start

Start a Workflow before the Worker

The original path starts one process. The Temporal path creates a stable Workflow ID, then starts a Worker for that Workflow.

02

Code change · Orchestrator method → Workflow function

Move the coordinator sequence into a Workflow

The sequence stays in TypeScript. Temporal records each scheduled command and completed result in Event History.

03

Code change · Method call → Child Workflow

Replace subagent methods with Child Workflows

Each investigation gets a stable Child Workflow ID. The parent still waits for the same three results.

04

Code change · Direct effect → Activity

Put external work in Activities

Codex and the test runner perform external work. Activities give that work a timeout, retry policy, and cancellation signal.

05

Code change · Memory callback → Activity heartbeat

Save retry hints in heartbeats

The Activity heartbeats its Codex thread ID and recent progress. A retry reads those details before it starts work.

06

Code change · Fresh run → Replay and continue

Restart compute against the same history

The baseline creates a new workspace. The Temporal path starts only a replacement Worker, so it does not create a second Workflow.

The replacement Worker replays history

  1. Temporal supplies completed Workflow and Child Workflow results.
  2. Temporal retries unfinished Activities.
  3. Heartbeat details help an Activity resume its Codex thread.
  4. The Workflow continues with the next recorded step.

Event History preserves orchestration progress.

Heartbeats preserve retry hints for active work.

Idempotency still protects external side effects.

Run the demo →