sno-ai/sno-station-skills / skills/S-communication-and-handoff/rotate-agent/skill
rotate-agent
VerifiedQuota-triggered failover from Claude Code, Codex, Cursor, Hermes or OpenClaw. When armed, it reads the sender quota and tries other-vendor models in place, then receiving agents in the configured order. Use when a long run must finish even if one vendor's quota runs out. Not a monitor for anything else.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.9 KB |
| scripts/rotate-agent-answer-providerexecutable | script | 3.9 KB |
| scripts/rotate-agent-preflightexecutable | script | 7.8 KB |
| scripts/rotate-agent-resumeexecutable | script | 12.9 KB |
| scripts/rotate-agent-resume.texecutable | script | 10.0 KB |
| scripts/rotate-agent-switchexecutable | script | 5.1 KB |
| scripts/rotate-agent-watchexecutable | script | 6.7 KB |
| scripts/selftest/fake-quotaexecutable | script | 267 B |
| scripts/selftest/run-selftest.shexecutable | script | 10.3 KB |
| scripts/selftest/switch-provider.texecutable | script | 15.7 KB |
scripts/rotate-agent-answer-provider
View on GitHub#!/usr/bin/env bash
# Read the provider of one answered turn, never the session's configured fallback.
set -Eeuo pipefail
usage() {
printf 'usage: rotate-agent-answer-provider --agent hermes|openclaw [--seat <address> --receipt <REACH-RECEIPT-id> | --seat <address> --latest | --session <id> | --session-key <key>] [--with-model]\n' >&2
exit "${1:-2}"
}
AGENT='' SEAT='' RECEIPT='' SESSION='' SESSION_KEY='' LATEST=false WITH_MODEL=false
while (( $# )); do
case "$1" in
--agent|--seat|--receipt|--session|--session-key)
(( $# >= 2 )) || usage
[[ -n "$2" ]] || usage
case "$1" in
--agent) AGENT="$2" ;; --seat) SEAT="$2" ;; --receipt) RECEIPT="$2" ;;
--session) SESSION="$2" ;; --session-key) SESSION_KEY="$2" ;;
esac
shift 2 ;;
--latest) LATEST=true; shift ;;
--with-model) WITH_MODEL=true; shift ;;
-h|--help) usage 0 ;;
*) usage ;;
esac
done
[[ "$AGENT" =~ ^(hermes|openclaw)$ ]] || usage
[[ "$LATEST" == false || ( -n "$SEAT" && -z "$RECEIPT" && -z "$SESSION" && -z "$SESSION_KEY" ) ]] || usage
if [[ -n "$SEAT" ]]; then
[[ -n "$RECEIPT" || "$LATEST" == true ]] || usage
record="${SNO_REACH_STATE_ROOT:-$HOME/.local/state/sno-reach}/$SEAT/transcript.json"
if [[ "$AGENT" == hermes ]]; then
SESSION="$(jq -er '.session_id | select(type == "string" and length > 0)' "$record")" || exit 1
else
SESSION_KEY="$(jq -er '.session_key | select(type == "string" and length > 0)' "$record")" || exit 1
fi
fi
if [[ "$AGENT" == hermes ]]; then
[[ -n "$SESSION" ]] || usage
logs=()
for log in "${HERMES_HOME:-$HOME/.hermes}/logs/agent.log.1" "${HERMES_HOME:-$HOME/.hermes}/logs/agent.log"; do
[[ ! -f "$log" ]] || logs+=("$log")
done
(( ${#logs[@]} > 0 )) || exit 1
awk -v session="[$SESSION]" -v receipt="$RECEIPT" -v latest="$LATEST" -v with_model="$WITH_MODEL" '
index($0, session) && /agent.turn_context: conversation turn:/ {
if (latest == "true") next
if (active) { active=0; finished=1 }
if (!finished && (receipt == "" || index(substr($0, index($0, "msg=")), receipt))) active=1
next
}
(latest == "true" || active) && index($0, session) && /agent.conversation_loop: API call #[0-9]+:/ {
model=""
if (match($0, /model=[^[:space:]]+/)) model=substr($0, RSTART+6, RLENGTH-6)
if (match($0, /provider=[^[:space:]]+/)) provider=substr($0, RSTART+9, RLENGTH-9)
}
END {
if (provider == "" || (with_model == "true" && model == "")) exit 1
if (with_model == "true") print provider " " model; else print provider
}
' "${logs[@]}"
else
[[ -n "$SESSION_KEY" ]] || usage
[[ "$SESSION_KEY" == agent:main:* ]] || SESSION_KEY="agent:main:$SESSION_KEY"
tmp="$(mktemp -d)"
trap 'rm -rf -- "$tmp"' EXIT
timeout 120 openclaw sessions export-trajectory --session-key "$SESSION_KEY" --json --workspace "$tmp" >/dev/null || exit 1
[[ -f "$tmp/events.jsonl" ]] || exit 1
jq -ser --arg receipt "$RECEIPT" --argjson latest "$LATEST" --argjson with_model "$WITH_MODEL" '
reduce .[] as $e ({active:false, done:false, current:null, answer:null};
($e.type // "") as $type |
if ($type != "assistant.message" and $type != "user.message" and ($e.provider // $e.data.provider) != null)
then .current={provider:($e.provider // $e.data.provider), model:($e.modelId // $e.model // $e.data.modelId // $e.data.model)} else . end |
if $type == "user.message" then
if $latest then .active=true
elif .active then .active=false | .done=true
elif (.done | not) and ($receipt == "" or ($e | tojson | contains($receipt))) then .active=true
else . end
elif $type == "assistant.message" and .active then .answer=.current
else . end)
| .answer | select(.provider | type == "string" and length > 0)
| if $with_model then select(.model | type == "string" and length > 0) | "\(.provider) \(.model)" else .provider end
' "$tmp/events.jsonl"
fi
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Unverified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |