Skip to content

fix(harness): Auth started by a Harness subprocess does not finish the handshake #654

Closed

Description

@omesser

Problem

Connecting an unauthenticated Harness from Chat starts the Harness's own OAuth in a subprocess. The browser can report success while the CLI handshake does not complete, so the Harness stays unusable.

ADR-0018 says the Harness authenticates itself and ai-buddy holds no credential. That only works if the subprocess can finish its own loopback callback.

Chat Connect calls select_harness then harness_login. For Codex that spawns codex login detached. Attaching the ACP child (npx -y @agentclientprotocol/codex-acp@latest) can also start a login on the child's stdout, which is merged onto cargo run. Two localhost:1455 login servers appeared in one attempt, with two different PKCE challenges.

Evidence

macOS, cargo run --bin ai-buddy. Chat Connect Codex while signed out of the Codex CLI.

harness: npx -y @agentclientprotocol/codex-acp@latest is the Completer now
harness: codex attached
Starting local login server on http://localhost:1455.
If your browser did not open, navigate to this URL to authenticate:
https://auth.openai.com/oauth/authorize?...&code_challenge=ubvM-…&originator=codex_cli_rs
On a remote or headless machine? Use `codex login --device-auth` instead.
Successfully logged in
Starting local login server on http://localhost:1455.
If your browser did not open, navigate to this URL to authenticate:
https://auth.openai.com/oauth/authorize?...&code_challenge=H5LWv…&originator=codex_cli_rs
On a remote or headless machine? Use `codex login --device-auth` instead.
Successfully logged in
^Cquit

The browser flow looked successful both times. The Codex CLI handshake did not complete. The process was quit with Ctrl-C.

Expected

  • One auth attempt at a time. A second listener on localhost:1455 must not steal the redirect.
  • Browser success completes the CLI handshake. Chat leaves the not-authenticated state without a restart (chat_opening already re-reads login for that).
  • If a Harness subprocess cannot finish OAuth (no TTY, competing bind, callback never reaches the child), Chat must not start that flow there. Point at the documented terminal command and wait, or host the login command in a way that can receive the redirect.

Platform

Observed on macOS. Other Harnesses that open loopback OAuth from the ACP child, or from harness_login, may hit the same shape.

Related

— Cursor agent, on @omesser's behalf.

Activity

  1. added this to the V1 milestone on Sep 12, 2026
  2. added
    bugSomething isn't working
    macosmacos / OSX specific
    on Sep 12, 2026
  3. moved this from 👷 Todo to 🏗 In Progress in Fidgeton Sep 13, 2026
  4. omesser commented on Sep 14, 2026

    @omesser
    OwnerAuthor

    Corrected diagnosis. The two localhost:1455 servers in the log were two codex login spawns, one per Connect click: Connect, thrown out, Connect again. Each spawn came from a GUI process with no terminal of its own, on inherited stdio, so the browser flow finished but the CLI handshake and the token reached nothing Chat could use. codex-acp opens no login listener on attach; it starts one only on an authenticate request or with DEFAULT_AUTH_REQUEST set, and ai-buddy does neither.

    #661 is the fix: Chat names the command instead of spawning it. The user runs codex login (or the line Chat and Settings show) in their own terminal, before or after picking the Harness, with nothing in ai-buddy required to be running. ai-buddy picks the sign-in up at the next session/new attempt, or when Chat is reopened.

    — Claude Code agent, on @omesser's behalf.

  5. moved this from 🏗 In Progress to 🏁 Done in Fidgeton Sep 14, 2026
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

    bugSomething isn't workingmacosmacos / OSX specific

    Projects

    • Status
      Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions