Repository navigation
Description
Why
An expired OAuth session mid-conversation dumps a raw internal error into the
chat surface. It names no cause the user recognises and offers no way out.
The Harness reported an error: harness: Internal error: Failed to
authenticate: OAuth session expired and could not be refreshed
Three prefixes stack up before the sentence that matters: The Harness reported an error:, then harness:, then Internal error:. The user sent the same
message twice and got the same wall back, which is what a dead end looks like.
The product already knows how to say this well. When a Harness is not signed in
at attach time, not_authenticated (src-tauri/src/harness.rs:1521) produces
"harness not authenticated: run claude /login", and login_command
(:1546) works out the command per Harness. An OAuth token that expires after a
successful attach never reaches that path.
Where it goes wrong
session/new and session/load translate the auth refusal. session/prompt
does not.
src-tauri/src/acp_wire.rs:693, the open path:
if error.code == ErrorCode::AuthRequired {
OpenError::AuthRequired
} else if cx.is_incoming_closed() {
OpenError::Lost
} else {
OpenError::Failed(error.message)
}src-tauri/src/acp_wire.rs:757, the turn path:
Err(_) if cx.is_incoming_closed() => Err(TurnError::Lost),
Err(error) => Err(TurnError::Failed(error.message)),No AuthRequired arm. TurnError (:211) has no variant for it either, so the
raw string travels to src/chat-settle.js:65, which wraps it in a fourth prefix
and renders it:
note: `The Harness reported an error: ${payload.error}`,Two candidate causes, and they need different fixes
If the agent sent -32000 (auth_required), the turn path simply fails to
check the code the open path checks. Mirror :693, add a TurnError::Auth
variant, and route it to the same login_command copy the attach path uses.
If the agent sent -32603 (internal_error) — which is what the words
"Internal error" suggest — then no code check catches it, because the adapter
has flattened an auth failure into a generic one. That needs either a
message-shaped fallback or a fix upstream in the adapter.
Whoever takes this should capture error.code first. It decides the fix, and
the screenshot does not carry it. AI_BUDDY_TRACE_HARNESS is the way in.
Done when
The failure is terminal until a human signs in elsewhere, so this is a state and
not a message. See the correction comment on this issue.
- While a Harness is unauthenticated, the chat composer is disabled. Today
it accepts a second send that is guaranteed to fail, which is how the same
wall appeared twice. - The surface names the login, using the
login_command
(src-tauri/src/harness.rs:1546) the attach path already renders through
not_authenticated(:1521). Never the raw adapter string. - Signing in from another terminal brings the buddy back without a restart,
and the composer re-enables when it does. - The chat item carries one prefix, not four.
- A test pins the turn-path translation the way the attach path is pinned.
Notes
Reported on claude, session 51d9179d, BMO instance. Not reproduced yet; the
trigger is a token expiring in a live session, which no test currently forces.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
omesser commentedon Sep 24, 2026
The chat surface as the user saw it. Two identical questions at 01:57, two identical walls of error.
One detail this adds to the report. At 01:59 the same Harness answered a when summoned wake normally ("You called me! BMO is on top of the Dock…"). So the failure was transient and the session recovered on its own, without a restart. That makes the presentation worse rather than better: the chat gave the user a flat dead end for something that healed two minutes later, and nothing in the item suggested waiting or retrying was worth doing.
— Claude Code agent, on @omesser's behalf.
omesser commentedon Sep 24, 2026
Correction to my previous comment, which was wrong.
I wrote that the 01:59 summoned reply meant the failure was transient and the session recovered on its own. It did not. Oded opened the Harness independently in a terminal, signed in there, and ai-buddy came back to life after that. The recovery was manual and external, not automatic.
I inferred self-healing from two timestamps in a screenshot. The screenshot could not show the login that happened between them, and I should have labelled that a guess instead of stating it. Disregard that reading.
What this actually changes about the fix
The failure is terminal until a human signs in somewhere else. That makes this a state, not a message.
While a Harness is unauthenticated:
login_commandatsrc-tauri/src/harness.rs:1546, and the attach path already renders it throughnot_authenticatedat:1521. The turn path reaches neither.So the shape is a per-Harness auth state that gates the composer and carries the login command, not a prettier error string. The four stacked prefixes are still worth removing, but they are the smaller half.
— Claude Code agent, on @omesser's behalf.
omesser commentedon Sep 24, 2026
On the in-app login button
Measured today, one probe attach per Harness, reading what each advertises in
initialize.authMethods:authMethodsclaudecodexcursor-agentopencodegoosehermesgrokpiFor
claude, the Harness in this report, a button is not possible. It advertises no auth methods at all, so there is nothing for ai-buddy to callsession/authenticatewith. Its login isclaude /loginin a terminal and ACP never sees it. This is not a policy choice, it is what the Harness offers.So the hint is the fix here, not a fallback.
What the button would take, for the Harnesses that could have one
ACP auth methods come in two types.
terminalmeans the client re-runs the agent binary in an interactive terminal, which ADR-0018 forbids, since ai-buddy hosts no terminal and does not setclientCapabilities.auth.terminal.agentmeans the client sendsauthenticateand the agent logs itself in, which is the only shape a button could use.We currently throw that distinction away.
auth_hint(src-tauri/src/acp_wire.rs:1043) flattensAuthMethod::TerminalandAuthMethod::Agentinto oneAuthHint { name, description }with no kind. So today the app cannot tell which of the rows above are button-able. Keeping the type is the precondition for any button work, and it is a one-field change.Two known limits on top of that, recorded 2026-09-14 during #654 / #661 and not re-verified today: claude-code-acp throws not-implemented on
authenticate, and opencode no-ops. On that reading the button would help Codex and maybe cursor-agent, and nobody in this bug report.Recommendation
Ship the hint and the disabled composer under this issue. File the button separately, scoped to
agent-type methods, starting with keeping the kind inAuthHint. That keeps this bug unblocked and gives the button an honest precondition instead of a hope.— Claude Code agent, on @omesser's behalf.
test(harness): Drop the stub agent, the Fixture covers the turn (#991)
omesser commentedon Sep 25, 2026
Shipped on main via #993 (
5449f4f6655b57fffc6e272bdde61db774dd8189).Done-when checked against main:
TurnError::AuthRequired→refuse_login/not_authenticated+login_command; composer gates onopening.loginviaAttachSettled→ReloadChat→attached().auth_refusedcovers-32000anddata.errorKind == "authentication_failed"(no message sniffing).signed_in; session kept (session/newonce).chat-settle.js).auth-turn/auth-turn-32000+an_auth_refusal_on_the_turn_names_the_login_and_the_next_answer_clears_itpins both wire shapes.Deliberately not in this fix: in-app login button / preserving ACP auth method kind. Filed as #1000.
— Cursor agent (Coder), on @omesser's behalf.