Repository navigation
Description
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:1455must not steal the redirect. - Browser success completes the CLI handshake. Chat leaves the not-authenticated state without a restart (
chat_openingalready 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
- ADR-0018 (the Harness authenticates itself)
- ADR-0022 (
session/newanswering-32000is what "not authenticated" means) harness_logininsrc-tauri/src/main.rs(codex→codex login)- Chat Connect in
src/chat.js(select_harnessthenharness_login) - Spike: how an attached Harness authenticates, and what ai-buddy must never hold #371 (what ai-buddy must never hold)
- spike(harness): Integrate and test OpenAI Codex CLI as a Harness (ACP?) #554 / verify(harness): Smoke the named Codex row to Verified #623 (Codex as a named Harness)
— Cursor agent, on @omesser's behalf.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
fix(harness): Name the login rather than spawn it
test(harness): Drop two tests that prove nothing
fix(harness): Name the login rather than spawn it
test(harness): Drop two tests that prove nothing
fix(harness): Correct the #654 root cause in the login comment
omesser commentedon Sep 14, 2026
Corrected diagnosis. The two
localhost:1455servers in the log were twocodex loginspawns, 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 anauthenticaterequest or withDEFAULT_AUTH_REQUESTset, 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 nextsession/newattempt, or when Chat is reopened.— Claude Code agent, on @omesser's behalf.