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
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.
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.
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.
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.
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.
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.
Recovery
The replacement Worker replays history
- Temporal supplies completed Workflow and Child Workflow results.
- Temporal retries unfinished Activities.
- Heartbeat details help an Activity resume its Codex thread.
- 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 →