Combo Test: Task-Aware Background Processing
Background processes can update task state while Claude continues other work.
Background processes can update Claude task state while the agent continues other work without blocking.
How It Works
The Claude Code task system stores task metadata in JSON files at ~/.claude/tasks/$SESSION/$TASK_ID.json. A background process running in parallel (spawned with & syntax) can write directly to these files after long operations complete. The agent can poll task state via TaskGet and observe updates written by external shells, integrating long-running operations into the task workflow.
Test Setup and Results
The test created task #27 and launched a background shell: (sleep 2 && update task JSON) &. The background process wrote completion metadata and changed the task status to completed while Claude continued. TaskGet immediately reflected the change, validating the pattern.
What This Enables
- Async build integration: Long-running builds update task status independently
- External process reporting: Shell scripts or external systems signal completion
- Workflow composition: Tasks can spawn async work and poll for results without CLI blocking
The pattern is immediate once you have session and task ID:
(
do_long_operation
cat > ~/.claude/tasks/$SESSION/$TASK_ID.json << EOF
{"id": "$TASK_ID", "status": "completed", ...}
EOF
) &
Caveats
Session ID discovery and collision risk remain open; task ID alone is insufficient. Concurrent writes to the same JSON file lack locking and could corrupt state under heavy parallelism. The approach assumes cooperative, non-malicious background processes. Updates are fire-and-forget; error handling and retry logic remain the caller's responsibility.
Epistemic status: validated by runtime test. Pattern functional; production use requires session context and safe ID generation.
- file2.1.16/tests/combo-06-background-tasks/TEST-RESULTS.md
primitive_2dfd544e834e0f4895389ff8ed255199b87705613b1e2fd064d57fa75a6b679d2856ceafad6b1daa8f982493871b6ddb45ebfb52b561b6ad9c34c655965e66a0f7db455e04b9c183cfb554d68f4a2c1e7e4b3514f2128a567ad9fe85d1992112e361c801774a1108f4079d058d1fd09Signed with an ed25519 key held off the repo. Anyone can verify against the published public key; nobody without the secret key can forge it. Click verify: it recomputes the signature in your browser. The signature proves integrity and authorship of this exact content — not a third-party timestamp or that the underlying claim is objectively true. signedAt is when the @f3/attest pipeline ran, not when the work happened; the evidence refs carry the source dates.
- instance-of Scheduler / IPC Class
- introduces (in) 2.1.16 Battle Test (2.1.16) Release
- verifies (in) Combo Test: Task-Aware Background Processing — runtime test Test