Skip to content

Cross-agent failover template

Issue #10 promoted the old box-local dispatch pattern into the mica.wtf repo.

Use ~/.hermes/scripts/micawtf-agent-dispatch.sh for unattended agent work that may need to fall back between Claude and Codex.

  • Probes agent availability with command -v.
  • Uses a primary agent if available, otherwise a fallback agent.
  • Runs with explicit PATH and working directory.
  • Writes logs to /tmp/micawtf-agent-*.log.
  • Starts a watcher for async runs.
  • Treats EXIT:0 as the only success signal. This avoids false positives from agent prose that says “done” before the process exits.
  • On failure, sends a Telegram message with an exact resume command and the failed log path.
  • Supports --resume-from <log> to build a continuation prompt from the original prompt plus the previous log tail.
Terminal window
~/.hermes/scripts/micawtf-agent-dispatch.sh --probe
Terminal window
~/.hermes/scripts/micawtf-agent-dispatch.sh \
--task mica-example \
--prompt-file /home/hermes/micawtf/prompts/article-writer.md \
--workdir /home/hermes/micawtf \
--primary claude \
--fallback codex \
--timeout 5400

The command returns immediately with a PID and log path. The watcher sends Telegram when the task exits.

When a run fails, the watcher sends a command shaped like:

Terminal window
~/.hermes/scripts/micawtf-agent-dispatch.sh \
--task mica-example-resume \
--prompt-file /home/hermes/micawtf/prompts/article-writer.md \
--workdir /home/hermes/micawtf \
--primary codex \
--fallback claude \
--timeout 5400 \
--resume-from /tmp/micawtf-agent-mica-example-<run>.log

The resume prompt tells the next agent to continue from the current repository state and includes the tail of the previous log. This is intentionally not a magical state database; Git state plus the previous log is the handoff.

Claude:

Terminal window
claude -p < "$PROMPT_FILE"

Codex:

Terminal window
codex exec "$(cat "$PROMPT_FILE")"

The checked-in template intentionally uses normal CLI commands. If a local box needs more permissive flags, that should be an explicit local wrapper decision, not the repo default.

The canonical script is ops/hermes/scripts/micawtf-agent-dispatch.sh. It is installed into ~/.hermes/scripts/ by:

Terminal window
ops/hermes/install.sh scripts-only

Do not edit the installed copy directly.