Repository navigation
Description
Context
When the host's inference relay refuses a governed Claude turn's model request, the user is told the subscription failed to authenticate and should log in again. Nothing is wrong with the credential.
The relay answers a refused admission with its own error body: 403 (or 499 when the admission was cancelled), { type: "error", error: { type: "brain_inference_refused", message: "Inference network admission refused" } } (refuse, packages/ui-sdk/src/server/inference-relay.ts:95-98, used at :123-127). The Claude runtime reads any 403 from its API as an authentication failure. It writes Failed to authenticate. API Error: 403 Inference network admission refused and tags the assistant message error: "authentication_failed".
brain-kit then takes the runtime's word for it:
- Live.
packages/ui-backend-claude/src/stream-adapter.ts:151-157reports anauth_failurefor every class inAUTH_ERROR_CLASSES(packages/ui-backend-claude/src/subscription.ts:55-60).failure(stream-adapter.ts:412-422) attaches the subscriptionauthAction.authFailure(packages/ui-server/src/activity/runtime-status.ts:144-170) records it as the subscription's last failure, withaction: "relogin", and logs "a turn failed to authenticate … re-login". - Replay.
API_ERROR_TEXTS(packages/ui-backend-claude/src/history.ts:309-315) classes the same text asauthentication_failed. - The
499variant replays asunknownwith the textAPI Error: 499 Inference network admission refused. It names neither the cause nor the remedy.
Observed on a hosted 0.44.0 install (2026-11-04 to 2026-11-09). Three turns ended on relay refusals: two as authentication_failed / 403 and one as unknown / 499. Each refusal has a matching egress_connection governance event to the inference host with outcome: "denied" and a reason: safety_changed for the two 403s (the race tracked in #3725). The token stayed valid throughout, and the next turn on the same session succeeded. Afterwards GET /api/status still reported subscription.lastAuthFailure with action: "relogin" and the 403 text.
The relay refused the request, so the remedy lives in governance (the denial reason and its governance event), not in the login.
Scope
- Recognise a relay refusal before the runtime's authentication classification applies, live and on replay. The relay's own
brain_inference_refusedbody and its fixed message are the signals; brain-kit owns both ends. - Give that failure a dedicated first-party class, e.g.
host_refused(name decided in the PR), inFIRST_PARTY_FAILURE_CLASSES(packages/ui-sdk/src/protocol.ts:1377-1405). Carry noauthAction. - Do not report it through
authFailure, sosubscription.lastAuthFailureand the re-login log line stay untouched. - Treat a
499cancelled admission the same way, or as the existing cancellation, never asunknown. - Where the denial reason is known on the host (
egress_connection.reason), carry it in the failure message, e.g. "The host refused this model request (safety changed during admission)". Then the chat card and the transcript name the cause. If the retained transcript contains only the fixed refusal text, replay must name host refusal without inventing a more specific reason. Preserve the relay wire body and existing status contract unless separately justified.
Out of scope
- Why the relay refused (the
safety_changedrace is ui-server: join announced session binding before relay admission snapshots #3725). This issue only stops the refusal reading as a login problem. - Retrying a refused request.
- Changing the relay's status codes or body, unless the PR shows the runtime cannot be told apart otherwise.
- Pi: check whether Pi's relay client has the same misclassification, and file it separately if so.
Acceptance criteria
- A Claude turn whose relay refuses inference ends with the new class. Its
failurehas noauthAction. Proven by a stream-adapter test fed the runtime's actual synthetic message (error: "authentication_failed"with the relay text), and shown failing before the change. - The same transcript replayed through
apiErrorFailureproduces the same class, with a test. - After such a turn,
subscription.lastAuthFailureis unchanged and no "re-login" WARN is emitted. A runtime-status test proves it. - A genuine
Failed to authenticatethat did not come from the relay still classifies asauthentication_failedwithrelogin. The existing tests stay green. - The
499cancelled-admission text no longer replays asunknown.
Verification
bun run test packages/ui-backend-claude/tests/api-failure.test.ts packages/ui-backend-claude/tests/history-api-failure.test.ts, plus the new stream-adapter and runtime-status cases.- Mutation: remove the relay recognition, and the new tests fail on the class assertion.
Contract impact
Additive: a new first-party TurnFailure.errorClass value (docs/integration-contract/wire.md, "Turn failures"). errorClass is already free-form. Clients that do not know the class render the message.
Bounded reproduction — 2026-11-09
Inspected source: 9c7eb25825fdad5f4485db0df472188805edb450; Bun 1.4.4 (38afee6c8), frozen lockfile, isolated temporary checkout, repository test wrapper and offline preload. Command: bun run test ./tmp/triage/new-issues.test.ts. A temporary keyless fixture drove the real StreamAdapter with a synthetic assistant message (error: "authentication_failed", text Failed to authenticate. API Error: 403 Inference network admission refused) and the ordinary error result. Actual terminal failure was authentication_failed, status 403, authAction: "relogin"; one auth_failure activity event was emitted. HOST_REFUSAL_IS_NOT_AUTH failed on the class assertion. Real apiErrorFailure returned authentication_failed for that 403 and unknown for API Error: 499 Inference network admission refused. No provider or live host was contacted. The fixture failed at the named behavioral assertion, after module loading succeeded. Temporary diagnostic fixtures are outside authored source; this triage changes no product code.
Triage 2026-11-09 at main 9c7eb25825fdad5f4485db0df472188805edb450: Recorded the bounded intended-assertion failure and clarified current source/verification. The existing p1 and 0.45.0 commitment are preserved. It remains standalone: the GitHub-tools epic does not own this backend correction, and no existing open epic owns its full deliverable.
Activity
schlessera commentedon Nov 15, 2026
Claimed for implementation. Claim token:
claim-e00013c3. Branch:fix/3787-inference-relay-refusal.Collision scan pending; assigned scoped backend correction.
schlessera commentedon Nov 15, 2026
Readiness review passed: standalone additive failure classification, no open implementation PR or recent competing claim, and the cited relay/adapter/history/runtime-status paths still establish the reported failure. The path scan found only shared proof-closure collisions with other open PRs, with no direct path collisions. This worker is implementing the scoped correction on
fix/3787-inference-relay-refusal.schlessera commentedon Nov 15, 2026
Merged in #4018 as
571858f0ethrough the integration lease (orchestrator merge queue for 0.45.0). Candidate confirmation passed on the exact head; the squash's own main run carries the post-merge heavy categories.