Technical details of the inter-process communication system between dispatcher and workers
The IPC (Inter-Process Communication) system enables bidirectional communication between workers and the dispatcher without the worker losing context. This is what allows workers to ask questions mid-task and continue working after receiving answers.
Dispatch uses a file-based IPC protocol with sequence-numbered files in .dispatch/tasks/<task-id>/ipc/:
.dispatch/tasks/security-review/ipc/ 001.question ← Worker writes this 001.answer ← Dispatcher writes this 001.done ← Worker writes this (acknowledgment) 002.question ← Next question from worker 002.answer ← Dispatcher's answer 002.done ← Worker's acknowledgment .done ← Worker writes this when ALL work is complete
Why file-based IPC? It’s simple, debuggable, works across different CLI environments, and requires no special infrastructure. You can inspect the conversation by just reading the files.
# List IPC directory to find unanswered questions$ ls .dispatch/tasks/security-review/ipc/001.question# Read the question$ cat .dispatch/tasks/security-review/ipc/001.questionFound 2 auth implementations. Which should I review?
Dispatcher surfaces this to you:
Worker is asking: "Found 2 auth implementations. Which should I review?"
#!/bin/bashIPC_DIR=".dispatch/tasks/<task-id>/ipc"SEQ="001"QUESTION="Found 2 auth implementations. Which should I review?"# Atomic writeecho "$QUESTION" > "$IPC_DIR/${SEQ}.question.tmp"mv "$IPC_DIR/${SEQ}.question.tmp" "$IPC_DIR/${SEQ}.question"
On POSIX filesystems (Linux, macOS), mv is guaranteed atomic when source and destination are on the same filesystem. This is a kernel guarantee.
If the worker doesn’t receive an answer within ~3 minutes:
START=$(date +%s)TIMEOUT=180 # 3 minuteswhile [ ! -f "$IPC_DIR/001.answer" ]; do sleep 2 ELAPSED=$(( $(date +%s) - START )) if [ "$ELAPSED" -ge "$TIMEOUT" ]; then # Timeout fallback echo "Fell back to context dump due to IPC timeout" >&2 # Dump context cat > .dispatch/tasks/<task-id>/context.md << 'CONTEXT' ## Current State Working on checklist item: "Review authentication logic" ## Question Found 2 auth implementations. Which should I review? ## Context So Far - Scanned for secrets: found hardcoded API key in config.ts:47 - Read auth.ts and legacy-auth.js - Both appear to be in use CONTEXT # Mark item as blocked in plan file # ... (edit plan.md to change [ ] to [?]) ... exit 1 fidone
Result:
Worker preserves its context in context.md
Plan file shows [?] marker with inline question
Worker exits
Dispatcher can spawn a new worker with the context when you answer
Why 3 minutes? Long enough to avoid false timeouts (you might be reading the question), short enough to prevent indefinite waiting if the dispatcher crashes.
If the dispatcher session restarts (e.g., you close and reopen Claude Code), it should check for orphaned questions:
# Find all active tasksfor task_dir in .dispatch/tasks/*/; do task_id=$(basename "$task_dir") ipc_dir="${task_dir}ipc" # Check for unanswered questions for q in "$ipc_dir"/*.question; do [ ! -f "$q" ] && continue # No questions seq=$(basename "$q" .question) answer="${ipc_dir}/${seq}.answer" if [ ! -f "$answer" ]; then # Found unanswered question echo "Task $task_id has unanswered question: $seq" question_text=$(cat "$q") # Surface to user, wait for answer, write answer, respawn monitor # ... (same flow as step 4-7) ... fi donedone
This ensures questions are never silently lost even if the dispatcher crashes or is restarted.
You can read this directory like a conversation log:
$ cat ipc/001.questionFound 2 auth implementations. Which to review?$ cat ipc/001.answerReview auth.ts$ cat ipc/002.questionauth.ts uses JWT. Should I audit the token validation logic?$ cat ipc/002.answerYes, focus on signature verification and expiration checks.$ ls ipc/.doneipc/.done # Task complete