Skip to content

Support alternative CLI backends (Gemini CLI) for cross-model second opinions #619

Closed as not planned

Description

@korabeland

Problem

12+ gstack skills hardcode codex exec as the cross-model second opinion engine:

  • /codex, /review, /ship, /plan-eng-review, /plan-ceo-review, /plan-design-review, /design-consultation, /design-review, /office-hours, /autoplan

These calls use Codex-specific flags (-s read-only, -c 'model_reasoning_effort=...', --enable web_search_cached, resume <session-id>) that have no direct equivalent in other CLIs.

Users who don't have (or don't pay for) OpenAI Codex CLI but do have Google Gemini CLI installed currently have to maintain a translation shim to use these skills. The shim works for basic calls but can't fully translate:

  • codex exec resume <session-id> (session continuity — no Gemini equivalent)
  • -c 'model_reasoning_effort=...' (dropped silently)
  • --enable web_search_cached (dropped — Gemini has built-in search but no equivalent flag)
  • --json JSONL output mode (Gemini doesn't support structured trace output the same way)

Related

Proposal

Add a configurable "outside voice" backend in ~/.gstack/config.yaml:

outside_voice:
  backend: gemini  # or: codex, claude-subagent
  # backend-specific config inherited from each CLI's own auth

Then in skill files, replace direct codex exec calls with an abstraction that dispatches to the configured backend. Each backend adapter handles flag translation:

Codex flag Gemini equivalent Claude subagent
-s read-only --sandbox Agent tool (read-only by default)
-c 'model_reasoning_effort=...' n/a (drop) model param
--enable web_search_cached built-in (drop) WebSearch tool
resume <session-id> n/a SendMessage to existing agent
--json (JSONL traces) n/a parse agent output

This would:

  1. Let users choose their preferred second-opinion CLI
  2. Unify the inconsistent CODEX_NOT_AVAILABLE handling across skills
  3. Make the "outside voice" pattern a first-class gstack concept rather than a Codex-specific feature

Workaround

A bash shim at ~/.local/bin/codex that intercepts codex exec and translates to gemini -p works for most cases but breaks on session continuity and JSONL output parsing.

Environment

Activity

  1. drandrewlaw commented on Apr 4, 2026

    @drandrewlaw

    I just had a real-world experience with this in an /office-hours session that shows why multi-model second opinions are valuable.

    What happened: I ran Codex AND Gemini CLI as independent cold reads during Phase 3.5. They genuinely disagreed on a key premise (whether IoTeX was the right wedge chain for a DeFi monitoring product):

    • Codex: "IoTeX is too small to learn from. Go to Ethereum/Base/Solana where there are users."
    • Gemini: "IoTeX is the ONLY place to prove the physical+digital DePIN thesis. On Solana you're just another alert tool."

    This forced a real decision that a single model wouldn't have surfaced. Three perspectives (Claude + Codex + Gemini) produced a genuinely better outcome than any single model alone.

    How I ran it: After the existing Codex Phase 3.5 flow, I manually ran Gemini via gemini -p "$(cat prompt_file)" with the same structured context block, adapted for Gemini's different strengths. The integration was straightforward.

    Key CLI differences I hit:

    Feature Codex Gemini
    Prompt flag codex exec "prompt" gemini -p "prompt"
    Read-only -s read-only --approval-mode plan
    Working dir -C dir No equivalent (run from cwd)
    Output Plain text stdout Works fine with -p

    I'd like to implement this. The resolver pattern in scripts/resolvers/review.ts is clean — adding generateGeminiSecondOpinion() alongside the existing Codex resolver is straightforward. The test infrastructure already exists (test/helpers/gemini-session-runner.ts, test/gemini-e2e.test.ts).

    Proposed approach:

    1. Add GEMINI_SECOND_OPINION resolver that auto-detects which gemini
    2. User gets asked which model(s) to use when both are available (Codex, Gemini, or both)
    3. When both run, add a cross-model synthesis section comparing all three perspectives
    4. Respects the existing outside_voice config pattern proposed in this issue
    5. Apply the same pattern across the 12+ skills that currently hardcode Codex

    Refs: #772 (auto-detect), #215 (Gemini CLI support)

  2. fkittredge commented on Jun 11, 2026

    @fkittredge

    +1 — would like to use Gemini CLI as the outside-voice reviewer in place of (or alongside) Codex.

  3. time-attack commented on Jul 15, 2026

    @time-attack
    Contributor

    @korabeland The provider-neutral contract for cross-model second opinions remains unresolved, and this issue is the primary place tracking it.

  4. vaskockorovski commented on Aug 1, 2026

    @vaskockorovski
    Contributor

    I'd like to build this, and extend the design slightly — happy to take it if the shape below works for you.

    Motivation from real usage: running gstack with codex as the outside voice on every review leg, my OpenAI spend hit ~$18/day at solo-consultant throughput. I mined my own review dossiers before proposing this, and the data killed my first instinct (cap the rounds): across three recent leaves, genuine P1s landed at rounds 8 and 12 (one run), rounds 1/5/8/10 (another — two of the four were regressions introduced by the run's own fixes), and rounds 24/25/28 (a 34-round run). Any cap small enough to save money ships real defects. The loop is doing real work — it's just doing the cheap work at frontier prices.

    Proposal: move the loop to a cheap backend, keep codex as the converged-artefact gate.

    # ~/.gstack/config.yaml
    outside_voice:
      default: codex            # backwards-compatible: no config = current behaviour
      backends:
        codex:
          cmd: codex exec
        loop_voice:
          cmd: codex exec --profile openrouter-cheap   # Codex CLI's own provider config; no new deps
      review:
        loop:                    # the iterative fix-verify grind
          backend: loop_voice
          mode: advise_only      # findings logged; the host agent applies fixes
          stop: no_p1_no_p2      # same stop condition as today — never taper on "only minor lately"
        final_gate:              # runs only on the converged artefact
          backend: codex
          stop: no_p1_no_p2      # uncapped — deep latent defects are exactly what frontier is for

    Key points:

    • Zero behaviour change for existing users — absent config, every skill dispatches to codex exec exactly as today.
    • The abstraction is the one this issue already asks for: replace the 12+ hardcoded codex exec call sites with a dispatch helper; backends declare their invocation. This also gives office-hours: Phase 3.5 should fall back to Claude subagent when Codex is unavailable #463's Claude-subagent fallback a consistent home instead of the current per-skill CODEX_NOT_AVAILABLE divergence.
    • Why loop/gate rather than a shallow cheap pre-pass: review value is iterative fix-verify on an evolving artefact — a fix is new code, and late rounds catch real regressions of earlier fixes. A 1–2 pass cheap "pre-filter" saves nothing because the frontier model still runs the long loop. Moving the loop itself to a ~$0.60/M backend means 30 cheap rounds cost less than one frontier round, and the gate model arrives at an already-converged artefact (my data suggests its rounds drop from 11–34 to ~3–6).
    • The gate never triages the loop voice's findings — it reviews the artefact, not the junior's homework. Findings-per-round logs are kept for per-voice hit-rate analysis, which is how a team would eventually decide (with evidence) whether low-risk changes need the frontier gate at all.
    • Cheap backend rides Codex CLI's own model_providers/profiles (OpenRouter etc.) rather than a per-vendor adapter — flag translation stays inside a tool that already solves it. Gemini CLI as a backend can layer on later without blocking this.

    I'll fork and run this locally regardless (it's costing me real money weekly), but I'd rather land it here than maintain drift — same as #1302. If you'd prefer a different config shape or scope, say the word before I cut code.

  5. dgrant commented on Sep 17, 2026

    @dgrant
    Contributor

    Yes yes yes. I currently have a bit of a shim that allow me to do outside-voice/adversarial passes with codex or agy or both.

    Regarding this config proposal:

    outside_voice:
      backend: gemini  # or: codex, claude-subagent
      # backend-specific config inherited from each CLI's own auth
    

    We should make it support a list of backends, not just one. The user should be prompted (for me the reason I want to be prompted is so I can confirm my current usages in codex and agy before deciding whether to go ahead with none, one, or both).

  6. dgrant commented on Sep 17, 2026

    @dgrant
    Contributor

    Some changes were recently made in 1.86.0.0. See: #2850 (massive PR)

    I'm seeing this new OUTSIDE_LABEL template variable, which comes from here:

    export function outsideVoiceFor(ctx: Pick<TemplateContext, 'host'>) {
      return ctx.host === 'codex'
        ? { id: 'claude-code' as const, label: 'Claude Code', skillName: 'claude-code', nativeLabel: 'Codex (in-host)' }
        : { id: 'codex' as const, label: 'Codex', skillName: 'codex', nativeLabel: ctx.host === 'claude' ? 'Claude' : `${ctx.host} (in-host)` };
    }
    

    This looks like a good first step. At least 'codex' is less hard-coded now than before, and things are more refactored and abstracted so getting claude to use gemini instead of codex looks a bit easier.

  7. hui-zheng commented on Sep 20, 2026

    @hui-zheng

    Adding a data point from a setup that has been running a non-Codex outside voice for about seven weeks, plus a narrower proposal than the original one, because I think 1.86.0.0 already built most of what this issue asks for.

    The seam exists now; only the selection is still hard-coded. Read against 1.87.4.0 as installed:

    // scripts/resolvers/outside-voice.ts:8-12
    export function outsideVoiceFor(ctx: Pick<TemplateContext, 'host'>) {
      return ctx.host === 'codex'
        ? { id: 'claude-code' as const, label: 'Claude Code', skillName: 'claude-code', nativeLabel: 'Codex (in-host)' }
        : { id: 'codex' as const, label: 'Codex', skillName: 'codex', nativeLabel: ctx.host === 'claude' ? 'Claude' : `${ctx.host} (in-host)` };
    }

    outsideVoiceFor / outsideVoiceCommand / outsideVoiceInvocation / outsideVoicePreflight / outsideVoiceProvenance / outsideVoiceRuntime are exactly the abstraction this issue was asking for. What is missing is not the plumbing — it is that the choice is a ternary on ctx.host rather than something an operator can set.

    The contract a pluggable backend needs also already exists, in your own tree. outsideVoiceCommand builds the Claude Code branch as:

    "${bin}/gstack-claude-code" --cwd "$_REPO_ROOT" --access <none|…> \
      --timeout-ms <ms> <"$_OUTSIDE_INPUT" >"$_OUTSIDE_TMP/result.json"
    

    That is a complete, provider-neutral shape: prompt on stdin, review on stdout, explicit timeout, explicit access level. A third-party reviewer that honours it needs no new template logic at all. So the ask reduces to one config key naming the command, defaulting to today's host-derived behaviour:

    gstack-config set outside_voice_cmd "$HOME/bin/my-reviewer"
    

    with outsideVoiceFor consulting it before falling back to the ternary, and the id/label/nativeLabel fields deriving from it so OUTSIDE_LABEL and the provenance line stay accurate.

    One thing worth changing beyond selection: auth discovery should be able to run a command, not only read env vars. bin/gstack-codex-probe accepts credentials from exactly three places:

    # gstack-codex-probe:27-29
    _k1=$(printf '%s' "${CODEX_API_KEY:-}" | tr -d '[:space:]')
    _k2=$(printf '%s' "${OPENAI_API_KEY:-}" | tr -d '[:space:]')
    if [ -n "$_k1" ] || [ -n "$_k2" ] || [ -f "$_codex_home/auth.json" ]; then

    This is a security and blast-radius argument rather than a convenience one. Env-var-only discovery means the only way to make the probe see a credential is to put that credential in the environment, where it is inherited by every child process of the shell that exported it. Any other tool in the same environment that reads the same variable name will then silently select that provider for its own purposes, with no prompt and no log line — the variable's presence is itself the configuration. OPENAI_API_KEY in particular is a name that a great many unrelated tools treat as "use this provider", so the probe's accepted names are effectively a machine-wide switch.

    An optional outside_voice_auth_cmd, where exit 0 means usable, removes that coupling entirely: the backend reads its credential at call time from wherever it actually lives — an OS keychain, a secret manager, a short-lived token — and nothing is exported for other processes to find.

    Also worth stating plainly, since the issue title says "alternative CLI backends": pointing Codex itself at a non-OpenAI provider is not a substitute for this. outsideVoiceCommand hard-codes codex exec … -c model=…, and the model flag overrides the CLI's configured model, so the backend choice is gstack's rather than the operator's even when the provider is wired. We tried that route first and abandoned it; the concrete failure was the non-OpenAI endpoint rejecting Codex's namespaced tool wrapper with a 422 on /v1/responses.

    On the shape of a working third-party reviewer, since the contract above is the whole proposal: the one in use here is a small shell script with no tools and no repo access — a single /v1/chat/completions call, prompt on stdin, review on stdout, credential read at call time rather than from the environment. It has served as the outside voice for plan and architecture reviews here since 2026-08-01. Nothing about it is special; that is the point. Anything honouring the stdin/stdout contract already in your tree would work identically.

    For what it is worth on the "who takes it" question above: the narrower scope — one config key plus an optional auth command, no new backends bundled — looks small enough to land independently of anything Gemini-specific.

  8. capy-ai commented on Oct 11, 2026

    @capy-ai
    Contributor

    Thanks @korabeland for the idea. In the Oct 11 triage we grouped the open feature requests by theme so related asks get built together instead of one at a time. This one is part of the Provider pluralism theme in TODOS.md (https://github.com/garrytan/gstack/blob/50d020ad9/TODOS.md#L54-L69), tracked as a whole in #3138. Closing it here so the open list stays actionable; it isn't rejected, and the theme credits every linked reporter when it's picked up.

  9. added
    parked
    on Oct 25, 2026
  10. capy-ai commented on Oct 25, 2026

    @capy-ai
    Contributor

    Reopened under the parked label: this is tracked in the Provider pluralism theme in TODOS.md and tracking issue #3138 (https://github.com/garrytan/gstack/blob/main/TODOS.md#p3-feature-themes-from-the-wave-9-triage-filed-2026-10-11), and what fixes it is the provider seam (#3138), which adds Gemini CLI as an outside-voice backend. Closed-but-tracked read as closed, so parked issues now stay open until they ship, are duplicates, or are declined (https://github.com/garrytan/gstack/blob/main/docs/triage.md).

  11. added
    S3
    enhancement
    on Oct 31, 2026
  12. capy-ai commented on Oct 31, 2026

    @capy-ai
    Contributor

    Thanks for the request, @korabeland, and to everyone who upvoted it. Our second-opinion reviews are built around Codex and Claude Code, and adding Gemini CLI as a third would mean copying a lot of Codex-only setup. We're closing this as not planned for now, and we'll revisit it if we ever build a general way to pick your reviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    S3enhancementparked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions