Repository navigation
Intelligently fallback to available agent when default agent has exhausted usage - #12105
davidsilvasmith wants to merge 1 commit into
Conversation
Automated AI review
Verified: On a stock Omarchy install, though, Claude and Codex are the only listed agents with usage collectors. The resolver treats almost every other agent as available, can choose an agent the launcher then refuses, and treats several routine collector states as "exhausted". The notes below suggest tightening what counts as "available" before the crash click relies on it. Almost every listed agent counts as available on a stock installAn agent counts as installed when any of its command names resolves through On a stock install:
Sandboxed run with the stock stubs installed and the Claude default at 100% of its session window:
Impact: a crash-notification click can install an agent the user never chose and start it in its auto-approve mode with the crash prompt. A newly installed agent may still need a sign-in. Agents without records (pi, opencode, omp) may also draw on the same Claude or Codex subscription that is already exhausted. Suggested change: only count agents that are actually set up, for example by reusing the presence check The resolver can choose an agent the launcher refusesThe resolver accepts alternative command names: A second run with Claude plus a Impact: notification actions run detached ( Suggested change: check the same command name in the resolver that the launcher checks. Routine collector states are read as "exhausted"The resolver scores an agent 0 when
Codex writes "Codex limits unavailable" when its RPC probe times out or raises ( Impact: a Claude default that has not run for a while, or whose limits probe failed without cached limits, gets replaced by another agent. A fully signed-out Claude with usage history or cached limits is kept. Whether Claude Code keeps working on other models when only a model-scoped window is full was not verified here. Suggested change: treat "limits unavailable", a lapsed access token and records whose window has reset or whose
|
Summary
When diagnosing a crashed process from desktop crash notifications (
omarchy-agent-crash) or invoking prompts with fallback, Omarchy previously attempted to launch the default agent unconditionally without checking if that agent had exhausted its rate limits, had 0 usage remaining, or had expired credentials.Changes
bin/omarchy-agent: Added--fallbackoption. When enabled, it checks the default agent's usage in$XDG_STATE_HOME/omarchy/agents/usage/. If the default agent is exhausted (100% limit used), expired, or unavailable, it automatically inspects other installed coding agents and selects the candidate with the most remaining quota headroom.bin/omarchy-agent-crash: Passes--fallbacktoomarchy-agentso that clicking "Click to diagnose with AI" on a process crash toast will seamlessly fall back to an active agent subscription when the default agent is out of usage.bin/omarchy-agent-prompt: Supports forwarding--fallback.test/shell.d/agent-fallback-test.sh: Added test suite verifying quota retention, 100% limit fallback, expired token fallback, headroom ranking, and crash forwarding.