Skip to content

fix(rfspec): persist results and support fire-and-forget polling#9

Closed
TheFactoriousDROID wants to merge 3 commits intoFactory-AI:masterfrom
TheFactoriousDROID:fix/rfspec-timeout-persistence
Closed

fix(rfspec): persist results and support fire-and-forget polling#9
TheFactoriousDROID wants to merge 3 commits intoFactory-AI:masterfrom
TheFactoriousDROID:fix/rfspec-timeout-persistence

Conversation

@TheFactoriousDROID
Copy link

Problem

The rfspec run.sh script spawns three droid exec calls in parallel (Opus, GPT-5.4, Gemini). These take several minutes to complete, but the Execute tool has a default 60-second timeout. When the timeout hits:

  1. The shell process gets orphaned (continues running in background)
  2. stdout is disconnected from the calling session
  3. The temp dir self-destructs via trap when the script finishes
  4. Results are permanently lost -- the parent session never receives them

Fix

run.sh

  • Write model outputs to persistent ~/.factory/rfspec/runs/<timestamp-pid>/ instead of a self-destructing temp dir
  • Print RFSPEC_RUN_DIR=<path> immediately on launch so the agent captures it even if Execute times out
  • Write a done sentinel file (STATUS=complete or STATUS=failed) so the parent session can poll for completion
  • Still prints results to stdout for cases where the timeout is large enough

SKILL.md (v1.2.0 -> v1.3.0)

  • Rewrote workflow to instruct the agent to use fireAndForget=true on the Execute call
  • Added polling loop: read background log for run dir, then check <run_dir>/done every 30-60s
  • Once complete, agent reads <run_dir>/results.md with the Read tool
  • Updated examples to match the new pattern

Sends user prompt directly to Opus 4.6 (max), GPT-5.4 (xhigh), and
Gemini 3.1 Pro (high) in parallel -- each at its maximum reasoning tier.
Presents competing responses and lets the user pick or synthesize.

Includes a skill that teaches the agent the full workflow: when to invoke
rfspec, how to evaluate and compare results, how to synthesize, and where
to save the final spec.
…saving

Background droid exec calls failed for Opus because no --auto flag was set,
causing permission denial in non-interactive subprocesses. Also, the agent
instructions allowed saving specs directly without user review -- now requires
ExitSpecMode approval before writing to specs/active/.
The run.sh script spawns three droid exec calls that take several minutes,
but the Execute tool times out at 60s. When that happens the temp dir
self-destructs and results are lost.

Changes:
- Write model outputs to persistent ~/.factory/rfspec/runs/<id>/ instead of
  a temp dir
- Print RFSPEC_RUN_DIR path immediately so the agent captures it before timeout
- Write a done sentinel (STATUS=complete|failed) for polling
- Update SKILL.md (v1.3.0) with fire-and-forget + poll workflow instructions
@TheFactoriousDROID TheFactoriousDROID force-pushed the fix/rfspec-timeout-persistence branch from a7e2bf0 to 9213b79 Compare March 10, 2026 03:15
@TheFactoriousDROID
Copy link
Author

Merged into #8 (add-rfspec-plugin branch). All timeout/persistence fixes are now included there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant