Static reading edition · s04-05
Manage background work without losing its state
Continue independent work while monitoring delegated tasks and wait for results before relying on them.
Understand the approach
Background delegation means a child can work while the parent handles an independent activity. It does not establish completion, persistence through every interruption, recurring execution or resource cleanup. For this capstone, a worker can implement one bounded module while the parent prepares the integration checklist from CONTRACT.md. The parent must still wait for the required implementation output before accepting the combined candidate.
Current Codex clients expose subagent activity, and the CLI provides /subagents for inspecting and switching threads. App and IDE controls can differ. Use the actual client's controls and record only observed states. Do not import Claude background front matter, Ctrl+B behavior or environment flags. A child that needs a fresh approval in a non-interactive situation may fail rather than opening a dialog; report that concrete gap instead of inventing its result.
The local simulate.cjs program is deliberately different: it deterministically prints work-package handoffs and runs the supplied reference integration. Its actualAgentsSpawned field is false. Use it to understand ownership and dependencies, then label any optional real Codex run separately. If a worker finishes before you observe a running state, report dispatch and return only. Recheck the resulting code version, because an earlier completion message does not prove later files still meet the contract.
In the app, open the child thread shown in main-chat activity, inspect its latest file/result, then ask the main chat to steer or stop that named child if needed. CLI switches threads with /subagents; the IDE panel depends on the client. Try a concrete error: a worker starts editing report.cjs despite owning normalization. Stop the overlap, preserve useful work, assign report.cjs one owner and rerun combined checks on the final files. Stopping a conversation does not rewind file edits. This dispatch→inspection→steering→checked return uses actual Codex controls rather than Claude-specific background shortcuts.
Background work keeps its identity until authoritative completion
A dispatched task is running or waiting until its real handle reports completion, failure, or required input. A polling timeout is a reason to inspect or wait again, not evidence that a duplicate task should be started.
Practice and acceptance
A local simulation can teach dependency states; actual agent dispatch, waiting and return need actual client observations.
About your environment
Checked 21 October 2026. Background controls and interactive approvals vary by client; this lesson creates no recurring task.
Try it step by step
- Read the simulation's explicit kind and actualAgentsSpawned fields before interpreting its output.
- Use A and B's frozen work packages for an optional actual Codex run; keep the parent on an independent review task.
- Record actual dispatch, observed status and returned artifact where the client exposes them, without artificial delays.
- Wait for the required implementation outputs and run integration on those actual files.
- If no real child was run, report only simulation and code-check evidence; do not invent a monitoring trace.
A useful starting example
Illustration · adapt before use.
In a disposable delegation-capstone copy, give one actual subagent package A and starter/normalize.cjs only. While it works, prepare the parent integration checklist from CONTRACT.md. Inspect its status using the controls this client actually exposes, then wait for its returned diff and checks before synthesizing. Record only observed states. Run the actual candidate checks after both modules are complete. Keep simulate.cjs output labelled deterministic and never describe it as a live child transcript.Tell the normalization worker to stay in starter/normalize.cjs and cover null plus unsupported values. Do not change B’s file.
If it is editing report.cjs, stop it, preserve its useful diff and assign that file one owner.
After both outputs return, run node run.cjs starter and node --test candidate.test.cjs in the actual destination.An honest simulation receipt
The supplied program illustrates state handoff and checks reference code.
node labs/delegation-capstone/simulate.cjskind: deterministic-handoff-simulation
actualAgentsSpawned: false
integration.passed: trueThe integrated code result is real; the handoff activity is an explicitly deterministic teaching model.
Your turn
Run the deterministic simulation to understand ownership and dependency order, then inspect its code. If actual Codex delegation is available, observe one bounded package from dispatch to result and attach its real handoff and code check. If it finishes before you inspect a running state, record only the states actually observed. Deliver a result ledger distinguishing simulated and real observations.
Try the exercise before opening its reference answer. Use a disposable practice folder.
Track work without fabricating background activity
Extract into a new practice folder and keep the included labs folder. Run these commands from that extraction root, or from the course folder, using an existing Node.js installation.
- Command 1 text
node labs/delegation-capstone/simulate.cjsCheck: kind is deterministic-handoff-simulation; actualAgentsSpawned is false; reference integration passes.
- Command 2 text
node --test labs/delegation-capstone/candidate.test.cjsCheck: The unedited starter intentionally fails 4 candidate checks; all 4 should pass after both fixes.
A local simulation can teach dependency states; actual agent dispatch, waiting and return need actual client observations.
Check your result
- Simulation records are labelled deterministic and actualAgentsSpawned:false is preserved.
- Any claimed dispatch, running state, intervention or return has actual client evidence.
- The returned code is checked separately from an agent's completion status.
Reference answer & rubric Try the exercise before opening
The supplied script provides real integration code checks and deterministic handoff illustrations; it intentionally spawns zero agents.
- Run simulate.cjs and find actualAgentsSpawned:false.
- Separate its package ordering from any real client activity.
- For actual delegation, record only observed states and make scope corrections explicit.
- Check returned source freshness and integrated behavior before final synthesis; a background completion message alone is insufficient.
Check your understanding
A subagent is running in the background. What can the parent safely do?
- Perform an independent task and wait for the result before making dependent claims.
- Mark its requested output complete immediately.
- Assume it is now scheduled to rerun automatically.
Reveal the answer and explanation
Answer 1: Perform an independent task and wait for the result before making dependent claims.
Background execution allows independent progress. It establishes neither completion nor recurrence.
Take this quiz in the interactive lesson to save your answer in the browser.
When it does not work
Simulation output is presented as evidence of two running agents.
Likely cause: Deterministic package records were mistaken for actual client activity.
What to try: Label the script honestly and supply separate thread/activity evidence for any real run.
Stopping a child is assumed to remove every process or artifact.
Likely cause: Agent state and resource cleanup were conflated.
What to try: Inspect the relevant actual process/files separately and preserve needed work before cleanup.
Common mistakes
- Calling a background task durable automation or promising completion after the computer becomes unavailable.
- Importing a Claude background shortcut and interpreting an unobserved action as successful.
Source mapping & differences · different
Codex supports background delegated work and thread inspection, but the source's background fields, shortcuts and persistence assumptions do not transfer.
Source topic: Background subagents ↗Go to the source
Official documentation, checked 21 October 2026. Product names, controls and availability may vary with your version, platform or account.
Completion and quiz progress are saved
only in the interactive course.