fix(computer): Agents on Anthropic models fail every turn with 401 "invalid x-api-key" when only DeepSeek credentials are injected

Aperta
#824 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Jackzigen ci sta già lavorando.

Dal 27/11/2026.

  • #848 di @Jackzigen — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
ai, backend

Direzione di ricerca

Start by reading the Pi runtime configuration and model credential handling described in the issue; the payload does not name source files or tests. Trace how ANTHROPIC_BASE_URL and the selected model’s catalogue baseUrl are resolved, then check whether a linked pull request already addresses the behavior. Done means Anthropic model runs either use the configured compatible gateway or fail early with a clear missing credential message.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happened

Any Agent whose model is an Anthropic model fails every turn with a raw provider error, while Agents on a DeepSeek model keep working in the same Room at the same time:

401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"},"request_id":"req_011Ch..."}

Direct chat with an Agent on a DeepSeek model is unaffected, which makes it look like "chat works, Rooms are broken".

The model picker still offers anthropic/* models on a Computer that has no Anthropic credential. Selecting one looks fine, and the failure only shows up later, per turn, as a provider 401.

Steps to reproduce
  1. On a Computer whose only model credentials are DeepSeek (free tier or BYOK DeepSeek), create or edit an Agent and set its model to an Anthropic model (e.g. claude-haiku-4-5 / claude-opus-5-5).
  2. Open a Room with that Agent and mention it.
  3. Every turn of that Agent fails with the 401 above; Agents on deepseek/deepseek-flash in the same Room answer normally.

Minimal reproduction outside Linger with the runtime environment Linger injects:

pi -p "reply with OK" --provider anthropic --model claude-haiku-4-5 --no-session
# 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"},"request_id":"req_011Ch..."}

env -u ANTHROPIC_AUTH_TOKEN -u ANTHROPIC_API_KEY -u ANTHROPIC_BASE_URL \
  pi -p "reply with OK" --provider anthropic --model claude-haiku-4-5 --no-session
# No API key found for anthropic.
Area

Agents and runs

Version

0.1.10

Environment
  • Linger 0.1.10 (release build), macOS 26.5.2, Apple Silicon, local TeamHub
  • Agent runtime: Pi (pi-coding-agent 1.5.2), preferredRuntime: pi
Logs

Daemon log, once per failed turn:

{"event":"runtime.operation.failed","runtime_type":"pi","level":"ERROR","error":"401 {\"type\":\"error\",\"error\":{\"type\":\"authentication_error\",\"message\":\"invalid x-api-key\"},\"request_id\":\"req_011ChM15NdGPAYQrnYkJa7Kz\"}"}

The Pi session for the same Agent records the model up front:

{"type":"model_change","provider":"anthropic","modelId":"claude-haiku-4-5"}

Across runtime homes on this Computer, Agents whose model is anthropic/* have failures; Agents whose model is deepseek/deepseek-flash have none.

Why it happens: the runtime environment carries only DeepSeek credentials — DEEPSEEK_API_KEY plus the same key in ANTHROPIC_AUTH_TOKEN, with ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic — while Pi's anthropic provider resolves baseUrl from the model catalogue (https://api.anthropic.com) and ignores ANTHROPIC_BASE_URL. The DeepSeek key is therefore sent to the real Anthropic API as x-api-key and rejected. The same bogus key sent to the DeepSeek Anthropic-compatible endpoint returns a different envelope (Authentication Fails, Your api key: ****-123 is invalid (request_id: <uuid>)), so the 401 above comes from Anthropic, not from DeepSeek.

Either of these would be enough:

  1. Fail the run at start with an explicit message ("this Agent's model needs an Anthropic credential; none is configured on this Computer") instead of a raw 401 per turn.
  2. Let the runtime's ANTHROPIC_BASE_URL win over the catalogue baseUrl, so an Anthropic-compatible gateway can serve anthropic/* models.
  3. Hide or block Anthropic models in the picker on Computers with no Anthropic credential.
Lingua principale
TypeScript
Stelle
3.8k
Fork
360
Merge medio
8h 10m
PR unite (30g)
540

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di simplexai-labs/linger

Tutte le issue di simplexai-labs/linger

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.