JesseRWeigel / JesseRWeigel/get-math-done
Bug: Executor subagent file writes lost due to sandbox isolation
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
During the first real test run (chromatic number research, Phase 1 literature survey), executor subagents spawned via the `task()` delegation pattern wrote files to `knowledge/` but the writes didn't persist to disk. The orchestrator correctly detected the missing files (artifact recovery protocol working as designed) but had to rewrite them manually, consuming extra context.
## Root Cause
When Claude Code spawns subagents, they may run in a sandboxed environment where file writes don't persist to the parent process's filesystem. GPD handles this with an explicit artifact recovery protocol:
1. After every subagent returns, verify `files_written` exist on disk
2. If missing, extract content from the agent's response text and write directly
Our executor command references this protocol but the recovery path needs to be more robust — specifically:
- The orchestrator should attempt extraction from the agent output automatically
- If the agent returned structured content (e.g., markdown sections), parse and write them
- Log the sandbox isolation event for debugging
## Observed Behavior
- Wave 1 (single agent): files persisted correctly
- Waves 2-4 (parallel agents via `task()`): files did NOT persist
- The orchestrator detected missing files and rewrote T1.7 and T1.8 manually
- Earlier wave files (T1.2, T1.3, T1.4, T1.5, T1.6) were also sandboxed but the orchestrator had their content in context and recovered
## Expected Behavior
All subagent file writes should either:
1. Persist to the parent filesystem, OR
2. Be automatically recovered by the orchestrator using the artifact recovery protocol
## Fix
1. Update `execute-phase.md` workflow to add explicit post-agent file verification after EVERY agent spawn
2. Add a `recover_artifacts()` function that parses agent output for file content
3. Consider using `getWritable()` pattern or explicit file handoff instead of relying on subagent filesystem access
4. Add observability logging for sandbox isolation events
## References
- GPD: `src/gpd/specs/references/orchestration/agent-delegation.md` — Artifact Recovery Protocol
- First observed in: chromatic-number-random-graphs test project, Phase 1, Waves 2-4
Contributor guide
Assessment
This issue has not been assessed yet.