Skip to content

backends: a host inference-relay refusal is reported as "Failed to authenticate" and asks for a subscription re-login #3787

Closed

Description

@schlessera

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-157 reports an auth_failure for every class in AUTH_ERROR_CLASSES (packages/ui-backend-claude/src/subscription.ts:55-60). failure (stream-adapter.ts:412-422) attaches the subscription authAction. authFailure (packages/ui-server/src/activity/runtime-status.ts:144-170) records it as the subscription's last failure, with action: "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 as authentication_failed.
  • The 499 variant replays as unknown with the text API 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_refused body 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), in FIRST_PARTY_FAILURE_CLASSES (packages/ui-sdk/src/protocol.ts:1377-1405). Carry no authAction.
  • Do not report it through authFailure, so subscription.lastAuthFailure and the re-login log line stay untouched.
  • Treat a 499 cancelled admission the same way, or as the existing cancellation, never as unknown.
  • 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_changed race 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 failure has no authAction. 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 apiErrorFailure produces the same class, with a test.
  • After such a turn, subscription.lastAuthFailure is unchanged and no "re-login" WARN is emitted. A runtime-status test proves it.
  • A genuine Failed to authenticate that did not come from the relay still classifies as authentication_failed with relogin. The existing tests stay green.
  • The 499 cancelled-admission text no longer replays as unknown.

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

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    area: backendsAgentBackend implementations and the seam they share.
    priority: p1Scheduled into the current or next milestone.
    on Nov 9, 2026
  2. added this to the 0.45.0 milestone on Nov 9, 2026
  3. added
    area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.
    contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 9, 2026
  4. self-assigned this
    on Nov 15, 2026
  5. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-e00013c3. Branch: fix/3787-inference-relay-refusal.

    Collision scan pending; assigned scoped backend correction.

  6. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    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.

  7. schlessera commented on Nov 15, 2026

    @schlessera
    OwnerAuthor

    Merged in #4018 as 571858f0e through 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.

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

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: backendsAgentBackend implementations and the seam they share.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.priority: p1Scheduled into the current or next milestone.type: fixSomething is broken and must behave the way it is documented.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions