Skip to content

Codex rate limit fallback: route agent tasks to Claude when Codex is rate limited #75

@gagan114662

Description

@gagan114662

Problem

When the ChatGPT/Codex subscription is rate limited, codex exec returns an error and the agent sibling icon turns red — no result, no spoken feedback. There's currently no fallback.

Expected behaviour

When Codex is rate limited (or unavailable), agent tasks should fall back gracefully instead of silently failing.

Proposed solution

Add a two-tier fallback in AgentSessionManager.launchAgent():

  1. Tier 1 — Codex (primary): runs codex exec --json as today
  2. Tier 2 — Claude fallback: if Codex throws a rate-limit error, re-route the task to ClaudeCodeCLIClient. Claude can't build real files or run code, but handles research/summarization/planning tasks well.

The spoken response should tell the user which tier handled the task:

  • Codex: speak result as-is
  • Claude fallback: prefix with "Codex is rate limited, here's what I can tell you: ..."

Detection

Codex rate-limit errors come through as CodexCLIError.agentError(message) where message contains "rate" or "429". Check for this before deciding to fall back vs surface the error directly.

Files to change

  • AgentSessionManager.swift — add fallback logic in the catch block
  • CodexCLIClient.swift — expose a helper to detect rate-limit errors from the error message

Context

  • Rate limits are on the ChatGPT subscription (not API credits), reset hourly
  • Codex binary: ~/.local/bin/codex-clicky (v0.124.0)
  • Claude fallback: ClaudeCodeCLIClient already available in CompanionManager

Blocked until rate limit resets — implement tomorrow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions