Skip to content
Flows
Implement the Six Core Orchestration Patterns
Agent Architecture120-180 minutes
0/4 steps0%

Step 1 of 4

Build the shared lifecycle infrastructure

Six patterns, one chassis: registration, state, delivery, cleanup.

Prompt capsule

Implement the agent lifecycle layer all patterns share. Registration: every dispatched child gets an id, a state (foreground/background/completed/failed/cancelled), and its own cancellation scope - a child's abort control must be independent so cancelling the parent's current step does not kill background workers. Delivery: completed children enqueue their report through one notification path that inserts it into the parent's next turn as visible content - this is the only way results 'exist'. Promotion: a foreground child races its next-step promise against a background signal; when promoted, execution restarts in background mode and the parent receives a task id instead of blocking. Transcripts: persist every child's messages incrementally (an append-only chain keyed by message ids) - this enables resume and post-hoc debugging. Cleanup: a single finally-path releasing everything a child acquired (connections, temp files, watchers, tasks) on every exit route.

Paste into Claude · Complete implementation prompt with explicit requirements

Expected after this step

A lifecycle layer with independent cancellation, one delivery path, promotion, transcripts, and total cleanup.

Should not happen

  • Results delivered to a log nobody reads instead of the parent's next turn
  • Background children killed accidentally by the parent's cancellation signal
  • Cleanup on the happy path only, leaking sessions/files/connections on errors
  • Implicit communication assumptions - agents 'reporting' in text no other agent receives

Verify before continuing

Do not move on until every check is true. The complete button stays locked until then.

Do not continue if…

  • !Results delivered to a log nobody reads instead of the parent's next turn
  • !Background children killed accidentally by the parent's cancellation signal
  • !Cleanup on the happy path only, leaking sessions/files/connections on errors
  • !Implicit communication assumptions - agents 'reporting' in text no other agent receives

If the AI messes this up

Use this when the AI fakes progress or breaks the feature. It forces a real fix.

Background children die when the user cancels the parent's step. Your cancellation scopes are shared - give each child its own controller at registration and have the parent's cancel signal exclude background ids explicitly.

Your notes for this step