Cross-agent failover template
Cross-agent failover template
Section titled “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.
What the template does
Section titled “What the template does”- 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:0as 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.
~/.hermes/scripts/micawtf-agent-dispatch.sh --probeAsync dispatch
Section titled “Async dispatch”~/.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 5400The command returns immediately with a PID and log path. The watcher sends Telegram when the task exits.
Resume chain
Section titled “Resume chain”When a run fails, the watcher sends a command shaped like:
~/.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>.logThe 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.
Default agent commands
Section titled “Default agent commands”Claude:
claude -p < "$PROMPT_FILE"Codex:
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.
Source of truth
Section titled “Source of truth”The canonical script is ops/hermes/scripts/micawtf-agent-dispatch.sh. It is installed into ~/.hermes/scripts/ by:
ops/hermes/install.sh scripts-onlyDo not edit the installed copy directly.