--- name: agent-outage-recovery description: Use when all agents stop at once. Find cause, resume work. version: 1.0.0 author: HamaratLabs license: MIT metadata: hermes: tags: - hermes - outage - credential-pool - anthropic - resume - orchestration related_skills: - hermes-agent - incident-escalation - multi-agent-project-orchestration --- # Agent outage recovery ## When to Use The user says "herkes hata veriyor", "agentlar durdu" or many profiles fail at the same time. ## Diagnose (one pass, all profiles) - `hermes gateway status`, `hermes auth list` (read the real pool order there; e.g. a subscription login first, then a paid API key referenced as `<ücretli-anahtar>`). - Grep `~/.hermes/logs/errors.log` and `~/.hermes/profiles/*/logs/{errors,agent}.log` for `usage limits|429|rotated to pool|unavailable for model|terminally invalid|Gateway disconnected`, with timestamps. - Common pattern: the subscription login hits its model limit (429, "unavailable for model ..."), the pool falls back to a paid API key, and that key hits its own spend cap (400 "usage limits"). Every agent stops together. It self-heals when the subscription window resets; no config change unless the user decides (e.g. raise the spend cap or add a cheaper fallback model). Keep within the provider's terms: one subscription account per person plus a paid API fallback, not a pool of rotated subscription accounts. - OAuth "refresh token terminally invalid" lines usually come from rarely used or out-of-scope profiles; not the main cause. - Do not claim "it switched to another key"; recovery is the subscription window resetting. Verify by the absence of new `API call failed` lines. - **"every provider in the fallback chain kept failing over":** walk the chain rung by rung instead of blaming quota. Read each rung's `summary=` in `agent.log` (`grep "API call failed" | grep -o "provider=[^ ]* .*model=[^ ]* summary=.*"`) and check credential status with `hermes auth list` (do not open credential files). Typical rung failures and fixes: - AGY `Antigravity CLI is not authenticated`: the Google login expired. Only the user can fix it (`agy` in their own terminal); never open the login URL yourself. Count the first occurrence per day to give them the start time. - An extra provider plugin fails with `BrokenPipe` or `model ... is not recognized`: its model catalog changed. List what that account really serves with `agy models` under the user's own signed-in session, probe one with `agy -p ... --model `, then replace the dead model id in every in-scope `config.yaml` (back up first, `yaml.safe_load` after) with the user's pick via `clarify`. - `Failed to activate fallback ...: Could not find the '' CLI command '(none configured)'`: the plugin is enabled in the profile's `config.yaml` but not present in that profile's `plugins/` dir. Symlink it from `~/.hermes/plugins/` into every in-scope profile that lists it, then probe. - Prove each fix with a one-line call on a worker profile: `hermes -p chat -q "Sadece tamam yaz." --provider

--model --oneshot -Q`, then confirm `API call #1: model= provider=

` in that profile's `agent.log` (the CLI may print only the session id). - **Paid key must be selectable everywhere:** moving interrupted work to a paid API provider only works in profiles that have that provider entry configured with its key. Without the entry the `--provider` flag does not error: the run silently falls into the profile's normal chain, so confirm the first `API call #` line. - Record what changed in a local patches log and in your system-status note, so the next outage starts from the true chain. ## Find interrupted work - "Organize everyone after the outage" sweep, in-scope profiles only: (1) recent sessions per profile from `hermes -p sessions list` that stopped mid-work; (2) cron jobs with `last_status` error and any enabled job whose `next_run_at` is already past; (3) root-cause each failing cron (its script may point at a branch/worktree that no longer exists: recreate with `git worktree add .worktrees/ -b origin/main`, local only, then run the script directly and require exit 0). Report profiles with nothing pending as idle instead of inventing work for them. - Per profile (`hermes -p sessions list`, `sessions export ` for one session): sessions with messages after the outage start whose last assistant message is `Your request was not processed` or `This turn did not complete`, or logs ending `EXIT 1` with `Gateway disconnected`. A session whose last message is a user `[IMPORTANT: Background process ... completed]` with no reply also died mid-work. - Before resuming, check whether a PM already restarted it (PM workspace `devam-*.md`, running `run-*.sh` chains, worktree gone and merged on main) to avoid duplicates. Skip out-of-scope profiles. ## Resume - Workers: a small `run-resume.sh ` wrapper run from the session's working directory. devam.md: interrupted by limit; check git status/log and finished background outputs first; do not redo; same brief rules; report in the brief's format. Log next to the PM's original log with `-2` suffix so the PM finds it. - Serialize jobs on the same repo/emulator; separate repos may run in parallel. - Put chains in a bash script file and run with `terminal(background=true, notify=true)`. Pitfall: `E="env -i ... PATH=$PATH"; $E bash ...` fails in zsh (no word splitting) and PATH contains a space (`/Applications/VMware Fusion.app/...`); quote `PATH="$PATH"` inside a bash script. nohup/disown wrappers are refused. - Resume a dead session directly: `hermes -p chat --resume --oneshot -Q -q ""` (run via `terminal(background=true)`). Do NOT pass `--max-turns`/`--run-budget`/`--provider`/`--model` with `--resume` (rejected within seconds, exit 2: "creation overrides unsupported on resume"); a resumed session keeps its launch provider. To move interrupted work onto a working provider (e.g. a paid API provider while the subscription is down), start a FRESH session: original brief + an appended note ("interrupted by a provider outage, unrelated to your work; check `git status`, output folders and partial reports first, do not redo finished parts"), launched with `--provider --model --max-turns N --run-budget S`. Within ~1 min confirm the first `API call #` shows the intended provider; a launch that shows another provider instead means the profile lacks the custom provider entry (see Diagnose). A review gate (e.g. a security-review profile) whose own chain is down is run the same way instead of leaving the release blocked. A job parked behind a timed waiter until a subscription window reopens (`while [ $(date +%H%M) -lt HHMM ]; ... --resume`) moves to the API the same way when the user asks: kill the waiter and confirm it is gone, then start a fresh session whose brief lists the earlier phase's files on disk (previous brief, phase report with its next-phase plan, decision file) and says "same worker, earlier session unavailable, reuse the tools, do not redo". Exit 1 "Execution outcome unknown after restart" fences the lost turn: `hermes -p sessions discard --yes` (says "nothing to discard" if the first attempt already cleared it), then re-run. Detect dead sessions after a reboot: sessions in `hermes -p sessions list` that stopped mid-work, with no `hermes -p` process running. - Fresh (non-resume) PM/worker runs: `--query-file` must be an absolute path (relative path exits code 2 silently with a ~100 byte output file). - After sleep/reboot, backgrounded jobs and their notifications can arrive hours late; check `date` and process `etime` before calling a job hung. If the `terminal` tool itself hangs (even `echo`), run work through `execute_code` (subprocess with timeout) or `terminal(background=true)`; a repo dir where `ls`/`git`/`esbuild` hang is a stall, not proof of a permission prompt or a stuck process: re-probe the same path (`stat`, `ls`) in a fresh `execute_code` call before diagnosing, because it often clears by itself after sleep/wake. A process `etime` includes suspended time, so judge real activity from the session list's last-activity time and fresh `API call #` log lines, not from a 6-hour `etime`. - Before proposing to kill a long-running process, identify its owner and purpose (`ps -o command=`, its cwd/worktree): long-lived Vite/esbuild servers under a project's `.worktrees/` are usually deliberate dev servers, not leftovers. Name what it belongs to and ask; never offer a kill on a guess. - PM Telegram sessions that died cannot be resumed from here; tell the user to write "Devam" to them so they pick up the worker reports. ## Files - `scripts/menu_check.py`: prints one profile's `/model` picker rows, to confirm the paid fallback is selectable. ## Report Short Turkish: cause with times, what was restarted, what finished (verify commits with `git log main..HEAD`), what PMs need, one decision question via clarify.